OpenRouter: GitHub MCP used 42x the tokens of gh CLI

OpenRouter measured one GitHub task via MCP, the gh CLI and a skill. What each costs in context, and how builders wiring tools into agents should choose.

Picture a developer at a five-person agency. In one afternoon they wired the GitHub MCP server into a homegrown agent so it could check releases and triage issues across client repos. It works. Then the API bill comes in higher than expected, and long sessions start losing track of earlier instructions. Nobody added a feature. The agent sends a big block of tool definitions with every request, and some tool results are huge and get resent on every later turn. The forum advice is "just use the CLI," usually with no numbers behind it.

OpenRouter published numbers on November 11, 2026. In MCP vs CLI vs Skills: What Each Costs in Context, it ran one GitHub question through three setups: the GitHub MCP server, the gh CLI and a gh skill, on four models. On Claude Sonnet 5.5 all three answered correctly. The CLI used 1,421 input tokens, the skill 3,315, and the MCP server with its default tools 59,417. The post also shows where those tokens go and how to cut them, including with OpenRouter's own Tool Search server tool, which is in beta.

What it is

The post is a cost study plus a toolkit. It is not a product launch, though it ends by recommending OpenRouter's product. Here are its findings, each mapped to the agency developer's bill.

Tool definitions are a fixed tax on every request. OpenRouter counted the GitHub MCP server v2.0.2's 46 default tools at 19,436 extra prompt tokens per request on Claude Haiku 5.5. The post says Haiku counts a prompt exactly as Sonnet 5.5 does. The same tools cost 8,903 tokens on GPT-6 Luna and 8,525 on Gemini 3.8 Flash. Even the host matters: on Gemini 3.8 Flash the 46 tools cost 8,525 tokens through Google Vertex and 13,010 through Google AI Studio. The cost also grows with each toolset. On Haiku 5.5, the 10-tool issues toolset adds 5,801 tokens and the one-tool users toolset adds 619.

Tool results can cost more than the definitions. The MCP server's get_latest_release returned GitHub's full release object, 42,182 characters. Per OpenRouter, 87% of it described 22 download files. The model needed only the tag and the date. That object then stays in the context window, and on Sonnet 5.5 it added about 20,400 tokens. The gh CLI with --json tagName,publishedAt returned one line.

So scoping and trimming matter more than the protocol. OpenRouter ran each setup three times on October 20, 2026 and reports medians. On Sonnet 5.5, the default MCP server cost $0.1274 per task against $0.0075 for the CLI: 42 times the input tokens, 17 times the cost. Scoping the server to the 2 tools the task needs brought it to 23,228 tokens. Adding a 4,000-character cap on results brought it to 5,357 tokens at $0.0191, with every run correct. The skill (a 1,492-character SKILL.md of gh recipes) cost more than the bare CLI because, in OpenRouter's words, the file stays in the conversation once read.

Tool Search defers definitions until the model asks for them. You mark tools defer_loading: true and add the openrouter:tool_search tool. With all 46 GitHub tools deferred, the cost before any search was 578 tokens on the Claude models, 144 on GPT-6 Luna and 130 on Gemini 3.8 Flash. Over the whole task, it roughly halved Sonnet 5.5's tokens (59,417 to 30,334) and raised Haiku 5.5's (99,319 to 154,623).

An independent measurement backs the shape of this. In a DEV Community post originally published on ImportStatic (October 17, 2026), the author counted GitHub's server, v1.14.0 with defaults, at 11,207 tokens of definitions using OpenAI's o200k_base tokenizer. Input schemas made up 83% of that and descriptions 12%. Their sharpest finding cuts against the "MCP is bloated" story: the issue_write tool costs 807 tokens, while gh issue create --help costs 869. Their conclusion is that "the real difference was never the format. It's eager versus lazy loading."

Alternatives, each described only from its own source:

Who it's for

Pick this up if you run your own agent loop against a model API and pass MCP tools straight through. The ImportStatic post is blunt about this case: "If you call a model API yourself and pass the tools from tools/list straight through, you're loading everything." That covers the agency developer, anyone running high-volume automated agents where per-task cost multiplies, and anyone whose agents talk to a server that mirrors a whole product API.

The per-request definition tax matters less to you if you work mainly inside a harness that already defers tools, such as Claude Code with tool search on. The tool-result lesson still applies, though: OpenRouter notes that deferral doesn't shrink results.

Skip the switch to a CLI if your agent has no shell, if you need the server's own auth and permissions, or if the work is a long, stateful session with an app. Copes keeps his 49-tool video-editor MCP server for exactly that reason. Skip OpenRouter's Tool Search specifically if you're on Chat Completions and can't move, or if your agent forces tool calls with tool_choice (see Where it breaks).

Before and after

Before, with the default setup:

  1. Start the GitHub MCP server with its default toolsets and pass every tool to the model.
  2. Every request carries the full set of definitions: 19,436 tokens on Claude, per OpenRouter.
  3. The agent calls get_latest_release and receives a 42,182-character object, which rides along on every later turn.
  4. On list_issues the model chooses the result size. OpenRouter saw GPT-6 Luna ask for 100 issues with full text in four of six runs, getting 281,963 characters back.
  5. Result on Sonnet 5.5: 59,417 tokens and $0.1274 per task, or $127 per 1,000 tasks.

After, following the post's decision table:

  1. If a well-known CLI exists and the agent can run commands, give it a shell tool and one line saying gh is installed and authenticated: 1,421 tokens.
  2. If it's your own CLI, or one the model uses inconsistently, add a skill: 3,315 tokens, same commands every run.
  3. If you need MCP, scope it to the tools the task needs: 23,228 tokens with 2 tools.
  4. Trim results to the fields you need. list_issues takes a fields argument, and asking for only number, title and creation date cut its result from 8,336 characters to 714.
  5. For a large library across many servers, defer tools with Tool Search, keeping your three to five most-used tools loaded, as OpenRouter's docs suggest.

