Tools and MCP
MCP Server Development and Integration
Exam objective: Building, deploying, and integrating an MCP server into Claude applications and workflows, including its resources, tools, and prompts, the choice of transport (stdio or HTTP), and authentication.
What the exam tests
Building, deploying and integrating MCP servers: choosing among tools, resources and prompts, choosing stdio or Streamable HTTP, securing the connection, and wiring a server into the Messages API, Claude Code or the Agent SDK. Expect scenarios where one constraint (local files, many remote users, a secret, a missing permission) decides the design.
Key rules
Architecture. A host manages several clients; each client holds one stateful session with one server. Capabilities are declared at initialization, and a server must declare tools, resources or prompts to offer them.
Primitives, by who controls them.
- Tools: model-controlled actions (
tools/list,tools/call). - Resources: application-controlled context identified by URI (
resources/read, templates, optional subscriptions). - Prompts: user-controlled templates, often slash commands (
prompts/get).
Tool errors. Unknown tools and malformed requests are JSON-RPC protocol errors. API, validation and business failures return a result with isError: true and text the model can act on. With an outputSchema, return conforming structuredContent, plus the same JSON as text for backwards compatibility.
Transports.
- stdio: the client launches the server as a subprocess; messages are newline-delimited on stdin/stdout; logs go to stderr.
- Streamable HTTP: an independent server with one endpoint for POST and GET, optionally streaming with SSE. It replaces the older HTTP+SSE transport. If the server issues
MCP-Session-Id, the client sends it on every later request; a 404 means start a new session. - Security: validate
Origin, bind local servers to 127.0.0.1, authenticate.
Authorization (HTTP). Optional, but HTTP servers should follow the spec; stdio servers take credentials from the environment. The MCP server is an OAuth 2.1 resource server. It publishes Protected Resource Metadata naming its authorization server. Clients use PKCE and the resource parameter and send Authorization: Bearer on every request, never in the query string. Servers accept only tokens issued for them and never pass them upstream. 401 means missing or invalid token; 403 insufficient_scope means step up.
Messages API connector (beta). Remote HTTPS servers only, tool calls only. Each entry in mcp_servers needs exactly one mcp_toolset. You obtain and refresh OAuth tokens and pass authorization_token. It is not covered by zero data retention.
{
"mcp_servers": [{"type": "url", "url": "https://mcp.example.com/mcp", "name": "docs"}],
"tools": [{"type": "mcp_toolset", "mcp_server_name": "docs",
"default_config": {"enabled": false},
"configs": {"search": {"enabled": true}}}]
}
Claude Code. Scopes: local (default, this project, private), project (.mcp.json, shared through version control), user (all your projects). Precedence is local, then project, then user, with no field merging. .mcp.json expands ${VAR} and ${VAR:-default}. Use headersHelper for generated credentials and /mcp or claude mcp login for OAuth. Resources are referenced with @, prompts run as slash commands, and tool search defers tool definitions by default.
Agent SDK. Configure mcpServers; tools are named mcp__<server>__<tool> and need permission, typically through allowedTools. Check the init message for failed or needs-auth. The SDK does not run an interactive OAuth flow: pass a token in headers, or sign in beforehand from Claude Code.
Traps
- Printing debug output to stdout in a stdio server corrupts the protocol.
- Pointing the API connector at a local process, or expecting it to deliver prompts or resources.
- A denylist leaves newly added server tools enabled; use
default_config.enabled: falsefor a strict allowlist. acceptEditsdoes not auto-approve MCP tools;bypassPermissionsis far too broad.- Forwarding the client's token to a downstream API, even after validating it.
- A
.mcp.jsonentry with aurland notypeis read as stdio and skipped. - Treating
pendingin the SDK init message as a failure.
Decide quickly
| Situation | Choice | Why |
|---|---|---|
| Server needs local files, one user | stdio | Runs as a subprocess on that machine |
| One deployment, many remote clients | Streamable HTTP with auth | Independent multi-client server |
| User starts a reusable workflow | Prompt | User-controlled |
| App chooses what data to attach | Resource | Application-controlled |
| Model should act or query | Tool | Model-controlled |
| Messages API, remote server, tools only | MCP connector | No client to build |
| Local server, prompts or resources with the API | Own MCP client plus SDK helpers | Connector cannot do it |
| Team-wide server in Claude Code | Project scope with ${VAR} secrets | Shared definition, private keys |
| SDK agent sees tools but cannot run them | Add allowedTools rule | Permission is separate from connection |
Sources
- MCP specification: Architecture
- MCP specification: Transports
- MCP specification: Authorization
- MCP specification: Server features
- MCP specification: Tools
- MCP specification: Resources
- MCP specification: Prompts
- Claude API: MCP connector
- Claude Code: Connect to tools via MCP
- Agent SDK: Connect to external tools with MCP