agentleFS
mmccallammccalla/coding-agent-skill-library/skills/mcp-server-design/SKILL.md

mcp-server-design

Skill4 starsChanged 5 months agoApache-2.0View on GitHub

Use when designing, implementing, reviewing or securing Model Context Protocol servers/clients, including tools, resources, prompts, FastMCP servers and agent-friendly API wrappers.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 9 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when external capabilities should be exposed to agents through a reusable, discoverable interface rather than hard-coded …

    line 13
  2. Distinctive:

    Prefer filtered, sorted and scoped operations over bulk unstructured retrieval.

    line 24
  3. Distinctive:

    Use least privilege for every server and tool.

    line 27
  4. Distinctive:

    When reviewing an MCP server, check capability discovery, schema clarity, transport-specific logging, least-privilege authentication, and …

    line 33
  5. Distinctive:

    Add authentication, authorisation and allow-listing.

    line 42
  6. Distinctive:

    Add client integration tests for discovery and execution.

    line 44
  7. Distinctive:

    Do not wrap an API unchanged if it returns data the agent cannot understand.

    line 49
  8. Distinctive:

    Do not expose broad filesystem, shell, database or network access by default.

    line 50
  9. Distinctive:

    Prefer local servers for sensitive data and remote servers for shared scalable tools only when access control is mature.

    line 53
  10. Very specific:

    Use skills_docs/security/OWASP_ASI_CROSSWALK.md for the shared risk map.

    line 57

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

MCP Server Design

When to use

Use this skill when external capabilities should be exposed to agents through a reusable, discoverable interface rather than hard-coded function calls. MCP is suitable for complex, evolving or enterprise tool ecosystems.

For a small fixed set of functions in one app, direct tool/function calling may be simpler.

Objective

Expose external capabilities through narrow, typed, discoverable, least-privilege MCP interfaces.

Design principles

  • Expose agent-friendly capabilities, not raw legacy APIs.
  • Prefer filtered, sorted and scoped operations over bulk unstructured retrieval.
  • Return text, JSON or structured data that the consuming agent can parse.
  • Separate resources, tools and prompts clearly.
  • Use least privilege for every server and tool.

MCP source-aligned guidance

The MCP server guide distinguishes resources, tools and prompts as the three main server capability types. For stdio transports, never write logs or diagnostics to stdout because stdout carries JSON-RPC messages; send logs to stderr or files instead. Tool inputs should use explicit schemas such as JSON Schema or SDK schema helpers, with clear descriptions and examples so clients can discover and call tools safely.

When reviewing an MCP server, check capability discovery, schema clarity, transport-specific logging, least-privilege authentication, and whether the exposed operation is agent-friendly rather than a raw legacy API wrapper.

Source: Model Context Protocol — Build a server.

Procedure

  1. Identify the external system capability to expose.
  2. Decide whether it is a resource, tool or prompt.
  3. Design an agent-friendly schema with clear descriptions and examples.
  4. Add authentication, authorisation and allow-listing.
  5. Implement the MCP server with explicit errors and typed returns.
  6. Add client integration tests for discovery and execution.
  7. Threat-model prompt injection, data exfiltration and destructive actions.

Guardrails

  • Do not wrap an API unchanged if it returns data the agent cannot understand.
  • Do not expose broad filesystem, shell, database or network access by default.
  • Redact secrets and sensitive data from observations.
  • Require confirmation for destructive operations.
  • Prefer local servers for sensitive data and remote servers for shared scalable tools only when access control is mature.

OWASP ASI mapping

Use skills_docs/security/OWASP_ASI_CROSSWALK.md for the shared risk map.

ASI riskMCP control
ASI02 Tool MisuseExpose narrow tools with strict schemas, typed errors and documented side effects.
ASI03 Identity and Privilege AbuseEnforce authentication, authorisation, tenant scoping and least-privilege credentials at the server.
ASI04 Agentic Supply Chain VulnerabilitiesPin and review MCP servers, tools, prompts and dynamic discovery sources.
ASI07 Insecure Inter-Agent CommunicationAuthenticate clients, restrict discovery and version tool/resource contracts.

Related skills

  • tool-use-and-function-calling — direct tool calling when MCP is unnecessary
  • guardrails-safety-patterns — auth, validation and least privilege
  • knowledge-retrieval-rag — document grounding alongside tools

References

Verification

  • Tool/resource/prompt boundaries are clear.
  • Schemas are typed and agent-readable.
  • Discovery works from an MCP client.
  • Authentication and authorisation are enforced.
  • Error responses are structured.
  • Security tests cover injection and unauthorised access.

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.