DEV Community

MCP Token Saver
MCP Token Saver

Posted on

Real Token Cost of MCP: 91K Tokens of JSON

255 MCP tools. 91,000 tokens of JSON schemas. Before you ask a single question. Here's what I found and how I fixed it.


The experiment

I connected Claude Code to 5 MCP servers. File system, GitHub, Postgres, Puppeteer, and a custom search tool. Then I counted every token that flowed through the system.

The numbers:

Phase Token Count What it is
Tool discovery (initial) 91,247 JSON schemas for 255 tools
Per-conversation overhead 12,400 Repeated schema injections
Tool result wrapping 812 per call {"content":[{"type":"text","text":"..."}]}
20 tool calls later 16,240 Result overhead alone
Total for 1 conversation ~120,000 Before any real output

That's a GPT-4 conversation where 60% of your tokens are JSON braces, brackets, and repeated schema definitions.

Let me show you what I mean.


What MCP tool schemas actually look like

Here's ONE tool definition from a typical MCP server:

{
  "name": "search_files",
  "description": "Search for files matching a pattern in a given directory",
  "inputSchema": {
    "type": "object",
    "properties": {
      "pattern": {
        "type": "string",
        "description": "Glob pattern to match files"
      },
      "path": {
        "type": "string",
        "description": "Root directory to search in"
      },
      "case_sensitive": {
        "type": "boolean",
        "description": "Whether to perform case-sensitive matching",
        "default": false
      }
    },
    "required": ["pattern"]
  }
}
Enter fullscreen mode Exit fullscreen mode

That's 347 characters, ~87 tokens. For ONE tool.

A typical MCP server exposes 30-60 tools. Five servers = 255 tools. That's 22,185 tokens just for tool definitions.

But it gets worse. The model also gets:

  • Server status messages (~200 tokens each)
  • Tool listing headers (~50 tokens per server)
  • Error handling schemas (~100 tokens per tool)

Realistic total: 91K tokens for a 5-server setup.


The result wrapping problem

Every MCP tool result comes wrapped in this structure:

{
  "content": [
    {
      "type": "text",
      "text": "The actual content you care about"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

That's 47 characters of JSON overhead per result. For a 100-character result, 32% of tokens are pure overhead.

If the result is structured data:

{
  "content": [
    {
      "type": "text",
      "text": "{\"file\": \"app.py\", \"matches\": [\"line 42\", \"line 87\"]}"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Now you have JSON inside JSON. The inner JSON is stringified. The outer JSON wraps it. Double encoding. Double parsing. Double tokens.


The cost in dollars

At Claude 3.5 Sonnet pricing ($3/M input tokens):

Scenario Input Tokens Cost per Conversation
Without MCP 10,000 $0.03
With 5 MCP servers 130,000 $0.39
With 10 MCP servers 250,000 $0.75
Heavy tool use (50 calls) 200,000 $0.60

A developer having 20 conversations per day with MCP:

  • Daily cost: $7.80 - $15.00
  • Monthly cost: $156 - $300
  • Annual cost: $1,872 - $3,600

That's not counting output tokens.


I built a tool to fix this

mcptoon — a CLI that sits between your AI agent and MCP servers. It:

  1. Caches tool schemas — injects them once, not per conversation
  2. Compresses results — strips JSON wrapping, returns clean text
  3. Uses TOON format — Token-Optimized Object Notation

What TOON looks like

Instead of:

{"name": "search_files", "inputSchema": {"type": "object", "properties": {"pattern": {"type": "string"}, "path": {"type": "string"}}, "required": ["pattern"]}}
Enter fullscreen mode Exit fullscreen mode

TOON outputs:

name search_files
pattern string required
path string
Enter fullscreen mode Exit fullscreen mode

That's 62 tokens instead of 2,034 for all 255 tools. 97% reduction.

Real-world results

Metric Raw MCP With mcptoon Savings
Tool discovery 91,247 tok 2,847 tok 97%
Per-result overhead 47 chars 0 chars 100%
20 tool calls 16,240 tok 7,080 tok 56%
1 conversation total ~120K tok ~35K tok 71%

How to use it

pip install mcptoon
Enter fullscreen mode Exit fullscreen mode

Then in your Claude Code config:

{
  "mcpServers": {
    "filesystem": {
      "command": "mcptoon",
      "args": ["serve", "--stdio", "npx", "@anthropic/mcp-filesystem"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Or if you use Cursor:

mcptoon add filesystem --stdio npx @anthropic/mcp-filesystem
mcptoon list
Enter fullscreen mode Exit fullscreen mode

Zero dependencies. 250KB. Works with any agent that runs shell commands.


The bigger picture

MCP is a great protocol. The idea of standardizing tool interfaces across AI agents is important. But the implementation has a token efficiency problem that nobody talks about.

When Anthropic announced MCP, the examples showed 3-5 tools. That's manageable. But real-world setups have 50-255 tools. At that scale, the JSON overhead becomes the dominant cost.

If you're building MCP servers:

  • Keep tool descriptions short
  • Minimize schema complexity
  • Don't nest JSON in results
  • Consider token cost as a first-class concern

If you're consuming MCP tools:

  • Use a proxy like mcptoon to compress
  • Cache schemas across conversations
  • Limit the number of servers you connect

Show me the code

mcptoon is open source, Apache 2.0, zero dependencies:

The entire codebase is readable in an afternoon. No transitive dependencies to audit. No supply chain risk.

If this was useful, a GitHub star helps others find it. Questions? I'm in the comments.


This is an independent project. Not affiliated with Anthropic or the MCP team. All token counts are measured, not estimated.

Top comments (0)