Build, iterate, and evaluate Model Context Protocol (MCP) servers that expose external services as tools an LLM can call. Use when asked to "build an MCP server
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-create-mcp-server-4fe204fc78de ,按照其中的说明把「create-mcp-server」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Invocation points:
/gsd mcp init scaffolds config but there's a tool integration to build<core_principle> THE QUALITY METRIC IS TASK COMPLETION, NOT SCHEMA VALIDITY. A server that lists 30 tools with cryptic names and empty descriptions passes the protocol but fails the point. The tool description is the only thing an LLM has to decide whether to call it — write it like documentation for a stranger under time pressure.
DESIGN FOR THE MODEL, NOT THE API. A raw REST endpoint is rarely the right tool. Group, filter, and pre-shape responses so the model gets what it needs to reason, not a 40KB JSON blob it has to summarize. Fewer, deeper tools beat many, shallow ones. </core_principle>
Skeleton:
server/
src/
index.ts # MCP entry point — stdio or sse transport
client.ts # API client with auth, retries, typed errors
tools/ # one file per tool, or grouped by domain
pagination.ts # shared cursor handling
errors.ts # MCP-friendly error formatting
package.json # @modelcontextprotocol/sdk as dep
tsconfig.json
README.md # how to run, env vars, rate-limit notes
evals.xml # 10 eval questions (Phase 4)
Core infrastructure goes first: API client with typed errors, pagination helpers, consistent retry/timeout behavior. Do not inline these per tool.
For each tool:
search_issues, get_customer, create_deployment. Not do_thing or api_v2_post.cursor: abc123 to continue."Write 10 evaluation questions in evals.xml that exercise the server end-to-end. Each question should require 2+ tool calls and at least one decision the model has to make based on earlier output. Cover:
Format:
<evals>
<eval id="1">
<question>...user request...</question>
<expected>...concrete observable answer or tool-call sequence...</expected>
</eval>
</evals>
Run the evals. If the model can't complete them, the server — not the model — needs work. Iterate on descriptions, error messages, and tool granularity.
Write the project's .mcp.json entry using /gsd mcp init as a starting point. Document env vars and startup in README.md. If the server is globally useful, suggest the user file it as a durable skill via spike-wrap-up or publish it.
<anti_patterns>
{"error": "500"} is useless. Translate.</anti_patterns>
<success_criteria>
evals.xml has 10 questions; the model completes ≥8 without handholding..mcp.json entry.</success_criteria>