What is an MCP server, why agents need it, and how to add one to Claude Code
The Model Context Protocol in plain words: how it is built, how to add an MCP server to Claude Code, and why every connected server costs tokens.
7 min · · агенты · development
What is an MCP server, and why would you need one? The question comes up the moment Claude Code or another agent suggests "connecting MCP". In short, it's a program that gives an AI application access to your tools and data through a shared standard. Below: how it works, how to add a server to Claude Code, and why every connected server affects token spend.
What is an MCP server, in plain words
MCP (Model Context Protocol) is an open standard for connecting AI applications to external systems: files, databases, search, work services. The protocol's authors compare it to a USB-C port: one standard socket instead of a pile of adapters for each device.
MCP has three participants:
- Host — the AI application you work in: Claude Code, Claude Desktop, VS Code, Cursor.
- Client — a component inside the host. The host creates a separate client with its own connection for each server.
- Server — a program that gives the host data and actions. This is what people call an MCP server.
A server can be local or remote. A local one runs on your machine as a process and talks to the client over standard input/output (the stdio transport). A remote one runs on the internet and takes requests over HTTP (the Streamable HTTP transport), often with OAuth or a token in a header. The messages themselves are JSON-RPC 2.0 in both cases.
What a server can expose
| Primitive | What it is | Example |
|---|---|---|
| Tools | Functions the model can call | Query a database, create a tracker issue |
| Resources | Data for context | Database schema, file contents |
| Prompts | Ready-made interaction templates | Code review template with examples |
The client discovers what a server offers with methods like tools/list and calls a tool via tools/call. The list can change on the fly: a server can notify the client that its tool set has been updated.
An important point from the protocol docs: MCP covers only context exchange and doesn't dictate which model the application uses. So the same server works with whatever model you pick in the host.
Why agents need MCP
On its own, a model knows only what was in its training data and what you put in the request. For an agent to look up an issue in a tracker, run a SQL query, or read a design mockup, it needs tools. Before MCP, every such integration was written from scratch for every application. With MCP, you write the integration once as a server, and any compatible host can use it.
How it works in practice:
- The host passes the model a list of tools: each one's name, description, and parameter schema.
- The model decides it needs a tool and returns a call with arguments.
- The host calls the server through its MCP client and gets the result.
- The result is added to the context, and the model continues with the new data.
It's ordinary tool calling, with the tool side standardized. If you want to see this loop without MCP, in plain code, read the article on autonomous agents from scratch or the step-by-step example an AI agent in Python from scratch.
How to add an MCP server to Claude Code
First, Claude Code itself has to run on your key. For Zukko that's four variables (details in the Claude Code guide):
export ANTHROPIC_BASE_URL=https://api.zukko.pro
export ANTHROPIC_AUTH_TOKEN=fetch_your_key
export ANTHROPIC_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-sonnet-5The last one is required: Claude Code sends background requests to the Haiku-slot model (by default claude-haiku-*), which is not in the Zukko catalog, and the gateway answers an unknown model name with 404 model_not_found. If you switch with /model opus or /model sonnet, also set ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL to catalog models.
MCP servers are added with claude mcp add. Examples from the official Claude Code docs — a remote server, a remote server with a token in a header, and a local server where everything after -- is the launch command:
claude mcp add --transport http notion https://mcp.notion.com/mcp # remote server over HTTP
claude mcp add --transport http secure-api https://api.example.com/mcp \
--header "Authorization: Bearer your-token" # remote server with a token
claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable \
-- npx -y airtable-mcp-server # local server (stdio)The --scope flag sets where the configuration lives:
| Scope | Where it applies | Stored in |
|---|---|---|
local (default) | Current project, only for you | ~/.claude.json |
project | Current project, for the whole team via git | .mcp.json in the project root |
user | All your projects | ~/.claude.json |
Claude Code doesn't silently start servers from .mcp.json: in an interactive session it asks for approval first. That protects you from a repository that slips in its own server.
Checking and managing:
claude mcp list # all servers and their status
claude mcp get notion # details for one server
claude mcp remove notion # remove itInside a session, /mcp shows server status and each server's tool count, lets you complete OAuth sign-in, and lets you switch a server off temporarily without deleting its configuration.
On security: an MCP server receives data from your session and acts on your behalf. Connect servers from trusted sources and don't give them tokens broader than the task needs.
How MCP relates to token spend
A server costs nothing by itself, but everything it adds to the context is billed as model input tokens.
Tool definitions. Each tool's name, description, and parameter schema go to the model as part of the request. Claude Code has a tool search mechanism for this: at startup only tool names load, and full definitions are fetched on demand. But according to the Claude Code docs, this mode is turned off by default when ANTHROPIC_BASE_URL points somewhere other than Anthropic — that is, through any gateway, Zukko included. Then the definitions of every tool on every connected server load into context right away. Forcing tool search with ENABLE_TOOL_SEARCH=true without testing isn't a good idea: the docs warn that requests fail on proxies that don't support the blocks it needs. The practical takeaway: keep only the servers you need switched on, and check what's taking up context with /context.
Tool results. Whatever the server returns stays in the context and travels with every following request in the session. Claude Code warns when an MCP tool's output exceeds 10,000 tokens and truncates it at 25,000 by default (the MAX_MCP_OUTPUT_TOKENS variable changes the limit).
Cache. Claude Code uses the Anthropic format, where the gateway sees which part of the input came from cache and bills it at the cache-read price. Tool definitions sit at the start of the request and rarely change, so they cache well. Details in the key limits and cache docs.
Example calculation
Prices as of October 7, 2026, claude-sonnet-5: input $0.4, cache read $0.05, cache write $0.5 per 1M tokens. Say your connected servers' tool definitions take 10,000 tokens (check your own number in /context), and the session has 100 requests.
- Without cache: 100 × 10,000 × 0.4 / 1,000,000 = $0.40.
- With cache: one write 10,000 × 0.5 / 1,000,000 = $0.005 plus 99 reads 99 × 10,000 × 0.05 / 1,000,000 = $0.0495, total $0.0545.
A large 25,000-token tool result that then rides along in the next 50 requests: with cache 25,000 × 0.5 / 1,000,000 + 50 × 25,000 × 0.05 / 1,000,000 = $0.0125 + $0.0625 = $0.075; without cache 50 × 25,000 × 0.4 / 1,000,000 = $0.50.
The amounts are small, but they repeat in every session and for every agent, and they also take up the context window. The Claude Code docs recommend using a command-line tool (gh, aws, and the like) instead of an MCP server where one exists: it has no tool list sitting in the context. Prices are an example calculation; for the current list and prices, call GET https://api.zukko.pro/v1/models or open the Models page in the dashboard.
If Claude Code isn't connected yet, create a key in the dashboard and set a daily dollar limit on it right away, so experiments with MCP servers stay within budget.
FAQ
Is an MCP server the same as an API?
No. An API is a specific service's interface. An MCP server is an adapter that describes tools and data in a single format for AI applications. Quite often an MCP server wraps someone's API.
Do MCP servers work when Claude Code runs through Zukko?
Yes. Servers connect to Claude Code itself, and the gateway receives ordinary model requests in which tool definitions and results are part of the context. Just keep in mind that through a gateway, tool definitions load upfront by default, without tool search.
How many MCP servers can I connect?
Claude Code has no hard cap; the limits are the context window and your budget. Use /mcp to switch off servers the current task doesn't need.
Is it safe to install MCP servers from the internet?
A server runs code on your machine or receives your data, so install only trusted ones. For servers from .mcp.json, Claude Code asks for approval.
zukko
Pay 25×
less
for Claude Code & ChatGPT
One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.
Related articles
- Prompt Injection: What It Is and How to Protect a Bot and an AgentHow prompt injection works through user input and third-party documents, and which measures limit the damage: data isolation, tool permissions, key limits.
- Claude Code YOLO: Permission Modes and Working Without PromptsClaude Code has no mode literally called YOLO, but it has several permission modes and flexible rules. How to stop clicking Yes without losing files.
- Claude Code: a checklist of best practices for daily workHabits that make working with Claude Code predictable: a short CLAUDE.md, a plan before edits, small tasks, checking results and keeping spend under control.
- An MCP server in Java: a minimal example with one toolWe write a minimal MCP server in Java with one tool, register it in Claude Code, and learn to find the cause when the agent doesn't see it.