agentleFS
yigitkonuryigitkonur/skills-by-yigitkonur/skills/audit-agentic-mcp/SKILL.md

audit-agentic-mcp

Skill13 starsChanged 13 days agoMITView on GitHub

Use if auditing or designing an MCP server for agent-readiness — framework, security, context.

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Explore: Start with the helper scripts:

    line 60
  2. Distinctive:

    Detect framework, then route mechanics: Read manifest, entry point, tool registration, schemas, transport/auth config.

    line 77
  3. Very specific:

    Run the interview in references/decision-trees/brainstorming-new-mcp.md.

    line 95
  4. Very specific:

    If MCP is the wrong primitive, route to references/patterns/mcp-vs-cli.md and recommend CLI, agent skill, or a smaller script instead.

    line 98
  5. Distinctive:

    Do not load the whole reference tree by default.

    line 110
  6. Distinctive:

    Ask only when the target server is ambiguous, multiple servers are in scope and the user did not request a repo-wide audit, or the next …

    line 133
  7. Very specific:

    After every applied optimization, pick one live verification route: test-by-mcpc-cli, MCP Inspector, unit/integration test, or targeted …

    line 134
  8. Very specific:

    Before making version-sensitive claims, verify current MCP SDK, mcp-use, client compatibility, pricing, CVEs, and registry status from …

    line 279

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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/sdk v1 code → out of scope; follow the SDK's own docs
  • Writing or fixing raw @modelcontextprotocol/server v2 alpha code → out of scope; follow the SDK's own docs
  • Writing or fixing mcp-use/server code → route to build-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)

#RuleReference
1Explore the codebase before asking. Run helper scripts and rg first.scripts/audit-mcp-server.sh.md
2Audit requests stop at the report. Optimize/fix requests apply edits and verify.—
3Every finding cites file path and line, real code or labeled assumption.—
4One server at a time. If multiple servers exist, inventory and ask which is in scope.—
5Map tools to user intent — never wrap REST endpoints one-to-one.references/patterns/tool-design.md
6Flatten schemas past one nesting level; keep 3–6 required params.references/patterns/schema-design.md
7Curate tool responses for LLM consumption — never return raw upstream JSON.references/patterns/tool-responses.md
8Use isError in result content for tool failures. Reserve protocol errors for transport.references/patterns/error-handling.md
9Validate all LLM input server-side; never trust generated input.references/patterns/security.md
10Use Streamable HTTP for new remote deployments — not SSE.references/patterns/transport-and-ops.md
11Use progressive discovery past ~20 tools, not eager registration.references/patterns/progressive-discovery.md
12Tool descriptions are prompt engineering — treat them with care.references/patterns/tool-descriptions.md
13Capability-gate sampling, elicitation, and roots — never silently drop.references/patterns/advanced-protocol.md
14Use OBO with audience checks; never forward user tokens to upstream APIs.references/patterns/auth-identity.md
15Verify 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.

  1. Explore. Start with the helper scripts:

    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:

    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.

  2. 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.
  3. 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.
  4. 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.

  1. Run the interview in references/decision-trees/brainstorming-new-mcp.md.
  2. Choose framework and companion via references/decision-trees/companion-toolchain.md.
  3. Cross-check the sketch with references/decision-trees/design-phase.md for schema portability and architecture gotchas.
  4. If MCP is the wrong primitive, route to references/patterns/mcp-vs-cli.md and recommend CLI, agent skill, or a smaller script instead.
  5. 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.

WorkRead first
Existing-server quick auditscripts/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 auditreferences/decision-trees/security-posture.md, references/patterns/security.md, references/patterns/auth-identity.md, references/patterns/threat-catalog.md
Context / cost auditscripts/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 architecturereferences/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)

SkillWhen to pickTradeoff
build-mcp-use-serverNew HTTP-first TypeScript server wanting mcp-use/server conventions, widgets/apps, OAuth helpersLocks into mcp-use/server imports; less bare-metal control
test-by-mcpc-cliRepeatable stdio/Streamable HTTP smoke checks, JSON scripting, post-edit verificationRequires mcpc 0.2.x locally
audit-agentic-cliThe interface should stay CLI-first or the task is CLI agent-readiness, not MCPCLI contract work, not MCP protocol work

Raw official-SDK work (@modelcontextprotocol/sdk v1, @modelcontextprotocol/server v2 alpha) and v1 → v2 migration have no companion skill in this pack. Use the SDK's own docs: v1 is the production default with the widest client compatibility; v2 is for greenfield projects that accept alpha risk after checking npm and the docs (Node 20+, ESM, Zod v4, no server-side OAuth).

