tokenade
GitHubenfr
Install

Claude Code MCP: How to Set It Up

Connecting an MCP server to Claude Code takes one command. The part nobody tells you is what its tools return, and how much of that lands in your context.

Profile photo of Paul Irolla

By Paul Irolla

Founder · AI & developer tools · Tokenade

Ph.D. in AI · builds token-optimization tooling for AI agents

View author page
Updated 10 min read
Cite this page

How do you add an MCP server to Claude Code?

You add one with claude mcp add, and the exact form depends on the transport: claude mcp add --transport http <name> <url> for a remote server, or claude mcp add <name> -- <command> [args...] for a local process over stdio. That's the whole setup. The interesting question isn't how to connect a server — it's what connecting it costs you afterwards, which is the part the quickstarts skip.

I build token-reduction tooling, so I look at MCP from an angle most setup guides don't: every tool call returns something, and that something lands in context and stays in history for the rest of the session. Setup is a one-time act. The bill is recurring. This article covers both halves — the mechanics first, honestly and completely, then the accounting nobody publishes.

Here are the three forms you'll actually use:

# Remote server over HTTP
claude mcp add --transport http notion https://mcp.notion.com/mcp

# Local server over stdio (the -- separator is required)
claude mcp add airtable -- npx -y airtable-mcp-server

# With an environment variable
claude mcp add --env AIRTABLE_API_KEY=key airtable -- npx -y airtable-mcp-server

That -- separator matters: it tells Claude Code where its own options end and the server's command begins. Leave it out and your server's flags get parsed as Claude's.

Two notes on transports. SSE still works but HTTP is the preferred form for remote servers now. And WebSocket has no CLI flag at all — if you need type: "ws", you go through claude mcp add-json with a raw JSON string.

Which scope should you use — local, project, or user?

Use --scope project for anything your teammates also need, --scope user for tools you want in every project, and the default local for everything else. The scope decides which file the entry lands in, and that decides who else gets it.

ScopeFlagWritten toWho sees it
Local (default)--scope local~/.claude.json, under the current projectJust you, just here
Project--scope project.mcp.json in the project rootThe team, via version control
User--scope user~/.claude.json, top levelJust you, everywhere

The one that surprises people is user. It's convenient — connect once, available in every repo — and it's also the fastest way to end up with servers inside projects that have no use for them. A database MCP loaded into a static-site repo is clutter in the tool list at best, and pure overhead on every turn if your setup loads tools upfront. I keep user scope for genuinely universal tools and push everything else down to project.

On Windows, ~/.claude.json resolves to %USERPROFILE%\.claude.json. If you've set CLAUDE_CONFIG_DIR, that wins.

What does .mcp.json actually look like?

.mcp.json lives in your project root, gets committed to version control, and holds a single top-level mcpServers object keyed by server name.

{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": { "Authorization": "Bearer ${GITHUB_TOKEN}" }
},
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": { "DATABASE_URL": "${DATABASE_URL}" }
}
}
}

The fields split by transport. HTTP-family entries take url, headers, and optionally timeout (milliseconds), oauth and headersHelper. Stdio entries take command, args and env.

One trap worth knowing: an entry with no type field is treated as stdio. Pair that omission with a url and you get a configuration error rather than a working server, which is a confusing failure the first time you meet it. Set type explicitly and the problem never occurs.

Because .mcp.json is committed, Claude Code asks for approval before trusting project-scoped servers — a sensible guard, since a pulled branch could otherwise wire a new server into your session silently. claude mcp reset-project-choices clears those approvals if you need to re-decide.

How do you pass secrets without committing them?

Use ${VAR} expansion in .mcp.json so the file holds the name of the secret, never its value.

The syntax works in url, headers, command, args and env, and it supports defaults:

"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": { "Authorization": "Bearer ${API_TOKEN}" }

