Install any skill in seconds. Free to start, no credit card required.
Get Started Free →日本語翻訳:このファイルは mcp-server-patterns 用の日本語翻訳が必要です
.claude/skills/affaan-m-mcp-server-patterns/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 100% | 6 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 21% | 0% |
| case-07 | ✗→✓ | ▲ Improved | -37% | 0% |
| case-14 | ✗→✓ | ▲ Improved | -3% | 0% |
| case-17 | ✗→✓ | ▲ Improved | -2% | 0% |
| case-20 | ✗→✓ | ▲ Improved | 9% | 0% |
模型上下文协议(MCP)允许 AI 助手调用工具、读取资源和使用来自服务器的提示。在构建或维护 MCP 服务器时使用此技能。SDK API 会演进;请查阅 Context7(查询文档 "MCP")或官方 MCP 文档以获取当前的方法名称和签名。
在以下情况时使用:实现新的 MCP 服务器、添加工具或资源、选择 stdio 与 HTTP、升级 SDK,或调试 MCP 注册和传输问题。
registerTool() 或 tool() 注册。registerResource() 或 resource() 注册。处理程序通常接收一个 uri 参数。registerPrompt() 或等效方法注册。Node/TypeScript SDK 可能暴露 tool() / resource() 或 registerTool() / registerResource();官方 SDK 已随时间变化。请始终根据当前 MCP 文档 或 Context7 进行验证。
对于本地客户端,创建一个 stdio 传输并将其传递给服务器的连接方法。确切的 API 因 SDK 版本而异(例如构造函数与工厂函数)。请参阅官方 MCP 文档或查询 Context7 中的 "MCP stdio server" 以获取当前模式。
保持服务器逻辑(工具 + 资源)独立于传输,以便您可以在入口点中插入 stdio 或 HTTP。
对于 Cursor、云端或其他远程客户端,使用可流式 HTTP(根据当前规范,每个 MCP HTTP 端点)。仅在需要向后兼容性时支持传统 HTTP/SSE。
bashnpm install @modelcontextprotocol/sdk zod
typescriptimport { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; const server = new McpServer({ name: "my-server", version: "1.0.0" });
使用您的 SDK 版本提供的 API 注册工具和资源:某些版本使用 server.tool(name, description, schema, handler)(位置参数),其他版本使用 server.tool({ name, description, inputSchema }, handler) 或 registerTool()。资源同理——当 API 提供时,在处理程序中包含一个 uri。请查阅官方 MCP 文档或 Context7 以获取当前的 @modelcontextprotocol/sdk 签名,避免复制粘贴错误。
使用 Zod(或 SDK 首选的模式格式)进行输入验证。
@modelcontextprotocol/sdk (npm)。使用库名 "MCP" 的 Context7 以获取当前的注册和传输模式。modelcontextprotocol/go-sdk)。| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 57,397 | 27,314 | -52% | 1 | 1 | 0% | 4,776 | 5,787 | +21% | 0 | 0 | — |
case-02 | pass→pass | 6,495 | 5,282 | -19% | 1 | 1 | 0% | 1,241 | 1,833 | +48% | 0 | 0 | — |
case-03 | pass→pass | 16,279 | 15,344 | -6% | 1 | 1 | 0% | 3,000 | 4,218 | +41% | 0 | 0 | — |
case-04 | pass→pass | 11,385 | 9,344 | -18% | 1 | 1 | 0% | 2,384 | 2,875 | +21% | 0 | 0 | — |
case-05 | pass→pass | 13,956 | 13,748 | -1% | 1 | 1 | 0% | 2,563 | 3,465 | +35% | 0 | 0 | — |
case-06 | pass→pass | 6,923 | 2,988 | -57% | 1 | 1 | 0% | 1,073 | 1,350 | +26% | 0 | 0 | — |
case-07 | fail→pass | 16,412 | 4,588 | -72% | 1 | 1 | 0% | 2,562 | 1,614 | -37% | 0 | 0 | — |
case-08 | pass→pass | 4,850 | 3,612 | -26% | 1 | 1 | 0% | 767 | 1,518 | +98% | 0 | 0 | — |
case-09 | pass→pass | 11,921 | 8,459 | -29% | 1 | 1 | 0% | 2,005 | 2,323 | +16% | 0 | 0 | — |
case-10 | pass→pass | 8,258 | 8,652 | +5% | 1 | 1 | 0% | 1,602 | 2,520 | +57% | 0 | 0 | — |
case-11 | pass→pass | 11,232 | 6,880 | -39% | 1 | 1 | 0% | 1,718 | 1,897 | +10% | 0 | 0 | — |
case-12 | pass→pass | 15,268 | 24,194 | +58% | 1 | 1 | 0% | 2,534 | 3,414 | +35% | 0 | 0 | — |
case-13 | pass→pass | 10,482 | 7,207 | -31% | 1 | 1 | 0% | 1,834 | 2,050 | +12% | 0 | 0 | — |
case-14 | fail→pass | 9,550 | 3,500 | -63% | 1 | 1 | 0% | 1,450 | 1,401 | -3% | 0 | 0 | — |
case-15 | pass→pass | 9,591 | 8,203 | -14% | 1 | 1 | 0% | 1,803 | 2,382 | +32% | 0 | 0 | — |
case-16 | pass→pass | 11,711 | 8,455 | -28% | 1 | 1 | 0% | 1,856 | 2,138 | +15% | 0 | 0 | — |
case-17 | fail→pass | 8,546 | 2,371 | -72% | 1 | 1 | 0% | 1,224 | 1,200 | -2% | 0 | 0 | — |
case-18 | pass→pass | 16,170 | 11,048 | -32% | 1 | 1 | 0% | 2,257 | 2,624 | +16% | 0 | 0 | — |
case-19 | pass→pass | 10,457 | 1,743 | -83% | 1 | 1 | 0% | 1,836 | 1,062 | -42% | 0 | 0 | — |
case-20 | fail→pass | 7,994 | 3,856 | -52% | 1 | 1 | 0% | 1,346 | 1,470 | +9% | 0 | 0 | — |
case-21 | pass→pass | 19,084 | 17,853 | -6% | 1 | 1 | 0% | 3,274 | 4,079 | +25% | 0 | 0 | — |
case-22 | fail→pass | 15,332 | 14,174 | -8% | 1 | 1 | 0% | 2,288 | 3,181 | +39% | 0 | 0 | — |
case-23 | fail→pass | 12,331 | 5,891 | -52% | 1 | 1 | 0% | 1,887 | 1,771 | -6% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +30 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.