Execution rhythm

  • Audit/review request → produce the full audit report and stop. No code edits.
  • Optimize/fix request with clear scope → state assumptions and tradeoffs upfront, apply in-scope edits, verify.
  • Ask only when the target server is ambiguous, multiple servers are in scope and the user did not request a repo-wide audit, or the next action is destructive or externally visible.
  • After every applied optimization, pick one live verification route: test-by-mcpc-cli, MCP Inspector, unit/integration test, or targeted manual endpoint check.

Decision tree — what aspect needs attention?

What aspect of the MCP server is in scope?
│
├── Brand new server, no code yet
│   ├── references/decision-trees/brainstorming-new-mcp.md
│   └── references/decision-trees/companion-toolchain.md
│
├── Architecture decision — should this even be an MCP server?
│   └── references/patterns/mcp-vs-cli.md
│
├── Tool interface quality
│   ├── REST-wrapper tools ───────────── references/patterns/tool-design.md
│   ├── Wrong tool selected ──────────── references/patterns/tool-descriptions.md
│   └── Weak next-action guidance ────── references/patterns/tool-responses.md
│
├── Input / output reliability
│   ├── Schema parse failures ────────── references/patterns/schema-design.md
│   ├── Poor recovery errors ─────────── references/patterns/error-handling.md
│   ├── Response format choice ───────── references/decision-trees/response-format.md
│   └── Error strategy choice ────────── references/decision-trees/error-strategy.md
│
├── Security and identity
│   ├── Security posture flow ────────── references/decision-trees/security-posture.md
│   ├── Generic defenses ─────────────── references/patterns/security.md
│   ├── OAuth / CIMD / OBO ───────────── references/patterns/auth-identity.md
│   └── Named attacks / CVEs ─────────── references/patterns/threat-catalog.md
│
├── Context, tokens, and cost
│   ├── Context budget ───────────────── references/patterns/context-engineering.md
│   ├── Prompt-caching economics ─────── references/patterns/caching-economics.md
│   ├── Tool count cliffs ────────────── references/decision-trees/tool-count.md
│   └── Progressive loading ──────────── references/patterns/progressive-discovery.md
│
├── Protocol depth
│   ├── Sampling / elicitation / roots ─ references/patterns/advanced-protocol.md
│   ├── Resources + prompts ──────────── references/patterns/resources-and-prompts.md
│   └── Tool response authority ──────── references/patterns/prompt-gates.md
│
├── Client + model compatibility
│   ├── Per-client quirks ────────────── references/patterns/client-compatibility.md
│   └── Per-model behavior ───────────── references/patterns/model-behavior.md
│
├── Architecture & scaling
│   ├── Agentic workflows ────────────── references/patterns/agentic-patterns.md
│   ├── Multi-server composition ─────── references/patterns/composition.md
│   ├── Growth / load distribution ───── references/decision-trees/scaling.md
│   └── Early design decisions ───────── references/decision-trees/design-phase.md
│
├── Operations, testing, deployment
│   ├── Transport + ops ──────────────── references/patterns/transport-and-ops.md
│   ├── Hosting platforms ────────────── references/patterns/deployment-platforms.md
│   ├── Session lifecycle ────────────── references/patterns/session-and-state.md
│   ├── Testing strategy ─────────────── references/patterns/testing.md
│   └── Production readiness ─────────── references/decision-trees/production-readiness.md
│
└── Distribution and trust
    ├── Vendor exemplars ─────────────── references/patterns/exemplar-servers.md
    └── Registries / gateways ───────── references/patterns/registry-and-distribution.md

Quick reference card

You want to...Start here
Architect a brand-new MCPreferences/decision-trees/brainstorming-new-mcp.md → references/decision-trees/companion-toolchain.md
Decide MCP vs CLI vs agent skillreferences/patterns/mcp-vs-cli.md
Evaluate tool interface qualityreferences/patterns/tool-design.md → references/patterns/tool-descriptions.md
Fix schema parse failuresreferences/patterns/schema-design.md → references/decision-trees/design-phase.md
Improve error recoveryreferences/decision-trees/error-strategy.md → references/patterns/error-handling.md
Harden security posturereferences/decision-trees/security-posture.md → references/patterns/security.md → references/patterns/auth-identity.md
Reduce context / token usagescripts/measure-context-budget.sh.md → references/patterns/context-engineering.md
Manage 20+ toolsreferences/decision-trees/tool-count.md → references/patterns/progressive-discovery.md
Add sampling, elicitation, or rootsreferences/patterns/advanced-protocol.md
Pick deployment platformreferences/patterns/deployment-platforms.md
Design for a specific clientreferences/patterns/client-compatibility.md
Publish to a registryreferences/patterns/registry-and-distribution.md
Validate with live testsreferences/patterns/testing.md → test-by-mcpc-cli

