| name | mcp-server-design |
| description | Design and implement an MCP server's tools, resources, and prompts with safe transport and input validation. Use when building or extending a Model Context Protocol server for agent integration. |
MCP server design
Use this skill when
- Creating or extending an MCP server that exposes this project to AI agents
- Adding tools, resources, or prompts
- Configuring
.cursor/mcp.example.json / .mcp.json
Procedure
- Read the MCP specification and your SDK's docs.
- Pick a clear, stable server name and a tool-naming scheme (
<scope>_<verb>, e.g. db_query).
- Transport: stdio by default; pass secrets via environment variables, never CLI args.
- Tools — validate every input with a schema (e.g. Zod / pydantic). Prefer a small, compact
surface (a
search + dispatch pair) over dozens of raw tools when the domain is large.
- Separate read from write. Read-only tools are safe-by-default; write/side-effecting tools
must require explicit confirmation (e.g. a
confirmed: true flag and an allowlist of actions).
- Resources — expose read-only context (status, schema, recent events) — no secrets.
- Prompts — ship reusable prompt templates for common workflows where helpful.
- On a downstream/dependency failure: return structured diagnostics, do not throw opaque errors.
- Test tool handlers with mocked dependencies (no live side effects in unit tests).
Safety checks
- No raw shell / file / network / arbitrary-code tools without an explicit approval policy.
- All tool inputs validated against a schema.
- Side-effecting tools gated behind confirmation + allowlist; destructive actions need a written
authorization path. See .agent/SAFETY.md.
Done criteria
- Tool list matches the published schemas; descriptions are accurate and current.
- Secrets only via env; never logged or returned in tool output.
- Build produces the server entrypoint referenced by your MCP config.
- An inventory/reference doc is regenerated when the tool set changes.
References: MCP docs, Cursor / Claude Code MCP configuration guides.