Try it

The setup, per OpenRouter's post: Python with the requests library, an OPENROUTER_API_KEY environment variable, and the MCP server binary you want to measure. The post publishes the full mcp_cost.py script. It runs the MCP handshake, follows pagination on tools/list, then sends the same tiny request to each model with and without the tools and reports the difference in usage.prompt_tokens. OpenRouter argues this is more reliable than a local tokenizer, because each provider renders tool definitions into the prompt in its own format. Each run costs a few API calls.

Step 1, measure your own server. This is the post's run for the GitHub server:

python mcp_cost.py github-mcp-server stdio --toolsets=default

What OpenRouter saw:

46 tools
anthropic/claude-haiku-5.5 +19,436 prompt tokens on every request
openai/gpt-6-luna +8,903 prompt tokens on every request
google/gemini-3.8-flash +8,525 prompt tokens on every request

Replace the arguments with your own server's start command. If the number is large, you have found the fixed tax.

Step 2, check whether a CLI already does the job with a small, shaped output. OpenRouter's comparison call:

gh release view -R cli/cli --json tagName,publishedAt

It returned one line with the tag and the publish date, against the MCP tool's 42,182 characters.

Step 3, if you stay on MCP, scope the server. The ImportStatic post measured what github-mcp-server v1.14.0's flags buy, from 23,206 tokens for --toolsets all (91 tools) down to 1,693 tokens for three named tools:

--tools issue_read,issue_write,list_issues

If you run the server through ToolHive, Stacklok's docs show the equivalent with environment variables, adding read-only mode:

thv run -e GITHUB_TOOLSETS=repos,issues,pull_requests -e GITHUB_READ_ONLY=1 github

Re-run Step 1 after each change and watch the number fall.

Step 4, trim results in your client before the model sees them. Prefer whole fields (gh's --json, list_issues' fields argument) over a character cap. OpenRouter's cap worked only because GitHub puts the tag and date near the top.

Step 5, optionally, try deferral. On OpenRouter's Responses or Messages API, mark your MCP tools defer_loading: true and add this tool, then compare usage.input_tokens before and after:

{"type": "openrouter:tool_search"}

Cap the number of requests in your loop. OpenRouter's Gemini run once hit its 12-request limit.

Step 6, tell your agent the rules. Here is an example of ours, not from the sources, for a CLAUDE.md or system prompt that follows the post's practice:

- For GitHub lookups, use the gh CLI (installed and authenticated). Always pass --json with only the fields the task needs.
- Never request more than 10 issues at a time; ask for number, title and creation date unless the body is required.
- If a tool call returns an error, read it before retrying; do not retry more than twice with changed argument types.

The third line answers a specific failure. OpenRouter saw Haiku 5.5 retry list_issues three or four times with wrong-typed arguments, such as labels as a string instead of an array.

Where it breaks

It's one task on one server. OpenRouter says so itself: "We tested one server on one task, so run mcp_cost.py on yours before you decide." The study also leads to OpenRouter's own Tool Search, so read the Tool Search rows as a vendor testing its own beta product. We found no independent reproduction of OpenRouter's specific numbers. The ImportStatic counts agree in direction, but they use a different server version (v1.14.0 against v2.0.2) and a local tokenizer whose author says to "treat the figures as close, not exact."

Tool Search is unstable across models. In five runs of the same script, Haiku 5.5 used anywhere from 2,134 to 13,225 tokens, rising with each search. GPT-6 Luna wrote phrases instead of patterns, made three to six searches, and once gave up without calling the tool. On Gemini 3.8 Flash, deferring didn't save anything over the whole task (37,568 against 35,409 loaded). OpenRouter attributes Haiku's cost jump to failed list_issues calls and retries. Treat that as the post's own account of three runs, not a settled cause.

Combining fixes can break correctness. OpenRouter reports that the 4,000-character cap plus Tool Search left Gemini 3.8 Flash and Haiku 5.5 with one correct answer in three runs each.

There are API constraints. Tool Search fails with a 400 error if the request also forces a tool call through tool_choice. Chat Completions doesn't accept it at all, so you'd first move that agent to the Responses or Messages API.

Caching is a partial answer at most. OpenRouter says prompt caching lowers the price of these tokens but doesn't remove them from the context window. It's not clear from the post whether caching was in play in the per-task cost comparison.

Your harness changes the bill. The ImportStatic post says how much MCP overhead you pay depends on the harness: "In a harness that defers, MCP's standing cost is a few hundred tokens. In one that doesn't, it's the whole table above on every call." Sentry's blog adds that harnesses implement tool search differently, and that features such as server instructions aren't uniformly supported.

CLIs have their own costs. Sentry argues MCP is still better at discovery: the agent "does not even know the CLI exists by default." Copes' switch made big reads slower, 9.7 seconds for one long project, and the JSON output was 905 KB, far too much to hand an agent in one go.

Deferral is not a security control. Safeguard's blog notes that you still send every definition with each request, that tool descriptions are untrusted text a server author controls, and that "selection is not authorisation." A trimmed tool list still needs scoped credentials and approval for write actions.

The verdict: if you call model APIs yourself with MCP tools passed straight through, run the measurement script this week. The cheapest fixes, scoping and field-trimming, need no new vendor. Reach for Tool Search when your tool library is large, and only after testing it on the model you actually run.

Sources