NewAgent Observability is live.
Back to directory
Claude Code logo

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.

Connector
Official, and built into the CLI
Coverage
Claude Code's own tools, over stdio
Tools
45 built-in tools documented, 14 needing permission
Biggest risk for an agent
As a server, the connecting client owns confirmation

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:

DirectionCommandWhat crosses the boundary
Claude Code as clientclaude mcp add, add-json, list, getOther people's tools come in, under Claude Code's permission rules
Claude Code as serverclaude mcp serveClaude 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 workWhat Claude Code has hereCan an agent reach it
Code, tests & reviewFiles, edits, shell commands, search and language serversYes. Direct rather than through an API. It reads and writes the working tree instead of querying a platform about it
CI & releaseWhatever the shell can reachPartial. Indirect. A pipeline is reachable through its CLI, and nothing is modelled as a build or a deploy
Production observabilityNoneNo metrics, logs or traces of its own
Agent observability & evalsIts own session toolingPartial. Task and schedule tools describe work inside the session, and nothing evaluates model output
AI cost managementNoneNo 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 setToolsTokens (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 documented452,367 to 2,8162,375 to 2,8244,168 to 5,4121.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.

SignalCoveredNotes
Trace and session trackingPartialTask and schedule tools describe work inside the running session. There is no record of a past session to read back
Eval scores on recorded trafficNoNothing in the 45 built-in tools evaluates model output
Prompt version trackingNoNo tool versions or diffs a prompt
Offline experimentsNoNo dataset-backed run exists to compare against
Token and cost trackingNoThe 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. 1

    Decide which direction you actually need

    Adding a vendor server is the common case. Running claude mcp serve is the rare one, and it is the one that exposes more if it goes wrong.

  2. 2

    Give the full executable path in server mode

    The documentation warns that a command not on the system PATH produces spawn claude ENOENT, and points at which claude.

  3. 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. 4

    Know the startup wait

    With -p, Claude Code waits for pending servers up to MCP_TIMEOUT, 30 seconds by default. A server with a cached tool list skips the wait.

  5. 5

    Use --strict-mcp-config for a reproducible run

    It ignores every other MCP configuration and uses only what --mcp-config names.

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.

Terminal
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.

Terminal
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.

Terminal
{"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.

Terminal
{"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.

Terminal
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.

Terminal
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.

Terminal
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.

Terminal
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.

Terminal
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.

Terminal
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, WebFetch and WebSearch.

  • 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-config is the audit lever

    It 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 command field must reference the Claude Code executable. Run which claude and 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 to MCP_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

ItemValue
Server commandclaude mcp serve
Transportstdio, over stdin and stdout
Server authNone. A local process, not an endpoint
Confirmation in server modeThe connecting client's responsibility
Built-in tools documented45
Of those, permission-gated14
Client commandsadd, add-json, list, get, login, logout
Output warning threshold10,000 tokens
Output maximum25,000 tokens by default, via MAX_MCP_OUTPUT_TOKENS
Startup waitMCP_TIMEOUT, 30 seconds by default
Login flags requireClaude Code 2.1.186 or later
Inventory sourcecode.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 checkedWhat it shows
Built-in tools documented45
Requiring permission14
Output warning threshold10,000 tokens
Default output maximum25,000 tokens
Default startup timeout30 seconds
MCP client subcommandsSix 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.”

Claude Code MCP documentation, code.claude.com, 25 August 2026 · The tip printed directly beneath the Claude Desktop configuration for server mode.

“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.”

Claude Code MCP documentation, code.claude.com, 25 August 2026 · The documented failure when a desktop application cannot resolve the `claude` command.

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 observability

Frequently 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.

Changelog

  • Claude Code 2.1.221. --mcp-config with -p waits for still-pending servers before the first turn, up to MCP_TIMEOUT.
  • Claude Code 2.1.199. --permission-prompt-tool can no longer approve a tool marked as requiring user interaction; an allow result becomes a deny.
  • Claude Code 2.1.186. claude mcp login and claude mcp logout added, so a server's OAuth flow runs without the interactive panel.

Sources

Every number on this page traces to one of these

  1. Claude Code documentation · Connect Claude Code to tools via MCP, read 25 August 2026
  2. Claude Code documentation · CLI reference, same date
  3. Claude Code documentation · tools reference, same date

Claude Code’s own MCP documentation

Servers that reach the same code:

Servers with the smallest output: