
Claude Code MCP server: `claude mcp serve`, and why the client comes first
How the client handles other people's servers, what one command exposes when the direction reverses, and who is responsible for confirming a tool call then.
Last verified 28 August 2026 · from code.claude.com documentation for MCP, the CLI and the tools
This page is one of 90 in a directory of monitoring and developer tools. Each page checks what an AI coding agent can get out of the tool through its MCP server, the connector that lets the agent query the tool directly.
Summary
Claude Code is the MCP client that nearly every other page in this directory writes a configuration block for. That is its usual role.
It also runs the other way. `claude mcp serve` starts Claude Code as a stdio MCP server, so another application, such as Claude Desktop, can call Claude Code's tools.
The documentation is explicit about the consequence: this server only exposes Claude Code's tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.
As a client, it caps what a server can spend. A warning appears past 10,000 tokens of tool output, and the default maximum is 25,000, adjustable with MAX_MCP_OUTPUT_TOKENS.
What is the Claude Code MCP server?
Claude Code is an MCP client that can also run as an MCP server. MCP has two ends. A client holds the conversation and decides which tools to call. A server exposes tools and answers those calls. Almost every vendor in this directory ships a server.
Claude Code is the client end. It reads server configurations, negotiates with them, runs the tools they expose and applies permission rules before anything happens.
One command reverses that. claude mcp serve presents Claude Code's own tools, which read and edit files, run shell commands and search the web, to whatever connects to it over stdin and stdout.
The same product in both roles:
| Direction | Command | What crosses the boundary |
|---|---|---|
| Claude Code as client | claude mcp add, add-json, list, get | Other people's tools come in, under Claude Code's permission rules |
| Claude Code as server | claude mcp serve | Claude Code's own tools go out, and the connecting client owns confirmation |
The asymmetry matters. In the first row Claude Code decides what runs. In the second it does not, and the documentation says so.
It is a development tool, so it reaches the code and nothing operational.
| Part of the work | What Claude Code has here | Can an agent reach it |
|---|---|---|
| Code, tests & review | Files, edits, shell commands, search and language servers | Yes. Direct rather than through an API. It reads and writes the working tree instead of querying a platform about it |
| CI & release | Whatever the shell can reach | Partial. Indirect. A pipeline is reachable through its CLI, and nothing is modelled as a build or a deploy |
| Production observability | None | No metrics, logs or traces of its own |
| Agent observability & evals | Its own session tooling | Partial. Task and schedule tools describe work inside the session, and nothing evaluates model output |
| AI cost management | None | No spend data of any kind |
For an agent, Claude Code is where the other connectors are used rather than a connector itself. In server mode it hands another model a file system and a shell. That is a larger grant than the vendor servers in this directory make.
What can an AI agent do with Claude Code?
Claude Code documents 45 built-in tools, and 14 need permission inside Claude Code itself, including Bash, Edit, Write, PowerShell, WebFetch and WebSearch. Those are what claude mcp serve registers for a connected client. The documentation is explicit about the consequence. The server exposes only Claude Code's tools to your client, so that client owns confirmation. An agent connected this way reads files, runs shell commands and fetches pages.
What connecting costs before the first question
A context window is the amount of text a model can hold at once. Pointing another client at claude mcp serve loads all 45 of Claude Code's tool definitions. On Claude that costs 4,168 to 5,412 tokens. Fourteen of them require permission inside Claude Code itself.
This is the one page in the guide where the connector runs in the other direction, so the cost lands on whichever client you attach rather than on Claude Code. Shell execution and file writes are in that list.
| Tool set | Tools | Tokens (GPT-5.6, GPT-5.5) | Tokens (GPT-4, GPT-3.5) | Tokens (Claude Haiku 4.5 to Opus 5) | Share of a 200,000-token window |
|---|---|---|---|---|---|
| Every tool documented | 45 | 2,367 to 2,816 | 2,375 to 2,824 | 4,168 to 5,412 | 1.2% to 2.7% |
Encodings: GPT-5.6, GPT-5.5 o200k_base; GPT-4, GPT-3.5 cl100k_base; Claude Haiku 4.5 to Opus 5 count_tokens. Counted from the 45 tool entries in the vendor's own documentation. That documentation is the only public inventory.
The server could not be run for a live tools/list. No input schemas are available, so these figures cover each tool's name and description only. They are a floor, not the figure.
The Claude columns are measured through the API's count_tokens endpoint with an empty schema per tool. So they cover the same content as the GPT columns. The range there is two tokenizer generations. Haiku 4.5 and Opus 4.6 are at the low end. Opus 5 and Sonnet 5 are at the high end. The gap between them is about a third.
Can Claude Code watch your own AI agents?
Mostly no. Claude Code is the agent in these setups rather than the thing watching one, so the signals below describe its own session and not a model you are running. Read from the Claude Code documentation on 25 August 2026.
| Signal | Covered | Notes |
|---|---|---|
| Trace and session tracking | Partial | Task and schedule tools describe work inside the running session. There is no record of a past session to read back |
| Eval scores on recorded traffic | No | Nothing in the 45 built-in tools evaluates model output |
| Prompt version tracking | No | No tool versions or diffs a prompt |
| Offline experiments | No | No dataset-backed run exists to compare against |
| Token and cost tracking | No | The documented figures are ceilings, not accounting: a warning past 10,000 tokens of tool output and a default maximum of 25,000 |
Claude Code MCP server limits: where answers come back incomplete
Claude Code changes the approval boundary: its first limitation decides who is responsible for a tool call.
In server mode the permission prompt you are used to does not apply.
Anthropic states it directly: the server only exposes Claude Code's tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.
Claude Code documents 45 built-in tools and marks 14 as permission-gated inside Claude Code. Those gates are the ones that stop applying when another application is driving.
Guard: Only point a client at claude mcp serve if that client prompts for each tool call. The disclosure block above makes the agent restate the situation.
The agent says: “That is the whole result.” It may have stopped at 25,000 tokens.
Claude Code warns past 10,000 tokens of MCP output and applies a default maximum of 25,000. Connectors that return whole tables reach that ceiling routinely.
Guard: Bound the query at the server, rather than raising MAX_MCP_OUTPUT_TOKENS until the answer fits.
How to configure Claude Code MCP for agents
- 1
Decide which direction you actually need
Adding a vendor server is the common case. Running
claude mcp serveis the rare one, and it is the one that exposes more if it goes wrong. - 2
Give the full executable path in server mode
The documentation warns that a
commandnot on the systemPATHproducesspawn claude ENOENT, and points atwhich claude. - 3
Budget tool output
A warning appears past 10,000 tokens and the default ceiling is 25,000, changed with
MAX_MCP_OUTPUT_TOKENS. - 4
Know the startup wait
With
-p, Claude Code waits for pending servers up toMCP_TIMEOUT, 30 seconds by default. A server with a cached tool list skips the wait. - 5
Use
--strict-mcp-configfor a reproducible runIt ignores every other MCP configuration and uses only what
--mcp-confignames.
Paste this into your agent’s instructions
In server mode the confirmation step moves to the other side. An agent describing its own actions is the only remaining record of what it did.
When you answer using Claude Code as an MCP server, state: - Which tool ran and which paths or commands it touched. - That confirmation is the connecting client's job here. Claude Code's own permission prompts do not apply. - Whether a command changed files or only read them. Never state that data does not exist. State the path you read and what the tool returned. Write your answer in ASD-STE100 Simplified Technical English. Use short sentences with one idea in each.
Do you need the MCP server at all?
Usually no, not in server mode. For most tasks the question is which vendor server to add to Claude Code, and every other guide in this directory answers that.
Where another application needs file and shell access, its own tooling is usually the smaller grant. Server mode hands over Claude Code's whole tool list at once.
For a scripted run, --strict-mcp-config with an explicit --mcp-config file is the reproducible shape, and it makes the server set reviewable.
Where output size is the problem, a server that supports narrowing the query is better than a higher ceiling. Elastic and Prometheus both do this cheaply.
Add servers to it freely. Run it as a server only where the other side prompts.
Claude Code MCP server setup
Nothing is installed for either direction. Both are the claude CLI already on your machine.
No credential appears in the server-mode block below. It launches a local process over stdio, so there is no endpoint to authenticate against and no token to store.
The client-mode commands are the ones every other page in this directory uses. They are collected here for reference.
Claude Code as a server
Starts a stdio MCP server. The documentation notes the command prints nothing when it starts: a silent, blocked terminal means it is running and waiting for a client.
No credentials are needed. It is a local process on stdin and stdout, not an endpoint to authorize against.
claude mcp serve
Claude Desktop connecting to it
Anthropic's own example. No credentials are involved because the transport is a local process, not a network endpoint.
{"mcpServers":{"claude-code":{"type":"stdio",
"command":"claude",
"args":["mcp","serve"],
"env":{}}}}Use the full path if `claude` is not on `PATH`. The documentation names the failure exactly: spawn claude ENOENT. Run which claude and substitute the result.
Cursor connecting to it
In ~/.cursor/mcp.json for all projects, or .cursor/mcp.json in one. Cursor runs stdio servers, so the shape matches the Claude Desktop block, and no credentials are involved.
{"mcpServers":{"claude-code":{"command":"claude",
"args":["mcp","serve"]}}}Claude Code as a client
The commands the rest of this directory relies on. add-json is the route for a server that needs environment variables rather than a bare URL.
These commands hold no credentials themselves. A server needing one either takes it in its own config, or completes browser OAuth on first connect.
claude mcp add --transport http <name> <url>
claude mcp add-json "<name>" '{"command":"npx", ...}'
claude mcp list
claude mcp get <name>Authenticating a server from the shell
Runs a configured server's OAuth flow without opening the interactive panel. Over SSH, --no-browser prints the authorization URL to paste instead. Requires Claude Code 2.1.186 or later.
claude mcp login <name> claude mcp login <name> --no-browser claude mcp logout <name>
Every other client
Each block below is the configuration for one client, with the file path and the key that client expects.
Bounding what a server can spend
Claude Code warns when a single tool result passes 10,000 tokens, and refuses past the maximum. The default maximum is 25,000 tokens.
This is the lever that matters when a connector returns a whole table or a whole flame graph. No credential is involved; it is an environment variable read at startup.
MAX_MCP_OUTPUT_TOKENS=50000 claude
Reproducible server sets
--mcp-config loads servers from JSON files or strings. --strict-mcp-config uses only those, ignoring every other MCP configuration on the machine. Neither flag needs credentials: any authorize step belongs to the servers the file names.
claude --strict-mcp-config --mcp-config ./mcp.json
Startup timing
With -p, Claude Code waits for still-pending servers before the first turn, up to MCP_TIMEOUT, 30 seconds by default. A server with a cached tool list skips the wait and connects on first use.
This is why a slow server delays a scripted run rather than failing it. No authentication is involved in the wait itself.
MCP_TIMEOUT=10000 claude -p "..." --mcp-config ./mcp.json
Starting without any of it
--bare skips auto-discovery of MCP servers, hooks, skills, commands, subagents, plugins and project memory, leaving shell, file read and file edit. --safe-mode disables customisations to troubleshoot a broken configuration.
Both are useful when deciding whether a connector is what slowed a session down. Neither needs credentials, because neither loads a server to authorize against.
claude --bare -p "query" claude --safe-mode
Read-only access, permissions and security
In server mode, confirmation is not Claude Code's job
The documentation states that the server only exposes Claude Code's tools to your client, and that the client is responsible for implementing user confirmation for individual tool calls.
The tools on offer are broad
Claude Code documents 45 built-in tools, of which 14 require permission inside Claude Code itself, including
Bash,Edit,Write,PowerShell,WebFetchandWebSearch.A stdio server has no network boundary
It is a local process reading stdin, so the protection is whatever the connecting application enforces, plus the file permissions of the account that launched it.
As a client, an untrusted server's output is still text a model reads
The output ceiling limits how much of it arrives, not whether it is trustworthy.
--strict-mcp-configis the audit leverIt guarantees a run used only the servers named on the command line, which is otherwise hard to prove on a developer machine.
Troubleshooting
- `claude mcp serve` prints nothing
- That is documented behavior, not a failure. A stdio server communicates over stdin and stdout, so a silent, blocked terminal means it is running and waiting for a client.
- `spawn claude ENOENT`
- The
commandfield must reference the Claude Code executable. Runwhich claudeand put the full path in the configuration. - A tool result is truncated or warned about
- Claude Code warns past 10,000 tokens of MCP output and stops at the maximum, 25,000 by default. Raise it with
MAX_MCP_OUTPUT_TOKENS. - A scripted run stalls at startup
- With
-p, Claude Code waits for pending servers up toMCP_TIMEOUT, 30 seconds by default. A server with a cached tool list is not waited for. - A server will not authenticate over SSH
- Use
claude mcp login <name> --no-browser. It prints the authorization URL to paste, then takes the redirect URL back at the prompt. Requires version 2.1.186 or later. - You cannot tell which server broke the session
- Start with
--safe-mode, which loads no customisations at all, or--bare, which skips MCP discovery while keeping shell and file tools.
Claude Code MCP server: Reference
| Item | Value |
|---|---|
| Server command | claude mcp serve |
| Transport | stdio, over stdin and stdout |
| Server auth | None. A local process, not an endpoint |
| Confirmation in server mode | The connecting client's responsibility |
| Built-in tools documented | 45 |
| Of those, permission-gated | 14 |
| Client commands | add, add-json, list, get, login, logout |
| Output warning threshold | 10,000 tokens |
| Output maximum | 25,000 tokens by default, via MAX_MCP_OUTPUT_TOKENS |
| Startup wait | MCP_TIMEOUT, 30 seconds by default |
| Login flags require | Claude Code 2.1.186 or later |
| Inventory source | code.claude.com MCP, CLI and tools documentation, read 25 August 2026 |
What the vendor documents
The useful record here is the documentation itself, which states the limits numerically rather than describing them.
| What was checked | What it shows |
|---|---|
| Built-in tools documented | 45 |
| Requiring permission | 14 |
| Output warning threshold | 10,000 tokens |
| Default output maximum | 25,000 tokens |
| Default startup timeout | 30 seconds |
| MCP client subcommands | Six documented |
“This MCP server only exposes Claude Code's tools to your MCP client, so your own client is responsible for implementing user confirmation for individual tool calls.”
“The command prints nothing when it starts. A stdio MCP server communicates over stdin and stdout, so a silent, blocked terminal means the server is running and waiting for a client to connect.”
“Without the correct executable path, you'll encounter errors like spawn claude ENOENT.”
Facts on this page come from three Anthropic documentation pages read on 25 August 2026: the MCP guide, the CLI reference and the tools reference. The built-in tool count is the number of rows in the tools table, and the permission count is the rows marked as requiring permission.
Should you connect an agent to Claude Code?
Yes. Best for client mode always. Server mode only where the connecting application prompts for each call.
- Strongest fit
- Everyone connecting a vendor server, which is the usual direction and the reason most of this directory exists.
- Main advantage
- The client side is explicit about cost and reproducibility: an output ceiling, a startup timeout and a flag that ignores every configuration except the one named.
- Main weakness
- Server mode moves the confirmation step to the other application, and the documentation is clear that it does.
- Operational risk
- A client without per-call prompts driving 45 built-in tools, including shell execution and file writes.
From Oodle
One platform for agent traces and infrastructure
Agent traces usually sit in a different product from the rest of your telemetry, so when a slow database makes an agent slow the symptom is in one tool and the cause is in another. Oodle keeps both in one query surface, from $10 per million spans.
See agent observabilityFrequently asked questions
Is Claude Code an MCP server or a client?
Mostly a client. claude mcp serve also runs it as a stdio MCP server, which Anthropic documents under the heading Use Claude Code as an MCP server.
What does the server expose?
Claude Code's own tools. The documentation names 45 built-in tools in total, of which 14 require permission inside Claude Code, including Bash, Edit and Write.
Who approves a tool call in server mode?
The connecting client. The documentation states that the server only exposes Claude Code's tools, so the client is responsible for implementing user confirmation.
Why does the serve command print nothing?
Because a stdio server speaks over stdin and stdout. The documentation says a silent, blocked terminal means it is running and waiting for a client.
How large can a tool result be?
A warning appears past 10,000 tokens and the default maximum is 25,000. MAX_MCP_OUTPUT_TOKENS changes the maximum.
How do I authenticate a server without the interactive panel?
claude mcp login <name>, with --no-browser over SSH to print the authorization URL. Both need Claude Code 2.1.186 or later.