Skip to main content
Glama

mcp-toolforge

一个元 MCP 服务器,能够根据自然语言工具描述生成新的 MCP 服务器。

给定项目名称、简短描述,以及一系列自然语言工具描述(例如 "fetches the weather for a string city and returns a string summary"),mcp-toolforge 会生成一个完整、可运行的 MCP 服务器项目——schema、实现、带真实断言的测试、README、LICENSE——即可安装并运行。

flowchart TD
    subgraph Client_Layer["AI Client / Claude Desktop"]
        A["Client (Claude, Cursor, etc.)"]
    end
    subgraph Meta_Server["mcp-toolforge (this repo)"]
        M["mcp_toolforge.server"]
        G["mcp_toolforge.generator"]
    end
    subgraph Generated["Generated Server Project"]
        P["src/<pkg>/__init__.py"]
        S["src/<pkg>/server.py"]
        T["tests/test_<pkg>.py"]
        R["README.md"]
        L["LICENSE"]
        PP["pyproject.toml"]
    end

    A -- "MCP stdio JSON-RPC" --> M
    M -- "generate_server tool call" --> G
    G -- "writes files" --> P
    G -- "writes files" --> S
    G -- "writes files" --> T
    G -- "writes files" --> R
    G -- "writes files" --> L
    G -- "writes files" --> PP

架构

┌─────────────────────┐     ┌──────────────────────────┐
│   AI Client         │  stdio  │  mcp-toolforge server  │
│ (Claude, Cursor)    │──JSON──│  (this repo)           │
└─────────────────────┘  RPC    └────────┬───────────────┘
                                          │ generate_server
                                          │  (name, description,
                                          │   tool_descriptions, dest)
                                          ▼
                        ┌────────────────────────────────────┐
                        │  generator.generate_project()      │
                        │  parses NL → ToolSpec → ServerSpec │
                        │  renders: pyproject, server.py,    │
                        │  tests, README, LICENSE            │
                        └────────────────────────────────────┘
                                          │
                        ┌─────────────────┴─────────────────┐
                        │  Example generated servers         │
                        │  • examples/weather_server         │
                        │  • examples/todo_server            │
                        │  • examples/math_server            │
                        └────────────────────────────────────┘

Related MCP server: MCP Server Generator

快速入门

安装 mcp-toolforge

pip install -e ".[dev]"

自行运行 mcp-toolforge(元服务器)

作为 MCP 服务器(stdio 传输):

{
  "mcpServers": {
    "mcp-toolforge": {
      "command": "python",
      "args": ["-m", "mcp_toolforge.server"],
      "cwd": "/path/to/mcp-toolforge"
    }
  }
}

或者作为生成独立服务器项目的 CLI:

# Interactive wizard
mcp-toolforge -i

# One-shot
mcp-toolforge \
  --name my_server \
  --description "A server that does X" \
  --tool "fetches the weather for a string city and returns a string summary" \
  --dest ./my_server

使用 generate_server 工具

当 mcp-toolforge 注册为 MCP 服务器后,AI 代理可以调用:

generate_server(
  name="my_server",
  description="A server that does X",
  tool_descriptions=[
    "fetches the weather for a string city and returns a string summary",
    "adds a string task and returns a string confirmation"
  ],
  dest="/path/to/output"  # optional, defaults to /tmp/mcp-toolforge-gen
)

该工具会将完整项目写入 dest/<package_name>/,并返回一个摘要字符串。随后,生成的服务器可以独立安装并注册到你的 MCP 客户端中。

自然语言解析的工作原理

每个工具描述都应遵循以下模式:

<VERB> [a/an] <type> <name> [, <type> <name>] ... and returns <type> <description>

示例:

描述

工具名

参数

fetches the weather for a string city and returns a string summary

fetch

city: string

adds a string task and returns a string confirmation

add

task: string

multiplies two numbers given a number a and number b and returns a number product

multiply

a: number, b: number

lists all todos and returns an array of todo items

list

query: string(回退)

已识别的参数类型:string、integer、number、boolean、array。如果未检测到带类型的参数,则会推断出一个自由形式的 query: string 参数。

示例

三个示例服务器会生成到 examples/ 目录中:

服务器

包名

工具

描述

WeatherServer

weather_server

fetch, forecast

获取天气信息

TodoServer

todo_server

add, list, remove

管理待办事项列表

MathServer

math_server

add, multiply, compute

算术工具

每个示例都是一个完整可运行的 MCP 服务器,并自带测试:

cd examples/math_server
pip install -e .
pytest

开发

# Install with dev dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run end-to-end test against the meta-server over stdio
python e2e_test.py

# Regenerate examples
python make_examples.py

测试

  • tests/test_generator.py — 生成器的 16 个测试(解析、schema 推断、文件渲染、项目创建)

  • tests/test_server.py — 元 MCP 服务器的 5 个测试(工具列表、工具调用、错误处理)

  • e2e_test.py — 端到端测试,以真实的 stdio 子进程方式运行元服务器,并通过 MCP Client 连接

  • 每个示例服务器自带 4 个测试(3 个示例共 12 个)

所有测试均使用真实断言,并验证实际文件输出 / 工具结果。

许可证

MIT — 参见 LICENSE。

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    An intelligent tool that automates the setup of new Model Context Protocol (MCP) server projects through a conversational interface. It generates project structures, technical specifications, and context-rich documentation to streamline AI-assisted development in TypeScript or Python.
    10
    3
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Generates production-ready MCP servers with dual-mode (MCP + CLI) architecture, tests, and documentation. Includes progressive disclosure tools for AI agents and best practices guidance.
    7
    35 PyPI
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Automatically generates MCP server tools from OpenAPI specifications, enabling LLMs to interact with any API defined by an OpenAPI spec through natural language.
    13 npm
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Generates complete, runnable MCP server projects from natural-language tool descriptions, including schema, implementation, tests, README, and license. It enables AI agents to scaffold standalone MCP servers ready to install and run.
    MIT