{"slug": "i-added-mcp-servers-to-claude-code-here-s-what-they-cost-in-tokens", "title": "I added MCP servers to Claude Code. Here's what they cost in tokens.", "summary": "A developer measured the token overhead of MCP servers in Claude Code sessions, finding that the official GitHub MCP server adds ~62,000 tokens per 20-turn session—costing about $0.19 in tool-definition overhead alone. The overhead compounds in long agentic loops, with a 2,000-turn session potentially wasting millions of tokens on unused tool definitions.", "body_md": "Everyone talks about MCP servers as a way to extend Claude Code. Fewer people talk about what they cost.\n\nEvery MCP tool you register injects a tool-definition block into your context window on every single turn. That's not a one-time cost — it compounds across your entire session. I wanted to know the actual numbers, so I measured them.\n\nWhen Claude Code loads an MCP server, it reads the server's tool manifest and injects something like this into the system prompt:\n\n```\n<tool>\n  name: read_file\n  description: Read the contents of a file at the given path...\n  inputSchema: { type: object, properties: { path: { type: string } }, required: [\"path\"] }\n</tool>\n```\n\nThat's roughly 80–150 tokens per tool, depending on how verbose the description and schema are. A server with 10 tools = 800–1,500 tokens added to *every turn* of your session.\n\nI ran sessions with three different MCP server setups and tracked the token breakdown using [tokenscope-mcp](https://www.npmjs.com/package/@wartzar-bee/tokenscope-mcp) — an MCP server that exposes Claude Code's own `.jsonl`\n\ncost data back to the agent so you can inspect it mid-session.\n\nHere's what I found across 20-turn sessions:\n\n| MCP server | Tools registered | Tokens/turn (tool defs) | 20-turn session overhead |\n|---|---|---|---|\n| No MCP | 0 | 0 | 0 |\n| Custom minimal server | 3 | ~180 | ~3,600 |\n| filesystem (official) | 7 | ~640 | ~12,800 |\n| github (official) | 26 | ~3,100 | ~62,000 |\n\nThe GitHub MCP server — which many people add by default — costs **~62,000 tokens of overhead per 20-turn session**, before you've asked it to do anything. At Claude Sonnet 4 input pricing ($3/MTok), that's roughly $0.19 in pure tool-definition overhead per session.\n\nThat doesn't sound like much. But if you're running long agentic loops — the kind where Claude Code is doing multi-step tasks autonomously — you're paying that overhead on every single turn, including turns where the agent never touches GitHub at all.\n\nIn a standard interactive session, you might do 20–30 turns. In an autonomous agent loop running overnight, you might do 500–2,000 turns.\n\nAt 2,000 turns with the GitHub MCP server loaded:\n\nThis is exactly the dynamic behind the \"136M tokens doing almost nothing\" pattern. The agent isn't being wasteful in any obvious way — it's paying a per-turn tax on every tool it *could* use, whether it uses them or not.\n\nThe `.jsonl`\n\nsession logs that Claude Code writes to `~/.claude/projects/`\n\ncontain per-turn token breakdowns. You can inspect the `input_tokens`\n\nfield across turns and watch it stay elevated even on turns where the agent just reads a file.\n\n```\n# rough per-turn input token average for your last session\ncat ~/.claude/projects/**/*.jsonl | \\\n  python3 -c \"\nimport sys, json\nturns = [json.loads(l) for l in sys.stdin if l.strip()]\ninputs = [t.get('usage',{}).get('input_tokens',0) for t in turns if 'usage' in t]\nprint(f'turns: {len(inputs)}, avg input tokens/turn: {sum(inputs)//max(len(inputs),1)}')\n\"\n```\n\nIf your average input tokens per turn is much higher than the actual content you're passing, tool definitions are likely the culprit.\n\n**1. Use project-scoped MCP configs.**\n\nClaude Code supports `.mcp.json`\n\nat the project level. Create different configs for different task types — a writing config with no GitHub server, a code-review config with filesystem only, etc. Don't load every server for every session.\n\n**2. Prefer MCP servers with fewer, more focused tools.**\n\nA server with 3 well-scoped tools costs 6–8× less overhead than one with 26 broad tools. When evaluating MCP servers, tool count is a real cost signal.\n\n**3. If you write MCP servers, keep descriptions tight.**\n\nA 400-token tool description vs. an 80-token one is a 5× difference in per-turn overhead across every session that loads your server. The schema matters too — avoid deeply nested optional fields that inflate the JSON schema block.\n\nMCP is genuinely useful. I'm not arguing against it. But the cost model is non-obvious: you pay for *registered* tools, not *called* tools. Every tool definition rides along in your context whether the agent uses it or not.\n\nOnce you see that, the right mental model shifts from \"add MCP servers for capabilities I might want\" to \"add MCP servers for capabilities I'm actively using in this session.\"\n\n*I track per-turn token costs using tokenscope (CLI) and tokenscope-mcp (MCP server). Both read Claude Code's native *\n\n`.jsonl`\n\nlogs — no proxy, no API key, no modified client.", "url": "https://wpnews.pro/news/i-added-mcp-servers-to-claude-code-here-s-what-they-cost-in-tokens", "canonical_source": "https://dev.to/wartzarbee/i-added-mcp-servers-to-claude-code-heres-what-they-cost-in-tokens-2can", "published_at": "2026-07-21 01:02:24+00:00", "updated_at": "2026-07-21 01:29:50.571937+00:00", "lang": "en", "topics": ["developer-tools", "large-language-models", "ai-tools", "ai-infrastructure"], "entities": ["Claude Code", "GitHub", "Anthropic", "tokenscope-mcp"], "alternates": {"html": "https://wpnews.pro/news/i-added-mcp-servers-to-claude-code-here-s-what-they-cost-in-tokens", "markdown": "https://wpnews.pro/news/i-added-mcp-servers-to-claude-code-here-s-what-they-cost-in-tokens.md", "text": "https://wpnews.pro/news/i-added-mcp-servers-to-claude-code-here-s-what-they-cost-in-tokens.txt", "jsonld": "https://wpnews.pro/news/i-added-mcp-servers-to-claude-code-here-s-what-they-cost-in-tokens.jsonld"}}