mcp-builder

Featured

MCP 服务器构建方法论 — 系统化构建生产级 MCP 工具,让 AI 助手连接外部能力

AI & Automation 7,264 stars 705 forks Updated 4 days ago MIT

Install

View on GitHub

Quality Score: 98/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# MCP 服务器构建 系统化设计、实现、测试和部署 Model Context Protocol 服务器的方法论。 ## 1. 协议核心概念 MCP 定义三种原语: - **Tools(工具)**:AI 助手主动调用的函数,有副作用。如搜索、创建、删除操作。 - **Resources(资源)**:AI 助手只读访问的数据源,用 URI 标识。如 `users://{id}/profile`。 - **Prompts(提示词模板)**:预定义交互模板,引导用户触发工作流。 **选择原则:** 执行操作 → Tool | 读取数据 → Resource | 引导交互 → Prompt ## 2. 项目结构规范 ### TypeScript ``` my-mcp-server/ ├── src/ │ ├── index.ts # 入口,注册 tools/resources │ ├── tools/ # 按功能拆分 │ ├── resources/ │ └── lib/ # 客户端封装、校验逻辑 ├── tests/ ├── package.json └── tsconfig.json ``` 关键依赖:`@modelcontextprotocol/sdk` + `zod` ### Python ``` my-mcp-server/ ├── src/my_mcp_server/ │ ├── server.py │ ├── tools/ │ └── lib/ ├── tests/ └── pyproject.toml ``` 关键依赖:`mcp` + `pydantic` ## 3. Tool 设计原则 ### 命名 - `snake_case` 格式,动词开头:`search_users`、`create_issue`、`delete_file` - 名称自解释,AI 助手靠名称选工具,模糊命名导致误调用 ### 参数 - 每个参数有类型约束和 `.describe()` 描述 - 可选参数给默认值,减少 AI 决策负担 - 用枚举代替布尔开关 ```typescript server.tool("search_issues", { query: z.string().describe("搜索关键词"), status: z.enum(["open", "closed", "all"]).default("open").describe("状态筛选"), limit: z.number().min(1).max(100).default(20).describe("返回上限"), }, async ({ query, status, limit }) => { /* ... */ }); ``` ### 描述 说明**用途 + 返回内容 + 限制**,这是 AI 选择工具的关键依据: ```typescript server.tool("search_users", "根据姓名或邮箱搜索用户。返回 ID、姓名、邮箱列表。模糊匹配,最多 50 条。", schema, handler); ``` ### 输出 - 结构化数据 → JSON,人类可读内容 → Markdown - 始终用 `content: [{ type: "text", text: "..." }]` 格式返回 ## 4. 输入验证...

Details

Author
jnMetaCode
Repository
jnMetaCode/superpowers-zh
Created
4 months ago
Last Updated
4 days ago
Language
JavaScript
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

mcp-server-dev

Build MCP (Model Context Protocol) servers in TypeScript with @modelcontextprotocol/sdk. Use when writing, reviewing, or refactoring MCP server code: (1) Creating MCP servers with McpServer, (2) Registering tools with registerTool, inputSchema, outputSchema, Zod validation, (3) Defining resources and resource templates, (4) Defining prompts with arguments, (5) Transports: StdioServerTransport, NodeStreamableHTTPServerTransport, SSE, (6) Tool annotations (readOnlyHint, destructiveHint, idempotentHint), (7) Error handling and isError responses, (8) Dynamic tool loading and tool list change notifications, (9) Middleware patterns for MCP tools, (10) Testing MCP servers with vitest, (11) Publishing and configuring for Claude Code, Cursor, Windsurf, (12) Any @modelcontextprotocol/sdk imports.

3 Updated 3 days ago
arthjean
AI & Automation Solid

mcp-builder

Use when creating a new MCP (Model Context Protocol) server, extending an existing one, or debugging tool discoverability/performance. Guides through research → implementation → test → eval phases with TypeScript-first guidance matching our stack. Trigger on phrases like "build an MCP server", "expose X as an MCP tool", "write MCP tools for Y", "integrate Z via MCP".

48 Updated today
Kanevry
AI & Automation Solid

mcp-server

Use when building a Model Context Protocol server. Covers tool, resource, and prompt design, transport choice, authentication, error handling, and testing an MCP server against a real client.

23 Updated today
nimadorostkar