Common pitfalls

#PitfallFix
1Wrapping every REST endpoint as a toolDesign around user intent — references/patterns/tool-design.md
2Deeply nested JSON schemasFlatten to one level, 3–6 params — references/patterns/schema-design.md
3Returning raw API JSONCurate and summarize — references/patterns/tool-responses.md
4Throwing protocol errors for tool failuresUse isError in result content — references/patterns/error-handling.md
5No input validationValidate server-side — references/patterns/security.md
6Registering 20+ tools eagerlyProgressive discovery — references/patterns/progressive-discovery.md
7Vague tool descriptionsTreat descriptions as prompt engineering — references/patterns/tool-descriptions.md
8No live verification after editsUse test-by-mcpc-cli, Inspector, unit tests, or endpoint checks
9Using SSE for new remote deploymentsStreamable HTTP only — references/patterns/transport-and-ops.md
10Ignoring session cleanupLifecycle management — references/patterns/session-and-state.md

Reference routing table

Pattern files (references/patterns/)

FileRead when...
tool-design.mdEvaluating tool granularity, intent-based design, naming
tool-descriptions.mdDiagnosing tool selection, improving description quality
tool-responses.mdOptimizing return shape, picking output format, reducing tokens
schema-design.mdFixing parse failures, flattening schemas, trimming required params
error-handling.mdImproving recovery, retry loops, circuit breakers
security.mdGeneric defenses: injection vectors, sandboxing, auth basics
threat-catalog.mdNamed MCP attacks, dated CVEs, defense tooling, audit checklist
auth-identity.mdOAuth profile, RFC 9728 PRM, CIMD, OBO, step-up consent
context-engineering.mdToken-budget diagnosis, context window optimization, tiered verbosity
caching-economics.mdProvider-side prompt caching, write premiums, TTL, cost math
progressive-discovery.mdManaging 20+ tools, dynamic tool loading
agentic-patterns.mdAgent loops, multi-step workflows, ordering constraints
composition.mdMulti-server setups, gateway federation, meta-server patterns
prompt-gates.mdTool response authority, approval workflows, guardrails
resources-and-prompts.mdResource and prompt primitive usage, data-exposure strategy
session-and-state.mdSession lifecycle, state leaks, cleanup, application-level caching
testing.mdEval-driven development, regression testing, CI integration
transport-and-ops.mdTransport choice, deployment config, monitoring, connection management
deployment-platforms.mdHosting platforms and deployment constraints
mcp-vs-cli.mdDeciding whether MCP is the right primitive vs CLI, bash, skills, or hybrid
client-compatibility.mdPer-client truth table, silent drops, partial support, workarounds
model-behavior.mdPer-model tool-use benchmarks, idioms, pricing
advanced-protocol.mdSampling, elicitation, roots, completions, progress, cancellation, _meta
exemplar-servers.mdComparing design against production vendor servers
registry-and-distribution.mdOfficial Registry, Smithery, Docker MCP Catalog, gateways, trust signals

Decision-tree files (references/decision-trees/)

FileRead when...
brainstorming-new-mcp.mdMode B interview, framework picker, architecture sketch
companion-toolchain.mdChoosing build, test, architecture, CLI, or no-MCP companion route
design-phase.mdEarly architecture decisions, cross-model schema portability
tool-count.mdHow many tools to expose; organizing a large surface
response-format.mdText vs structured content vs mixed
error-strategy.mdFail-fast vs retry vs fallback
security-posture.mdThreat model selection, full security audit flow
scaling.mdGrowth, multi-server setups, load distribution
production-readiness.mdPre-deploy checklist, operational readiness

Freshness checks

Before making version-sensitive claims, verify current MCP SDK, mcp-use, client compatibility, pricing, CVEs, and registry status from primary sources. Start with npm package metadata and the official TypeScript SDK repository/release notes when framework guidance depends on SDK state.

Time-sensitive references — re-check before citing:

  • references/patterns/auth-identity.md
  • references/patterns/client-compatibility.md
  • references/patterns/caching-economics.md
  • references/patterns/deployment-platforms.md
  • references/patterns/model-behavior.md
  • references/patterns/registry-and-distribution.md
  • references/patterns/threat-catalog.md

Delegation policy

Use subagents only when the runtime supports them and project policy allows it. Delegate independent current-research questions, broad codebase scans, or batch implementation after the user has authorized implementation scope. Pass outcome, constraints, and binary done criteria. Do not delegate work that is faster as a local read-plus-edit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.