audit-agentic-mcp — Audit, Optimize, Architect MCP Servers
The agent-readiness front door for MCP servers. Decides what is wrong, what should change, which reference applies, which companion skill implements the fix, and how to verify the result.
This skill does not write SDK code. It diagnoses, prescribes, and routes.
When to use
Trigger when the user asks any of:
- "audit my MCP server" / "review this MCP server" / "is my MCP server agent-ready?"
- "optimize my MCP server" / "my agent keeps misusing this tool — what's wrong?"
- "design a new MCP server" / "should this be an MCP or a CLI?"
- "score this MCP server's tool design / schemas / auth / context budget"
- "my MCP server returns too much context" / "my agent picks the wrong tool"
- "harden my MCP server" / "production-readiness check for MCP"
- "which MCP framework should I pick — SDK v1, SDK v2, or
mcp-use?"
Do NOT use this skill for:
- Writing or fixing raw
@modelcontextprotocol/sdkv1 code → out of scope; follow the SDK's own docs - Writing or fixing raw
@modelcontextprotocol/serverv2 alpha code → out of scope; follow the SDK's own docs - Writing or fixing
mcp-use/servercode → route tobuild-mcp-use-server - Live CLI smoke-testing of an MCP server → route to
test-by-mcpc-cli - CLI agent-readiness (not MCP) → route to
audit-agentic-cli - Migrating SDK v1 code to v2 → out of scope; follow the SDK's own migration guide
Hard rules (load-bearing)
| # | Rule | Reference |
|---|---|---|
| 1 | Explore the codebase before asking. Run helper scripts and rg first. | scripts/audit-mcp-server.sh.md |
| 2 | Audit requests stop at the report. Optimize/fix requests apply edits and verify. | — |
| 3 | Every finding cites file path and line, real code or labeled assumption. | — |
| 4 | One server at a time. If multiple servers exist, inventory and ask which is in scope. | — |
| 5 | Map tools to user intent — never wrap REST endpoints one-to-one. | references/patterns/tool-design.md |
| 6 | Flatten schemas past one nesting level; keep 3–6 required params. | references/patterns/schema-design.md |
| 7 | Curate tool responses for LLM consumption — never return raw upstream JSON. | references/patterns/tool-responses.md |
| 8 | Use isError in result content for tool failures. Reserve protocol errors for transport. | references/patterns/error-handling.md |
| 9 | Validate all LLM input server-side; never trust generated input. | references/patterns/security.md |
| 10 | Use Streamable HTTP for new remote deployments — not SSE. | references/patterns/transport-and-ops.md |
| 11 | Use progressive discovery past ~20 tools, not eager registration. | references/patterns/progressive-discovery.md |
| 12 | Tool descriptions are prompt engineering — treat them with care. | references/patterns/tool-descriptions.md |
| 13 | Capability-gate sampling, elicitation, and roots — never silently drop. | references/patterns/advanced-protocol.md |
| 14 | Use OBO with audience checks; never forward user tokens to upstream APIs. | references/patterns/auth-identity.md |
| 15 | Verify after every applied edit. Pick one live route. | references/patterns/testing.md + test-by-mcpc-cli |
Two modes
Mode A — Audit / optimize an existing MCP server
Pick this when MCP-shaped code already exists.
- Explore. Start with the helper scripts:
```bash
bash skills/audit-agentic-mcp/skills/audit-agentic-mcp/scripts/audit-mcp-server.sh .
bash skills/audit-agentic-mcp/skills/audit-agentic-mcp/scripts/measure-context-budget.sh .
```
Then confirm with direct searches:
```bash
tree . -I node_modules --dirsfirst -L 3
rg -n -l "McpServer|FastMCP|server\.tool|@tool|@mcp\.tool|registerTool|Server\(" . -g '!node_modules'
rg -n "server\.tool|@tool|registerTool|def .*tool|tool\(" . -g '!node_modules'
rg -n -l "z\.|inputSchema|BaseModel|Field\(|pydantic|jsonschema" . -g '!node_modules'
rg -n "stdio|streamable|sse|transport" . -g '!node_modules'
```
See scripts/audit-mcp-server.sh.md and scripts/measure-context-budget.sh.md for what the helpers cover and what to read next.
If tree is missing, find . -maxdepth 3 -type d. If rg is missing, grep -R. If no MCP-shaped code exists after checking root and likely server dirs (src/, server/, servers/, app/, apps/, packages/, services/, mcp/), report the missing prerequisite and switch to Mode B only if the user actually wants a new server.
- Detect framework, then route mechanics. Read manifest, entry point, tool registration, schemas, transport/auth config. Keep this skill on audit reasoning; route implementation mechanics to the companion table below.
- Score and prioritize. Produce the audit Output Contract below. Tie every finding to real evidence or a labeled assumption. Thresholds in references are diagnostic cues, not verdicts.
- Apply only in implementation scope. For optimize/fix, edit the in-scope findings and verify with one live route. For audit/review, stop at the report.
Audit Output Contract
- target path and detected framework
- short scorecard across: tool interface, schemas/responses, errors, security/auth, context/cost, client compatibility, ops/testing, and architecture
- prioritized findings — each with severity, evidence path/line, impact, recommended fix, companion-skill route
- verification plan:
test-by-mcpc-cli, MCP Inspector, unit/integration, or targeted manual check - assumptions and items not touched
Mode B — Architect a new MCP server
Pick this when no MCP-shaped code exists yet, or the user wants a fresh server alongside an existing one.
- Run the interview in
references/decision-trees/brainstorming-new-mcp.md. - Choose framework and companion via
references/decision-trees/companion-toolchain.md. - Cross-check the sketch with
references/decision-trees/design-phase.mdfor schema portability and architecture gotchas. - If MCP is the wrong primitive, route to
references/patterns/mcp-vs-cli.mdand recommend CLI, agent skill, or a smaller script instead. - Hand off to the chosen companion only after the architecture sketch is signed off.
Architect Output Contract
- chosen framework and companion skill
- why MCP is better than CLI, agent skill, or a smaller primitive — sourced from
references/patterns/mcp-vs-cli.md - security posture, context-budget posture, and production-readiness risks
- validation plan before and after implementation
Minimal read sets
Do not load the whole reference tree by default. Start with the smallest bundle.
| Work | Read first |
|---|---|
| Existing-server quick audit | scripts/audit-mcp-server.sh.md, scripts/measure-context-budget.sh.md, references/patterns/tool-design.md, references/patterns/schema-design.md, references/patterns/tool-responses.md, references/patterns/error-handling.md, references/patterns/testing.md |
| Security / auth audit | references/decision-trees/security-posture.md, references/patterns/security.md, references/patterns/auth-identity.md, references/patterns/threat-catalog.md |
| Context / cost audit | scripts/measure-context-budget.sh.md, references/patterns/context-engineering.md, references/patterns/caching-economics.md, references/decision-trees/tool-count.md, references/patterns/progressive-discovery.md |
| New-server architecture | references/decision-trees/brainstorming-new-mcp.md, references/decision-trees/companion-toolchain.md, references/decision-trees/design-phase.md, references/patterns/mcp-vs-cli.md |
Companion skills (route fixes here)
| Skill | When to pick | Tradeoff |
|---|---|---|