${VAR} substitutes the environment variable; ${VAR:-default} falls back when it's unset. That's what makes a committed .mcp.json safe: the token lives in your shell or your secret manager, and the repo carries only the reference.

For credentials that have to be minted at connect time — short-lived tokens, signed requests — there's headersHelper. You point it at an executable, it runs fresh on every connection with a 10-second budget, and it prints a JSON object of headers to stdout. Claude Code hands it CLAUDE_CODE_MCP_SERVER_NAME and CLAUDE_CODE_MCP_SERVER_URL in its environment so one script can serve several servers.

For OAuth servers you usually need nothing at all: HTTP and SSE servers negotiate OAuth 2.0 automatically, and the /mcp panel walks you through the browser sign-in. claude mcp login <name> and claude mcp logout <name> handle it from the CLI when you'd rather not leave the terminal.

How do you check a server is actually connected?

Run claude mcp list from the shell, or /mcp inside a session — both show every configured server with its live status.

The statuses you'll see are worth learning, because they fail in genuinely different ways:

  • ✔ Connected — working.
  • ! Connected · tools fetch failed — the transport is up but the tool list didn't come back. The server is reachable and useless.
  • ! Needs authentication — run claude mcp login <name>, or authenticate from the /mcp panel.
  • ✘ Failed to connect — unreachable. Usually a wrong URL, a dead local command, or a missing environment variable.
  • ⏸ Pending approval — a project-scoped server waiting on your trust decision.

claude mcp get <name> prints the full resolved config for one server, which is the fastest way to find out that your ${API_TOKEN} expanded to nothing.

The /mcp panel has one more number on it worth a look: the tool count per server. It tells you how big a surface each server adds, and the next section is about what that, and everything else, really costs.

What does each connected server cost you?

Less than it used to while idle, and more than you'd think once you call it. Claude Code defers MCP tool definitions by default since tool search shipped (Claude 4.5 and later models): only tool names and server instructions sit in context, and a tool's full schema loads when Claude reaches for it. An idle server is no longer a big standing cost. The exceptions are worth knowing: when ANTHROPIC_BASE_URL points at a third-party proxy, tool search is off unless you set ENABLE_TOOL_SEARCH; servers marked alwaysLoad: true load in full; and older models load everything upfront. Lazy MCP loading covers those cases.

The cost that stays is what tools return. A GitHub list_issues call, a Playwright page snapshot or a SQL query result lands in the context window in full and is re-sent with history on every later turn. Here's where I have to be straight with you: almost nobody publishes what their responses cost, or their manifests either. Third-party estimates for popular servers contradict each other by tens of thousands of tokens, because they measure different versions under different conditions. I'm not going to repeat them as facts.

So measure rather than guess. Two readings tell you nearly everything:

  1. /context at the start of a session, before you type anything. Whatever already occupies your context on turn zero is your standing overhead. With tool search on, it should be small; if MCP tool definitions take a big share, you're in one of the exceptions above.
  2. /context after a few real tool calls. The jump tells you what the responses cost, which on heavy servers like GitHub or Playwright is usually the bigger number.

Both take two minutes and are worth more than any figure I could quote you, because they're your servers at their current versions.

How do you keep the tools without paying for what they return?

Deferral is handled for you on a current Claude Code setup. What's left is hygiene and output. The hygiene part is simple: connect what this session needs, disconnect the rest, and prefer project scope over user so servers don't follow you into repos that don't want them.

The output part is where Tokenade comes in, inside Claude Code and also Cursor, Codex, Copilot and Windsurf. Its MCP proxy sits between the agent and each server (tokenade mcp-wrap install wraps your configured servers in one command) and compacts what the tools return before it reaches the model: dedicated compactors for GitHub and GitLab, browser automation (Playwright, Puppeteer, Chrome), filesystem, Git, memory and databases (Postgres, SQLite, MySQL, Supabase, DuckDB), and a generic shape-aware compactor for every other server. Screenshots and images pass untouched, and the full result stays recoverable. Compaction runs entirely on your own machine — none of your code is uploaded for analysis. It's free and open source (MIT/Apache-2.0), so install it and see whether the numbers move on your own setup.

