$npx -y skills add softspark/ai-toolkit --skill mcp-builderBuilds production MCP servers via 4-phase methodology: research, implement, test, evaluate. Triggers: build MCP, new MCP, MCP integration, MCP server scaffold.
| 1 | # MCP Builder |
| 2 | |
| 3 | $ARGUMENTS |
| 4 | |
| 5 | Build a production-grade MCP server following Anthropic's 4-phase methodology. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | - Wrapping a third-party REST API as MCP tools |
| 10 | - Exposing an internal database or service to Claude |
| 11 | - Creating reusable integrations for the team |
| 12 | - Migrating a custom tool into the MCP ecosystem |
| 13 | |
| 14 | For MCP protocol theory, see `mcp-patterns` knowledge skill (auto-loaded). |
| 15 | |
| 16 | ## 4-Phase Workflow |
| 17 | |
| 18 | ### Phase 1 — Research & Planning |
| 19 | |
| 20 | 1. Read the target API's documentation (OpenAPI spec, README, changelog). |
| 21 | 2. Identify the 5-15 most useful operations. Prefer workflow-oriented tools over 1:1 API mirror. |
| 22 | 3. Decide transport: `stdio` for local dev tools, `streamable-http` for remote/shared. |
| 23 | 4. Decide language: **TypeScript recommended** (best SDK), Python acceptable (`mcp` package). |
| 24 | 5. List required secrets (API keys, tokens) and their env var names. |
| 25 | |
| 26 | Output: `PLAN.md` with tool list, transport choice, auth model. |
| 27 | |
| 28 | ### Phase 2 — Implementation |
| 29 | |
| 30 | Scaffold: |
| 31 | ``` |
| 32 | my-mcp/ |
| 33 | ├── package.json # or pyproject.toml |
| 34 | ├── src/ |
| 35 | │ ├── server.ts # entry point |
| 36 | │ ├── client.ts # API client (axios/httpx) |
| 37 | │ ├── tools/ # one file per tool |
| 38 | │ ├── schemas.ts # Zod/Pydantic schemas |
| 39 | │ └── errors.ts # typed errors |
| 40 | ├── .env.example |
| 41 | └── README.md |
| 42 | ``` |
| 43 | |
| 44 | Per tool: |
| 45 | - Input/output schemas (Zod for TS, Pydantic for Python) |
| 46 | - Clear `name` with service prefix (e.g. `github_create_issue`) |
| 47 | - Description starts with a verb, mentions trigger keywords |
| 48 | - Annotations: `readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint` |
| 49 | - Pagination support via `cursor` or `page` parameters |
| 50 | - Focused responses — filter noise, don't dump raw API payloads |
| 51 | |
| 52 | ### Phase 3 — Review & Testing |
| 53 | |
| 54 | - TypeScript: `npm run typecheck && npm run lint && npm test` |
| 55 | - Python: `ruff check . && mypy --strict src/ && pytest` |
| 56 | - MCP Inspector dry-run: |
| 57 | ```bash |
| 58 | npx @modelcontextprotocol/inspector node dist/server.js |
| 59 | ``` |
| 60 | - Verify each tool's schema validates a real request and rejects malformed input. |
| 61 | |
| 62 | ### Phase 4 — Evaluation |
| 63 | |
| 64 | Write 10 realistic end-user questions that an LLM should be able to answer using your server. Run them through Claude with the server attached. Grade: did the model call the right tool? Did the response give enough to answer? Fix the description, schema, or response format of any tool that failed. |
| 65 | |
| 66 | Example eval questions for a `github-mcp`: |
| 67 | 1. "What issues are open on repo X with label `bug`?" |
| 68 | 2. "Create an issue titled Y in repo Z" |
| 69 | 3. "Who has the most commits this month in repo X?" |
| 70 | |
| 71 | When a tool fails an eval, the cause is almost always the description, not the schema. Score each tool against the description rubric in `mcp-patterns` (one-line purpose, WHEN TO USE, WHEN NOT TO USE, CRITICAL, self-test). A tool with an empty **WHEN NOT TO USE** is under-specified — it will misfire the moment a second tool in the same server overlaps with it, so add the boundary before re-running the eval. See `mcp-patterns` → "How to Write a Tool Description" for the full rubric and worked example. |
| 72 | |
| 73 | ## Tool Design Checklist |
| 74 | |
| 75 | - [ ] Name has service prefix and is verb-led |
| 76 | - [ ] Description mentions when to use it and includes trigger keywords |
| 77 | - [ ] Description carries a non-empty **WHEN NOT TO USE** that names overlapping tools (see `mcp-patterns` rubric) |
| 78 | - [ ] Input schema is strict, no free-form `object` with `additionalProperties: true` |
| 79 | - [ ] Output is focused — essential fields only, with pagination cursor if applicable |
| 80 | - [ ] Error responses are actionable ("API returned 403 — check `GITHUB_TOKEN` env var") |
| 81 | - [ ] Annotations set correctly (readonly/destructive/idempotent) |
| 82 | - [ ] No secrets logged or echoed in errors |
| 83 | - [ ] Rate limiting respects the upstream API |
| 84 | |
| 85 | ## Transport Cheat Sheet |
| 86 | |
| 87 | | Scenario | Transport | |
| 88 | |----------|-----------| |
| 89 | | Local dev tool, 1 user | `stdio` | |
| 90 | | Remote server, multiple users | `streamable-http` with SSE | |
| 91 | | Internal company tool, auth required | `streamable-http` + OAuth proxy | |
| 92 | | Embedded in IDE/editor | `stdio` spawned by editor | |
| 93 | |
| 94 | ## Registration Cheat Sheet |
| 95 | |
| 96 | Local Claude Code (`.mcp.json`): |
| 97 | ```json |
| 98 | { |
| 99 | "mcpServers": { |
| 100 | "my-mcp": { |
| 101 | "command": "node", |
| 102 | "args": ["dist/server.js"], |
| 103 | "env": { "API_KEY": "$MY_API_KEY" } |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | ``` |
| 108 | |
| 109 | Global Claude Code (user-scope): |
| 110 | ```bash |
| 111 | claude mcp add my-mcp --scope user -- node /path/to/server.js |
| 112 | ``` |
| 113 | |
| 114 | Claude Desktop: same JSON, placed in `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS). |
| 115 | |
| 116 | ## Common Pitfalls |
| 117 | |
| 118 | | Mistake | Fix | |
| 119 | |---------|-----| |
| 120 | | 1:1 API mirror with 80 tools | Pick 10 workflow-oriented tools | |
| 121 | | `description: "wrapper for /users endpoint" |