When you ask Claude Code to read a database table, inspect a design mockup, or pull analytics from an external service, what happens under the hood isn't a "magic cloud call"—it's a strict packet exchange over the open Model Context Protocol (MCP). At its core, MCP is a universal socket between a language model and the outside world: instead of writing a bespoke adapter in the editor or agent core for every service, you stand up a compatible server that advertises its operations in a single machine-readable format.
That standardization quickly solves the isolation problem, but it immediately raises three practical engineering questions. How does message transport work so background processes don't crash the terminal or mix logs with commands? Which configuration file wins when the same server is defined both in the repository and locally on your machine? And most importantly—why did connecting a dozen external tools used to burn half the context window before your first prompt, whereas today it costs almost nothing?
The Host — Client — Server Triad and Two Transports: stdio vs. Streamable HTTP
In the current Model Context Protocol specification (version 2026-07-28), every integration breaks down into three distinct roles. Host is the application running the model (here, Claude Code or Claude Desktop). Client is the internal connector inside the host that maintains an isolated connection to one specific server. Server is an external program or remote service exposing three kinds of primitives: executable Tools, readable Resources, and reusable Prompts templates.
These components communicate using messages strictly encoded in . In practice, this means the model never sees your server's source code and never reads its documentation: it relies exclusively on the list of names, text descriptions, and argument that the server returns in response to tools/list.
The protocol delivers these JSON-RPC messages between client and server over two primary transports, while Claude Code also supports a third option for streaming push notifications.
| Transport | Where the Server Lives | How Exchange Works | Key Behavior in Claude Code |
|---|---|---|---|
stdio | Local child process on your machine | Line-delimited JSON-RPC over standard stdin and stdout streams | Host automatically passes CLAUDE_PROJECT_DIR; all server debug logs must go strictly to stderr |
| Remote service or local HTTP daemon | HTTP requests and streamed responses ("type": "http" or "streamable-http") | Supports OAuth and custom headers; since v2.1.265, automatically falls back to if the server rejects it | |
| Network server with a persistent socket | Bidirectional event channel ("type": "ws" in .mcp.json or claude mcp add-json) | Handy for push events, but does not support OAuth and cannot be configured via --transport |
Pay close attention to the ironclad rule of stdio transport: stdout is 100% reserved for JSON-RPC packets. If a local Node.js or Python script writes a plain debug line to stdout via console.log or print, the client will fail to parse JSON-RPC and the connection will drop immediately. All log output must go strictly to stderr.
Claude Code shuts down stdio processes on a strict timer so orphaned daemons don't pile up on your machine:
- On macOS and Linux, the host sends
SIGINT, waits 100 ms, sendsSIGTERM, and after another 400 ms forcefully kills the process withSIGKILL. - On Windows, the host closes the child process's
stdinstream, waits 300 ms, and if the process hasn't exited on its own, terminates the entire child process tree.
Early guides often referred to SSE (--transport sse) as the main network transport. In the current MCP transports specification, plain SSE is deprecated: always specify Streamable HTTP for new connections, and Claude Code will fall back to SSE automatically when backward compatibility is needed.
MCP protocol architecture: the Host, Client, and Server triad, stdio and Streamable HTTP transport channels, and deferred schema loading via MCP Tool Search.
.mcp.json Scopes and Strict Precedence Without Field Merging
You can register servers in Claude Code either through CLI commands or directly in configuration files. The entire connection system follows a strict scope hierarchy—from personal settings in a single folder up to organization-wide policies.
Before editing JSON by hand, look at how the core terminal MCP management commands work.
# Connect a remote server over Streamable HTTP at project scope (.mcp.json)
claude mcp add --transport http --scope project sentry https://mcp.sentry.dev/mcp
# Connect a local stdio server with an environment variable (-- separator is required)
claude mcp add --env API_TOKEN=your_token --transport stdio my-tool -- npx -y @org/mcp-server
# Connect a remote connector from the Anthropic Directory
claude mcp add --web notion https://mcp.notion.com/mcp
# Inspect, reset project approvals, and remove a server
claude mcp list
claude mcp get sentry
claude mcp reset-project-choices
claude mcp remove sentry
With claude mcp add for a local stdio server, keep two syntax quirks in mind: the double dash -- before the launch command is mandatory, and at least one flag (such as --transport stdio) must sit between --env and the server name—otherwise the parser treats the command argument as part of the env value. Inside a running session, you can inspect server health and reconnect a crashed process with /mcp, while new web connectors from the Anthropic Directory (requiring Claude Code v2.1.330+ on Pro/Max/Ultra or v2.1.332+ on Team/Enterprise) hot-load via /reload-plugins.
When the same server name appears in multiple places, a five-tier precedence pyramid applies (with an enterprise policy layer above it).
| Tier (Scope) | Where It Lives | When to Use It |
|---|---|---|
managedMcpServers | Organization system policy (v2.1.259+) | Enforced corporate servers and admin allowlists |
local (default) | ~/.claude.json under the specific project path | Your personal servers with local keys and debug flags |
project | .mcp.json at the root of the Git repository | Shared team tools committed to version control |
user | Global block in ~/.claude.json | Utilities you want available across every project |
| Plugins & Connectors | Plugin manifests and claude.ai account | Prebuilt extension bundles and cloud OAuth integrations |
If a server named postgres is defined in both the team's .mcp.json (project scope) and your local ~/.claude.json (local scope), Claude Code does not merge their env or args fields. The higher-precedence entry replaces the lower one in full, and any settings you didn't duplicate in local are dropped.
So a team .mcp.json can be committed to Git safely without secrets, the command, args, env, url, and headers fields support environment variable interpolation via ${VAR} and defaults via ${VAR:-default}. Below is a clean .mcp.json template configuring a local and a remote server side by side.
{
"mcpServers": {
"company-api": {
"type": "http",
"url": "${API_MCP_URL:-https://mcp.internal.example.com/mcp}",
"headers": {
"Authorization": "Bearer ${INTERNAL_MCP_TOKEN}"
}
},
"local-docs": {
"command": "node",
"args": ["./scripts/docs-mcp.js"],
"env": {
"DOCS_ROOT": "${CLAUDE_PROJECT_DIR}/docs"
}
}
}
}
Two critical details in this file cause most setup mistakes. First, the networked company-api server explicitly sets "type": "http": if you supply "url" but omit type, Claude Code defaults to treating the entry as a stdio server, fails to find a launch command, and silently skips the block. Second, to prevent key leaks from untrusted repositories, Claude Code forces sensitive system variables (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, AWS_BEARER_TOKEN_BEDROCK, HTTPS_PROXY, NPM_TOKEN) to resolve as empty if referenced in a remote server's url or headers. And whenever a new .mcp.json is first discovered in a project, the terminal always prompts for your explicit approval before launching it.
The Schema Context Tax and How MCP Tool Search Eliminates It by Default
Not long ago, the biggest complaint about MCP went like this: "hook up three or four servers with 20–30 tools each, and 30,000–50,000 tokens of your context window are gone before you even type your first question." The culprit was naive integration design.
When developers wrap an existing 1:1 into MCP—turning 50 endpoints into 50 tools—two metrics degrade at once:
- Context schema tax. Every model request had to carry the full catalog of JSON Schemas, descriptions, and
enumlists. - Tool-selection degradation. The model fumbled between lookalike methods like
modifyUser, forced to guess string status constants instead of calling crisp, intent-driven operations likeusers_activateorusers_extendwith a unique namespace prefix (service_...).
In current Claude Code (for Claude Opus 4, Sonnet 4, Haiku 4.5, and newer), the startup schema tax is eliminated by MCP Tool Search, which is now enabled by default. How does it work under the hood?
At session start, Claude Code loads only tool names and short server-level instructions into the system context. Heavy JSON Schemas and detailed descriptions remain deferred outside the active window and are fetched dynamically via a model search query only when the task genuinely calls for a specific tool. In addition, sorting the tool list alphabetically stabilizes key order so prefix caching stays intact across turns.
How MCP Tool Search Eliminates Startup Schema Tax
You can tune this behavior at three levels—from a global environment variable down to an individual tool in server code:
- Via the
ENABLE_TOOL_SEARCHenvironment variable.truekeeps tools deferred at all times;falsedisables search and loads everything upfront;autoenables deferred loading once schemas exceed 10% of the context window, whileauto:5sets the threshold to 5%. - Via
.mcp.jsonat the server level. Add"alwaysLoad": trueif a core server (such as your primary issue tracker) is needed on every other turn without an extra search step. - On the server side itself. In the
tools/listresponse, an individual tool can carry the_meta["anthropic/alwaysLoad"]flag.
Meanwhile, Claude Code strictly caps oversized server descriptions: instructions and preloaded tools are capped at 4,096 characters, while descriptions of tools loaded via MCP Tool Search are capped at 16,384 characters (overridable via CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH).
MCP Output Limits and the Emerging WebMCP Standard
Protecting input context isn't enough—a single careless command returning 100 raw database rows or a multi-megabyte log dump can blow up a session far faster. The Claude Code MCP documentation enforces four layers of defense against oversized responses, plus a hard cap on single-message network payloads.
| Threshold or Parameter | Default Value | What Happens When Exceeded | How to Control It |
|---|---|---|---|
| In-conversation warning | 10,000 tokens | Displays a notice about a large tool response | Optimize queries or add server-side filtering |
| Output token limit | 25,000 tokens | Tool output is capped at the configured budget | Environment variable MAX_MCP_OUTPUT_TOKENS |
| Disk spill threshold | 50,000 characters | Response is saved to tool-results inside ~/.claude/projects/ | _meta["anthropic/maxResultSizeChars"] attribute (500,000-char ceiling) |
| HTTP/SSE/WS packet size | 16 MiB | Hard read abort on oversized messages | Paginate exports across multiple calls |
A well-designed MCP server doesn't just bump into these limits—it splits output into two layers: a compact text projection content for the model (with an explicit [Data truncated...] marker on a line boundary so the model doesn't mistake a fragment for a complete result) and the full structuredContent field for programmatic clients.
Another major shift in the standard brings MCP out of the backend and directly into an open browser tab. Today, web agents have three options: call a server API directly via classic MCP (losing user visual oversight), embed UI widgets inside chat (MCP Apps), or run in co-browsing mode by clicking buttons in the browser. The catch with co-browsing is that reading the DOM and analyzing screenshots with vision models is slow, expensive, and breaks whenever a layout changes.
To make co-browsing reliable, the W3C Web Machine Learning Community Group is developing WebMCP (WebMCP repository, packages webmcp-types and @w3c/webmcp-polyfill). Instead of hunting blindly for buttons, a website registers typed JavaScript methods directly inside the active tab via document.modelContext.registerTool(...)—with a crisp argument JSON Schema and live access to the user's cart or session state.
await document.modelContext.registerTool({
name: "searchProducts",
description: "Search the catalog filtered by query and maximum price",
inputSchema: {
type: "object",
properties: {
query: { type: "string", description: "Search query" },
maxPriceUsd: { type: "number", description: "Maximum price in USD" }
},
required: ["query"]
},
execute: async ({ query, maxPriceUsd }) => {
const items = await window.storeCatalog.search({ query, maxPriceUsd });
return { count: items.length, items: items.slice(0, 5) };
}
});
When a page publishes this contract, the agent doesn't have to ask the browser for a screenshot and guess the search box coordinates—it calls searchProducts directly with typed arguments. For site owners, concerns raised by skeptics on the Apple WebKit team (risk of fragmenting the web into "human" vs. "agent" versions) are addressed through governing which frames may register tools, paired with for authentication. Production team benchmarks on live storefronts show a 2.5× to 7.5× efficiency jump over classic browser automation.
How Much Faster WebMCP Is Than Classic Browser Autoclickers
In nekuda.ai's measurements, invoking native methods via WebMCP proved 2.5–7.5× faster and up to 47× cheaper than screenshot-and-DOM-parsing workflows. In a live Shopify Checkout experiment, tasks completed 2.7× faster and 58% cheaper, hitting 60 out of 60 successful runs compared to 56 out of 60 for classic browser scripts.
You now have the full engineering map of the protocol: how the host manages stdio child processes and Streamable HTTP channels, why .mcp.json entries override without field merging, and how MCP Tool Search shields the context window from schema bloat. In the next lesson, we put this architecture to work—wiring Claude Code to visual and graphics MCP stacks for real Chrome, Figma mockups, and 3D scenes in Blender and Spline.
Apply This Right Now
- Audit your current connections with
claude mcp listand verify that every networked.mcp.jsonentry explicitly sets"type": "http"rather than deprecatedsseor a missingtypefield. - Separate configs by scope: move shared team servers using
${VAR}placeholders into project.mcp.json, and keep personal tokens and experimental tools inlocaloruserwithout duplicating server names. - Confirm that
ENABLE_TOOL_SEARCH=falseis not set in your environment and that rarely used servers do not enable"alwaysLoad": true, keeping schemas deferred. - When working with servers that return long logs or tables, adjust
MAX_MCP_OUTPUT_TOKENSif needed or add tool-side filters to stay within the 10,000–25,000 token window.