Whichever route you take, the principle is the same: connecting a server should be a decision you make per project, not a default you inherit. Which MCP servers earn their place works through that trade-off server by server.

Can servers give you more than tools?

Yes — servers can also expose resources you reference with @ and prompts that appear as slash commands, though support varies because each server chooses what to implement.

Resources autocomplete when you type @, using the form @servername:protocol://resource/path — @github:issue://123, say, or @postgres:schema://users. Claude Code fetches and attaches the resource when you reference it. This is a genuinely cheaper pattern than a tool call for read-only lookups: you pull one specific thing instead of describing a search.

Prompts show up when you type /, as /mcp__servername__promptname — /mcp__github__list_prs, for instance, with arguments space-separated after it. They're discovered dynamically from whatever is connected.

What goes wrong (anti-patterns)

Installing servers at user scope by default. It's the convenient flag. Every project you open gets every tool you've ever connected, including the ones irrelevant to that repo, and the agent has more to choose from for no reason.

Assuming tool search is always on. Route Claude Code through a third-party proxy, or mark a server alwaysLoad, and every schema loads upfront again. Check /context once.

Ignoring what tools return. A single unfiltered GitHub or Playwright response can outweigh every schema you connected. Measure tool results, not just the manifest.

Omitting type in .mcp.json. No type means stdio. With a url present, that's a configuration error and a confusing first debugging session.

Committing secrets into .mcp.json. The file is designed to be committed. Use ${VAR} expansion — the repo should carry the name of the secret, never the value.

Judging a server by its tool count alone. Ten terse tools can cost less than four with sprawling schemas. The count is a proxy, /context is the measurement.

Frequently asked questions

What's the difference between .mcp.json and ~/.claude.json?

.mcp.json sits in your project root and is meant to be committed — it's how a team shares the same servers. ~/.claude.json is your personal file: --scope local writes there under the current project, --scope user writes there at the top level for all projects. Rule of thumb: if a teammate cloning the repo would need the server, it belongs in .mcp.json.

Does an MCP server cost tokens if I never call its tools?

A little. With tool search on (the default for Claude 4.5 and later models), only its tool names and server instructions sit in context, so an idle server costs little. Behind a third-party proxy, with alwaysLoad, or on older models, its full tool definitions are sent on every turn, and disconnecting unused servers becomes one of the cheapest wins available. Once you do call its tools, what they return is the bigger cost. Token-efficient MCP tool use covers that output side in depth.

How do I find out what a specific server costs me?

Run /context in a fresh session before typing anything, note the figure, connect the server, restart, and compare: that's its standing overhead. Then use it for a few calls and look again: that's what its responses cost, usually the larger number. Both beat any published estimate, since servers change between releases. If Tokenade wraps your servers, tokenade dashboard breaks savings down per MCP tool.

Why does my project-scoped server show "pending approval"?

Because .mcp.json is version-controlled, Claude Code asks before trusting servers it finds there — otherwise pulling a branch could wire a new server into your session without you noticing. Approve it in the /mcp panel; claude mcp reset-project-choices clears past decisions if you want to re-approve from scratch.

Can I use the same MCP servers in Cursor or Codex?

Largely yes — MCP is a shared protocol, so a server written for one agent generally works in another, though each host differs in configuration format and in which parts of the spec it implements. Whether tool definitions are deferred depends on the host; the size of what tools return carries over unchanged, which is why the levers in how to reduce AI coding agent token usage are agent-agnostic.


See also:

FAQ

Cut your AI agent's token bill.

Ranked #1 on the Token-Harness Optimizer Leaderboard. Zero config.

Tokenade cuts the token bill of AI agents: one install, zero config, and it trims what your agent sends to the model.