NLBackend

NLBackend

Define backends in natural language via Markdown files; provides auto-generated CRUD tools, custom actions, business rules, workflows, and system tools for LLMs through the Model Context Protocol.

Category
访问服务器

README

NLBackend

Define backends in natural language. Run them via MCP.

NLBackend is a framework where you describe your data models, business rules, actions, and workflows in plain Markdown files — and the framework turns them into a fully functional API that LLMs can interact with through the Model Context Protocol.

No code. Just natural language.

schema/user.md          →  users_create, users_get, users_list, users_update, users_delete
schema/recipe.md        →  recipes_create, recipes_get, recipes_list, ...
rules/permissions.md    →  enforced on every operation
workflows/publish.md    →  run_workflow("publish")

How it works

┌─────────────────────────────────────────────────────────────┐
│                     Your Project (Markdown)                 │
│  schema/*.md   actions/*.md   rules/*.md   workflows/*.md   │
└──────────────────────────┬──────────────────────────────────┘
                           │
                    ┌──────▼──────┐
                    │  NLBackend  │  ← compiles schemas, registers tools
                    │  MCP Server │  ← file-based DB, auto CRUD
                    └──────┬──────┘
                           │ stdio (MCP protocol)
                    ┌──────▼──────┐
                    │  Claude /   │  ← calls users_create, query_db, etc.
                    │  Any LLM    │
                    └─────────────┘

Two LLM roles:

  • Building LLM — reads claude.md files, writes .md definitions. Builds the backend.
  • Consuming LLM — connects via MCP, calls tools, reads/writes data. Uses the backend.

Quick start

Prerequisites

Bun v1.0+:

curl -fsSL https://bun.sh/install | bash

Install & create a project

git clone https://github.com/your-org/nlbackend.git
cd nlbackend
bun install

# Scaffold a new project
bun run src/cli.ts init my-app

Define your data model

Create my-app/schema/task.md:

# Task

A task in a to-do list.

## Fields

- **id**: string, auto uuid, immutable
- **title**: string, required, min 1, max 200
- **done**: boolean, default false
- **created_at**: string, auto timestamp, immutable
- **updated_at**: string, auto timestamp

That's it. The framework auto-generates tasks_create, tasks_get, tasks_list, tasks_update, and tasks_delete tools.

Start the server

bun run src/index.ts ./my-app

Connect an LLM

bun run src/cli.ts config ./my-app

This outputs the MCP config JSON. Paste it into your client:

Claude Desktop (~/.claude/claude_desktop_config.json):

{
  "mcpServers": {
    "my-app": {
      "command": "bun",
      "args": ["run", "/path/to/nlbackend/src/index.ts", "/path/to/my-app"]
    }
  }
}

Cursor (.cursor/mcp.json): same format.

The LLM can now call tasks_create, tasks_list, query_db, and all other tools.

Project structure

my-app/
├── project.md              # Name & description
├── claude.md               # Instructions for the Building LLM
├── schema/                 # Data models (one .md per entity)
│   └── claude.md           # Conventions for writing schemas
├── actions/                # Custom MCP tools beyond CRUD
│   └── claude.md
├── rules/                  # Business rules & validation
│   └── claude.md
├── workflows/              # Multi-step processes (saga pattern)
│   └── claude.md
├── integrations/           # External service configs (email, webhooks)
│   └── claude.md
├── config/server.md        # LLM provider settings
├── tests/                  # Natural language test scenarios
│   └── claude.md
└── db/                     # Auto-managed file database

Every folder has a claude.md that teaches an LLM how to write files for that folder. Share the project with Claude and describe what you want — it knows the conventions.

What you get automatically

You write Framework provides
schema/user.md users_create, users_get, users_list, users_update, users_delete
schema/recipe.md Same 5 CRUD tools for recipes
actions/recipes/search.md Custom recipes_search tool
rules/permissions.md Enforced business rules
workflows/publish.md run_workflow("publish")
Nothing describe_api, query_db, mutate_db, inspect, compile, explain, run_workflow

Schema keywords

Schemas are compiled with a rule-based parser (no LLM needed). Use these recognized keywords:

Keyword Example
required - **title**: string, required
optional - **bio**: string, optional
default - **role**: string, enum viewer/editor/admin, default "editor"
enum - **status**: string, enum draft/published/archived
min / max - **rating**: integer, min 1, max 5
unique - **email**: string, required, unique
indexed - **username**: string, indexed
reference to - **author_id**: string, required, reference to User
auto uuid - **id**: string, auto uuid, immutable
auto timestamp - **created_at**: string, auto timestamp, immutable
auto increment - **version**: integer, auto increment
immutable Cannot be changed after creation

System tools

These are always available on every NLBackend server:

Tool Purpose
describe_api Returns all schemas, tools, and compilation status
query_db Read with filters, sorting, pagination
mutate_db Low-level create/update/delete
inspect View compiled state of any schema, action, rule, or workflow
compile Trigger LLM compilation of actions/rules/workflows
explain Dry-run — shows what would happen without executing
run_workflow Execute a multi-step workflow

MCP resources

The server exposes read-only resources for the consuming LLM:

Resource URI Content
nlbackend://project Full project overview, data model, available tools, getting-started guide
nlbackend://schema/{entity} Detailed schema for a specific entity

CLI

nlbackend <project-path>              # Start the MCP server
nlbackend <project-path> --compile    # Start with LLM compilation
nlbackend init [<folder>]             # Create a new project from template
nlbackend config [<project-path>]     # Output MCP client connection config
nlbackend test [<project-path>]       # Run .test.md natural language tests
nlbackend version                     # Print version

Advanced features

Actions (custom tools)

For operations beyond CRUD, create action files in actions/{entity}/:

# Search Recipes

> Tier: 2
> Auth: public

Searches recipes by keyword, cuisine, or ingredients.

## Input
- **query**: string, optional — keyword search
- **cuisine**: string, optional — filter by cuisine type
- **max_time**: integer, optional — max cooking time in minutes

## Output
Returns matching recipes sorted by relevance.

Actions are LLM-compiled into execution plans. Requires ANTHROPIC_API_KEY and --compile flag.

Rules

Define business rules in rules/*.md:

# Permissions

## Only owners can edit
A user can only update or delete a recipe if they are the author.

## Admin override
Users with role "admin" can update or delete any record.

Workflows

Multi-step processes with saga-pattern compensation:

# Publish Recipe

## Trigger
When a recipe's status changes to "published".

## Steps
1. Validate all required fields are present
2. Generate a URL-friendly slug from the title
3. Send notification email to followers
4. Update recipe status to "published"

## On failure
If any step fails, revert the status to "draft".

Integrations

Connect external services in integrations/*.md:

# Email Integration

## Provider
Resend (https://api.resend.com)

## Authentication
API key stored in environment variable RESEND_API_KEY

## Available Actions

### Send Email
- **to**: email address (required)
- **subject**: text (required)
- **body**: text or html (required)

Natural language tests

Write tests in .test.md with Given/When/Then:

# User CRUD Tests

## Create a user
- Given an authenticated user with role "admin"
- When calling users_create with:
    - username: "alice"
    - email: "alice@example.com"
- Then response contains field "id"
- And response field "username" equals "alice"

Run with: nlbackend test ./my-app

Example project

See example-recipes/ for a complete Recipe Sharing Platform with users, recipes, reviews, favorites, search actions, and an email integration.

Development

bun install
bun test              # 62 unit tests
bun run typecheck     # TypeScript strict mode

# Run the example project
bun run src/index.ts ./example-recipes

# Run the smoke test (29 end-to-end tests)
bun run example-recipes/tests/smoke-test.ts

Architecture

  • Compiler — Rule-based for schemas, LLM-powered for actions/rules/workflows
  • Database — File-based JSON with WAL, in-memory indexes, per-collection locks
  • Runtime — Action executor, rule engine, workflow executor (saga pattern)
  • Server — MCP over stdio with auto-generated CRUD tools + system tools + resources
  • Cache.compiled/ directory for warm starts without LLM calls

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选