Overview
An MCP server exposes tools, resources, and prompts that any compatible client (Claude Code, Claude Desktop, IDE plugins) can call. Ship one when an agent will use the integration across sessions or across clients; use a plain function call or a CLI when the need is a single prompt. For a build walkthrough see build-an-mcp-server.
Ship a server for integrations the agent revisits
Good candidates: GitHub, a ticket system, an internal search index, a deployment console. Poor candidates: one curl to a public API, a script that runs once. The rule of thumb is reuse: if you would paste the same tool schema into a third prompt, write the server.
Check for an existing maintained server first. GitHub maintains github/github-mcp-server; the reference servers in modelcontextprotocol/servers include Filesystem, Fetch, Git, Memory, and Time, while others (GitHub, PostgreSQL) moved to servers-archived and receive no fixes.
Scope one server per domain and auth boundary
Group related tools under one server: a github server with list_issues, create_pull_request, and read_file, not three single-tool servers. A server is one credential set, one rate-limit budget, and one set of shared types such as an Issue schema. Splitting per tool multiplies auth setup and breaks shared types. Merge tools around a workflow rather than a raw endpoint; see mcp-tool-design.
Keep handlers stateless
Since the 2026-07-28 revision any request can reach any server instance, and there is no connection-scoped session. Return an explicit handle from a creation tool (for example create_basket returning basket_id) and take it as an argument afterward. Validate the caller’s authorization against the handle on every call, make handles opaque, and state the retention policy in the creation tool’s description. Expired handles should return a tool error the model can recover from.
Pick the right page for each concern
- Tool names, schemas, errors, and output: mcp-tool-design.
- Read-only data and subscriptions: mcp-resources.
- stdio versus Streamable HTTP, headers, deployment: mcp-transports.
- Auth, redaction, rate limits, path allowlists: mcp-security.
- Asking the user for input mid-call: mcp-elicitation.
- Structured logs and the Inspector: mcp-logging.