What you will be able to do
- Choose between a direct tool or CLI call, an MCP server and a hand-off to another agent for reaching a given system
- Explain what MCP standardises, including its three primitives and its stdio and Streamable HTTP transports
- Attach an MCP server in Claude Code, in the Agent SDK and through the Messages API MCP connector, and know the limits of each
- Choose the Claude surface (Claude Code CLI, Agent SDK, Client SDK, Managed Agents) that fits a given workflow
- Recognise when agent-to-agent delegation fits better than a tool or MCP server, and what a delegated agent receives and returns
Key concept
MCP server as a shared integration point — An MCP server exposes tools, resources and prompts through one protocol, so the same server can be plugged into any MCP client (Claude Code, the Agent SDK, the Messages API connector) without rewriting the integration for each. Choosing an integration mechanism mostly comes down to whether that reuse is worth running a separate server for.
1.Three ways to connect Claude to a system
Each time Claude needs to reach an outside system, such as a database, an issue tracker or a build server, the architect picks one of three mechanisms: a tool your application defines and runs, an MCP server, or another agent that owns that system. All three can get the job done. They differ in who maintains the integration, how many clients can reuse it, and how much judgement sits on the other side.
Direct tool use is the shortest path. Your application defines a tool with an input_schema, Claude returns a tool_use block, your code runs the operation and returns a tool_result. Where that code runs is covered in Who executes tools: client tools versus server tools. As an integration choice, it wins when one application owns one system and you control the schema. A CLI belongs here too: Anthropic publishes a bash tool schema, but your application still runs each command. The cost is that this integration lives inside your application. A second client, say a developer's Claude Code session, cannot reuse it.
An MCP server moves the integration out of your application and puts it behind a protocol. One server can then serve any MCP client, and one client can combine several servers. Each server sees only what it needs, because the full conversation stays with the host. MCP wins when the same capability has to be reachable from more than one surface, or when the vendor of the system already ships an MCP server you can attach rather than build.
Agent-to-agent hand-off is the right choice when the system needs its own judgement, not just a function call: a security review, a test-writing pass, a domain specialist with its own system prompt and toolset. The calling agent delegates the task and reads back what the specialist reports, instead of driving each step itself. How subagents, agent teams and workflows differ is taught in Subagents vs agent teams vs workflows across Managed Agents, Agent SDK and Claude Code.
In Managed Agents the specialist is either a predefined agent listed in the multiagent block of the lead's definition, or an inline agent that the lead defines when it delegates. Each subagent works in its own session thread, so its working context stays out of the lead's. Delegation is one level deep: a specialist cannot hand work on to further agents. Pick this over a tool or an MCP server when the system must reason about the task, and expect the lead to receive a report rather than a raw result.
| Mechanism | Who maintains the integration | Wins when |
|---|---|---|
| Direct tool (your input_schema, your code) | Your application, which runs each call and returns tool_result | One application owns the system and you control the schema |
| MCP server | A separate server any MCP client can attach | The same capability must be reachable from several clients, or a vendor server exists |
| Another agent | An agent with its own model, system prompt, tools, MCP servers and skills | The system needs its own reasoning and toolset, not a single call |
Checkpoint 1 of 9· Match them up
An architect is connecting Claude to three outside systems. Match each situation to the integration mechanism that fits it best.
Tap a term, then the definition that fits it.
A direct tool lives inside your application, which writes the schema and runs each call. That makes it the shortest path when one app owns the system, but no other client can reuse it. An MCP server sits behind a shared protocol, so several clients can attach the same server. That includes an existing vendor server. A separate agent fits when the work needs its own judgement and specialised setup, not just a function call.
“For tools you define, you write the schema and your application executes each call.”Source: platform.claude.com
2.What MCP standardises: primitives and transports
MCP standardises three kinds of things a server can expose, and each one is controlled by a different party. That split matters when you compare MCP with a plain tool definition, because a tool definition only covers the first row of the table below. Resources and prompts give a client context and templates that it, or the user, chooses to bring in.
| Primitive | Control | Example |
|---|---|---|
| Tools | Model-controlled | API POST requests, file writing |
| Resources | Application-controlled | File contents, git history |
| Prompts | User-controlled | Slash commands, menu options |
Servers and clients also negotiate capabilities. A server has to declare tool support before tools can be invoked, and a client has to declare sampling support before a server can request it. This lets each side add features at its own pace. The protocol can also run in the other direction: in Claude Code, an MCP server can act as a channel that pushes Telegram messages, Discord chats or webhook events into a session. A tool that Claude calls directly can only answer when Claude asks.
Two transports carry the protocol, and the choice between them decides which clients can reach a server. With stdio, the client launches the server as a subprocess and exchanges newline-delimited JSON-RPC messages over stdin and stdout. The server may log to stderr but must write nothing to stdout except valid MCP messages. Stdio is the transport behind the server that runs on a developer's laptop. With Streamable HTTP, the server is a remote endpoint. The client POSTs each JSON-RPC message to that endpoint, and the server answers with either one JSON object or an SSE stream. The client may also open a GET stream so the server can send messages without being asked.
A remote server takes on duties a subprocess never has. It must validate the Origin header on every incoming connection to block DNS rebinding. When it runs locally it should bind to 127.0.0.1 rather than 0.0.0.0, and it should authenticate every connection. Turning a stdio server into a production HTTP service is therefore deployment work, not a configuration toggle.
Checkpoint 2 of 9· Check yourself
A team's MCP server runs over stdio on a developer's laptop. They now want a hosted production service to reach the same server over the network. What does this change involve?
With stdio, the client launches the server as its own local subprocess, so a remote client cannot reach it. Running it as a remote Streamable HTTP endpoint adds duties a subprocess never has, such as validating the Origin header and authenticating connections. That makes the change deployment work, not a configuration toggle.
“Servers MUST validate the Origin header on all incoming connections to prevent DNS rebinding attacks”Source: modelcontextprotocol.io
3.Attaching an MCP server in Claude Code
Claude Code is a full MCP client, so it can attach a server over any transport. The --transport flag names the transport. What you were given tells you which one: a URL such as https://mcp.example.com/mcp means the server is remote, and a launch command such as npx -y @example/mcp-server means it runs on your machine.
# Basic syntax
claude mcp add --transport http <name> <url>
# Real example: Connect to Notion
claude mcp add --transport http notion https://mcp.notion.com/mcp
# Example with Bearer token
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token"# Basic syntax
claude mcp add [options] <name> -- <command> [args...]
# Real example: Add Airtable server
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \
-- npx -y airtable-mcp-serverConfiguration copied from another client usually arrives as an mcpServers JSON block, and you can pass it to claude mcp add-json. One mistake comes up often: Claude Code reads an entry that has no type as a stdio server. An entry with a url but no "type": "http", "sse" or "ws" therefore fails. When you stop the session, Claude Code also stops each stdio server it launched. On macOS and Linux it sends SIGINT, then SIGTERM, then SIGKILL.
Use claude mcp list, claude mcp get <name> and /mcp to see whether a server is connected, pending approval or disabled. A project-scoped server from .mcp.json stays pending until someone runs claude interactively and approves it. Headless runs (claude -p) are stricter still: only servers passed on the command line, for example with --mcp-config, connect.
Checkpoint 3 of 9· Fill the gap
This command attaches an Airtable MCP server, and Claude Code starts it on your own machine with npx. Which transport value belongs in the blank?
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport ? airtable \
-- npx -y airtable-mcp-serverYou were given a launch command after --, not an https:// URL, so the server runs locally and Claude Code launches it as a subprocess over stdio. The http, sse and ws transports are for remote servers that you reach at a URL.
4.Choosing the surface: Claude Code CLI, Agent SDK, Client SDK or Managed Agents
Where you attach an MCP server depends on which surface runs the agent, so pick the surface first. The four options differ in who writes the agent loop and whether a person is watching while it runs.
| Surface | What you get | Fits when |
|---|---|---|
| Claude Code CLI | The terminal interface, built for daily interactive use | A person chats, watches each step and approves risky commands as they come up |
| Agent SDK | A library that runs the Claude Code binary, with built-in tools, permissions, sessions and hooks | Your Python or TypeScript process, such as a CI job, needs the agent loop without hand-written tool handling |
| Client SDK | Direct access to the Claude API; you write the tool loop yourself or use the beta tool runner | You want full control of every request and tool_result |
| Managed Agents | A hosted agent harness that runs the agent loop in an Anthropic-managed or self-hosted sandbox | Anthropic should host the agent, configured through the Claude API |
The Client SDK and the Agent SDK sound alike, but they split the work differently. With the Client SDK your code checks stop_reason, runs each tool_use block and sends the results back, which is exactly the code a pipeline team wants to avoid writing. The Agent SDK already contains that loop, along with Read, Edit and Bash tools and a permission system that decides which tools run automatically and which need approval. For CI, the headless form claude -p "Find and fix the bug in auth.py" --allowedTools "Read,Edit,Bash" pre-approves the tools, so nobody has to answer prompts.
Interactive approval is the deciding case for the CLI. An engineer debugging a failing build, who wants to see every file Claude opens and approve each risky command, needs the terminal session, with no integration code. An SDK script on a schedule has nobody watching. Managed Agents runs the session in a sandbox. The Messages API connector has no terminal at all.
In the Agent SDK, MCP servers go in the mcpServers option of query(). Tools from a server get names of the form mcp__<server>__<tool>, which is what allowedTools matches against.
import { query } from "@anthropic-ai/claude-agent-sdk";
try {
for await (const message of query({
prompt: "Find and run the appropriate database query",
options: {
mcpServers: {
"enterprise-tools": {
// Connect to a remote MCP server
type: "http",
url: "https://tools.example.com/mcp"
}
},
allowedTools: ["mcp__enterprise-tools__*"], // Wildcard pre-approves all tools from this serverCheckpoint 4 of 9· Check yourself
A team built a nightly pipeline on the Client SDK because they expected it to handle tools on its own. Their first request comes back with stop_reason "tool_use" and a tool_use block for one of their own tools. What happens next?
With the Client SDK you get direct API access. Your code runs each tool_use block and sends the tool_result back, or you use the beta tool runner to do that step. The built-in tools and the ready-made loop come with the Agent SDK. Interactive approval belongs to the CLI.
“Claude responds with stop_reason: "tool_use" and one or more tool_use blocks. Your code executes the operation and sends back a tool_result.”Source: platform.claude.com
Checkpoint 5 of 9· Exam question
A platform team is building an automated CI pipeline step where Claude must read repository files, run test commands, and edit code across multiple iterations until tests pass, without the team writing custom logic to parse tool_use blocks and resubmit tool results. Which integration approach best fits this need?
Correct answer: A — Use the Claude Agent SDK, which provides the agent loop, built-in tools like Read, Edit, and Bash, and manages tool execution automatically.
- A. Correct. The Agent SDK ships the agent loop and built-in tools such as Read, Edit, and Bash, so the team gets autonomous multi-step tool execution without writing the loop themselves.
- B. Incorrect. This describes the Client SDK path, which requires the team to implement and maintain the tool execution loop manually.
- C. Incorrect. Interactive CLI use requires a human present to approve steps, which defeats the goal of an unattended automated pipeline step.
- D. Incorrect. MCP exposes external tools to Claude but does not provide the local Read/Edit/Bash agent loop needed to operate directly on the pipeline's own repository checkout.
Checkpoint 6 of 9· Exam question
An engineer wants to interactively debug a failing build by chatting with Claude in a terminal, watching each file it opens and approving risky commands ad hoc, without writing any integration code. Which option best matches this workflow?
Correct answer: A — The Claude Code CLI, run interactively in a terminal to watch and approve each step live.
- A. Correct. The CLI is designed for interactive, terminal-based development where the engineer watches Claude's actions and approves steps in real time.
- B. Incorrect. A headless scheduled script is meant for unattended automation, not live, ad hoc interactive debugging.
- C. Incorrect. Managed Agents runs sessions on a remote hosted sandbox via a REST API, which is built for production automation, not a local interactive terminal session.
- D. Incorrect. The MCP connector governs which remote tools Claude may call from the Messages API; it does not provide an interactive terminal experience.
5.The Messages API MCP connector: remote servers only
The MCP connector lets a Messages API request use a remote MCP server directly, without a separate MCP client. Anthropic's side makes the connection. That is also why its limits are strict. The server must be publicly reachable over HTTP, using Streamable HTTP or SSE, and its url must start with https://. The API has no process to launch a stdio server from, so the laptop server above has to be deployed before production can use it. Only tool calls are supported, so the server's resources and prompts are not available through this path.
A request names the server and enables its tools in two separate places. The mcp_servers array holds connection details: type (currently only "url"), url, name and an optional OAuth authorization_token. The tools array holds an mcp_toolset that refers to that server by name. Each server name must be referenced by exactly one toolset. The toolset is also where you enable every tool, allowlist some or denylist others. One request can attach several servers. The connector sits behind a beta flag.
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-opus-5-5",
max_tokens=1000,
messages=[{"role": "user", "content": "What tools do you have available?"}],
mcp_servers=[
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN",
}
],
tools=[{"type": "mcp_toolset", "mcp_server_name": "example-mcp"}],
betas=["mcp-client-2025-11-20"],
)Rewriting the server's functions as client tools also connects the system, but it changes who does the work. Your backend would run every call and return each tool_result itself, so the query logic moves into the application and stops being a server other clients can share. Use the connector when the server can be exposed remotely and you want the API to handle the MCP round trip. Use client tools when the system must stay private to your backend.
| Surface | How you attach | Transports |
|---|---|---|
| Claude Code | claude mcp add, add-json, or --mcp-config for claude -p | stdio, http, sse, ws |
| Agent SDK | mcpServers option of query() | Local and remote, such as type: "http" |
| Messages API | mcp_servers plus an mcp_toolset in tools | Streamable HTTP or SSE over https:// only; tool calls only |
Checkpoint 7 of 9· Fill the gap
In this Messages API request, mcp_servers only holds the connection details. Which type value in the tools array turns on the server's tools for Claude?
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-opus-5-5",
max_tokens=1000,
messages=[{"role": "user", "content": "What tools do you have available?"}],
mcp_servers=[
{
"type": "url",
"url": "https://example-server.modelcontextprotocol.io/sse",
"name": "example-mcp",
"authorization_token": "YOUR_TOKEN",
}
],
tools=[{"type": " ? ", "mcp_server_name": "example-mcp"}],
betas=["mcp-client-2025-11-20"],
)The connector splits the setup into two parts. mcp_servers holds the server's URL, name and token. An mcp_toolset entry in tools refers to that server by name and enables its tools. "url" is the server definition's own type, not a tool type. Listing a server in mcp_servers without a matching toolset does not make its tools available.
Checkpoint 8 of 9· Exam question
A fintech company wants Claude to call tools hosted on an internal Postgres query service. The service currently only exposes a local stdio-based MCP server used by developers on their laptops, but the production app needs Claude to invoke it directly from server-side Messages API calls without operating a separate MCP client process. What should the team do?
Correct answer: A — Deploy the query service as a remote MCP server reachable over HTTPS via Streamable HTTP or SSE, then reference it in the mcp_servers array.
- A. Correct. The MCP connector only supports remote servers exposed over HTTPS using Streamable HTTP or SSE transport, so moving the service to a publicly reachable endpoint and referencing it in mcp_servers is the supported path.
- B. Incorrect. The MCP connector cannot spawn local stdio servers; the server must already be publicly exposed over HTTP-based transports.
- C. Incorrect. This abandons MCP entirely and requires the team to hand-build and maintain a tool_use schema instead of reusing the existing MCP interface.
- D. Incorrect. The Files API manages document and data uploads, not MCP tool schemas or server connectivity.
Sources9
6.When the system is better reached as another agent
Some systems need a whole agent rather than a tool. A tool or an MCP server gives Claude one function at a time, and the calling agent still does all the reasoning. A predefined agent brings its own model, system prompt, tools, MCP servers and skills. Handing work to it means handing over the judgement, together with the integrations that judgement needs.
Here is a concrete case. A lead agent needs code review and test writing. Attaching every review tool and test runner to the lead fills its context and blurs its instructions. Routing the work to a reviewer agent and a test-writer agent, each with a focused prompt and its own tools, keeps each concern self-contained. The same reasoning applies when the system is an MCP server that only a specialist needs: attach it to the specialist agent, not to the agent that coordinates the work.
Two properties of this option affect its design. Agents in a Managed Agents session share the same sandbox, filesystem and vault credentials, so a hand-off does not isolate permissions. It isolates context, because each agent runs in its own session thread with its own history. A subagent's thread also persists, so the lead can send follow-ups to a specialist that keeps its earlier work. Choose an agent over an MCP server when the conversation with the system may take several turns, not one request and one result.
Checkpoint 9 of 9· Check yourself
Your security team suggests delegating secret-scanning to a separate reviewer agent in the same Managed Agents session, so that the reviewer is walled off from the lead agent's credentials. What does handing work to that reviewer actually isolate?
Agents in a Managed Agents session share one sandbox, filesystem and set of vault credentials, so a hand-off does not separate permissions. What it separates is context: each agent has its own session thread and history. A subagent's thread also persists, so the lead can send it follow-ups.
“All agents share the same sandbox, filesystem, and vault credentials, but each agent runs in its own session thread, a context-isolated event stream”Source: platform.claude.com
Sources3
Practise it for real
Attach a remote MCP server to Claude Code and confirm its status
1.Run claude mcp add --transport http notion https://mcp.notion.com/mcp
Why: A URL means the server is remote, so it needs the http transport rather than a launch command
You should see: Claude Code saves a server named notion
2.Run claude mcp list, then claude mcp get notion
Why: These show each configured server and its connection details without opening a session
You should see: notion appears in the list, and get shows its details
3.Start claude and run /mcp
Why: The /mcp panel shows each server's status from inside a session and is where you re-enable a disabled server
You should see: The notion server appears with its status
4.Run claude mcp remove notion
Why: Removes the server when you are done, leaving the configuration as it was
You should see: notion no longer appears in claude mcp list
Stuck? Get a nudge
If a pasted JSON entry fails, check whether it has a url but no type. Claude Code reads that entry as stdio.
Sources
(9)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Your code executes the operation and sends back a tool_result.”
↩︎ Three ways to connect Claude to a system“Anthropic publishes the schema and trains Claude on it. Your application still executes each call and returns the tool_result.”
↩︎ Three ways to connect Claude to a system“For tools you define, you write the schema and your application executes each call.”
↩︎ Checkpoint“Claude responds with stop_reason: "tool_use" and one or more tool_use blocks. Your code executes the operation and sends back a tool_result.”
↩︎ Checkpoint - 2.
“Full conversation history stays with the host”
↩︎ Three ways to connect Claude to a system“Tool invocation requires the server to declare tool capabilities”
↩︎ What MCP standardises: primitives and transports“Multiple servers can be combined seamlessly Shared protocol enables interoperability”
↩︎ Key concept - 3.
“It uses its own configuration: model, system prompt, tools, MCP servers, and skills.”
↩︎ Three ways to connect Claude to a system“With subagents, it delegates tasks itself and reads what each subagent reports.”
↩︎ Three ways to connect Claude to a system“Delegation is one level deep, and a session can have at most 25 child threads at a time, idle ones included.”
↩︎ Three ways to connect Claude to a system“rather than loading a single agent with every capability”
↩︎ When the system is better reached as another agent“All agents share the same sandbox, filesystem, and vault credentials, but each agent runs in its own session thread”
↩︎ When the system is better reached as another agent“A subagent's thread stays available until you archive it, so the agent can send it follow-up messages.”
↩︎ When the system is better reached as another agent“Delegation is one level deep, and a session can have at most 25 child threads at a time, idle ones included.”
↩︎ Exam trap 5“All agents share the same sandbox, filesystem, and vault credentials, but each agent runs in its own session thread, a context-isolated event stream”
↩︎ Checkpoint - 4.
“Executable functions that allow models to perform actions or retrieve information”
↩︎ What MCP standardises: primitives and transports - 5.https://code.claude.com/docs/en/mcpOfficial docs
“an MCP server can also act as a channel that pushes messages into your session”
↩︎ What MCP standardises: primitives and transports“A launch command such as npx -y @example/mcp-server: the server runs on your machine.”
↩︎ Attaching an MCP server in Claude Code“Claude Code reads an entry with no type as a stdio server, so a url entry without a type fails.”
↩︎ Attaching an MCP server in Claude Code“Claude Code reads an entry with no type as a stdio server, so a url entry without a type fails.”
↩︎ Exam trap 3 - 6.
“The client launches the MCP server as a subprocess.”
↩︎ What MCP standardises: primitives and transports“The client MUST use HTTP POST to send JSON-RPC messages to the MCP endpoint.”
↩︎ What MCP standardises: primitives and transports“When running locally, servers SHOULD bind only to localhost (127.0.0.1) rather than all network interfaces (0.0.0.0)”
↩︎ What MCP standardises: primitives and transports“Servers MUST validate the Origin header on all incoming connections to prevent DNS rebinding attacks”
↩︎ Checkpoint - 7.https://code.claude.com/docs/en/headlessOfficial docs
“MCP servers: only servers supplied on the command line connect, for example with --mcp-config.”
↩︎ Attaching an MCP server in Claude Code“--allowedTools for auto-approving tools”
↩︎ Choosing the surface: Claude Code CLI, Agent SDK, Client SDK or Managed Agents - 8.https://code.claude.com/docs/en/agent-sdk/overviewOfficial docs
“The terminal interface, built for daily interactive use.”
↩︎ Choosing the surface: Claude Code CLI, Agent SDK, Client SDK or Managed Agents“A hosted agent harness that runs the agent loop”
↩︎ Choosing the surface: Claude Code CLI, Agent SDK, Client SDK or Managed Agents“Control which tools run automatically, which need approval”
↩︎ Choosing the surface: Claude Code CLI, Agent SDK, Client SDK or Managed Agents“A library that runs the Claude Code binary, with Claude Code’s capabilities, such as built-in tools, permissions, sessions, and hooks.”
↩︎ Exam trap 4“Read, write, edit files, run commands, and search the web”
↩︎ Prediction - 9.
“connect to remote MCP servers directly from the Messages API without a separate MCP client”
↩︎ The Messages API MCP connector: remote servers only“Local STDIO servers cannot be connected directly.”
↩︎ The Messages API MCP connector: remote servers only“Must be referenced by exactly one MCPToolset in the tools array.”
↩︎ The Messages API MCP connector: remote servers only“The server must be publicly exposed through HTTP (supports both Streamable HTTP and SSE transports).”
↩︎ Exam trap 1“Of the feature set of the MCP specification, only tool calls are currently supported.”
↩︎ Exam trap 2