Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

Developer staring at a laptop screen, showing code editor with token usage metrics, frustrated expression, cluttered…
Open SourceScore: 72

Why MCP Can't Save Your Input Tokens (And What Actually Works in Claude Code)

MCP tools can't reduce your Claude Code input tokens since they run after context entry. Use a pre-send hotkey or CLI pipe to clean prompts before they enter the token meter.

·4h ago·4 min read··6 views·AI-Generated·Report error
Share:
Source: dev.tovia devto_mcpCorroborated
Can MCP tools in Claude Code reduce my input token usage?

MCP tools can't reduce your input tokens because they execute after your raw prompt is already in the context window. The only way to save input tokens is to clean prompts before they enter Claude Code—using a global hotkey or CLI pipe—not via MCP, hooks, or slash commands.

TL;DR

MCP tools run after your prompt enters context, so they add tokens instead of saving them. Use a pre-send hotkey instead.

Key Takeaways

  • MCP tools can't reduce your Claude Code input tokens since they run after context entry.
  • Use a pre-send hotkey or CLI pipe to clean prompts before they enter the token meter.

What Changed — The Token Optimization Trap You Need to Know

You built a prompt cleaner. You exposed it as an MCP tool for Claude Code. You expected token savings. And then you checked the transcript and realized you'd been paying more, not less.

This is the reality: MCP tools cannot reduce your input tokens. They run inside the agent loop, after your text is already in the context window. Every MCP-based token optimization for your own prompts is a net loss.

What It Means For You — The Three Broken Assumptions

Assumption 1: MCP cleans MY prompt

Here's what actually happens when Claude Code has a clean_prompt MCP tool:

  1. Your raw prompt enters the conversation context. The token meter has already run.
  2. The model reads it, decides to call clean_prompt.
  3. The tool returns the cleaned version — which is appended to the context.
  4. The model proceeds with raw + cleaned + tool-call overhead + tool schema in the system prompt.

Net effect: you paid for the raw prompt, then paid again for the cleaned copy, plus overhead.

Where MCP cleaning actually works: prompts Claude Code sends downstreamRAG queries, sub-agent instructions, pipeline calls. Those calls never see the raw version, so the savings are real there. That's a legitimate use case; it just isn't the "clean my typing" use case.

Assumption 2: Hooks can rewrite the prompt

Claude Code has a UserPromptSubmit hook that fires before the model sees your prompt. But it can only do two things: add context or block the prompt. It cannot replace the text. Same story with Codex's hooks framework — add-context or block only.

Assumption 3: Slash-command bash injection replaces the prompt

Claude Code slash commands support !command`` injection — the bash runs before the model sees the command body, and its output replaces it. So /clean <messy text> → bash pipes the text through the cleaning API → the model receives only the cleaned version.

This looks like it works. But check the session's JSONL transcript. The raw text is still there, recorded as <command-args>. And when the command resolves as a skill, the raw text appears about four times — command-args, tool args, skill-load note, bash output. The context cost goes up, not down.

Bonus trap: fail-open behavior

If your cleaning script fails open (missing API key → passes original text through), the model will paraphrase your raw prompt into a plausible-looking "Cleaned prompt: …" on its own. It looks identical to a real clean. The only way to tell is record-level transcript forensics.

Try It Now — What Actually Works

The token meter starts when your text enters the context. So the only place cleaning can save input tokens is in the text box, before send. Agent platforms give you no API for that moment — so go around them:

Option 1: Global hotkey (best for interactive use)

Set up a system-level hotkey (Windows Win32 RegisterHotKey, or AutoHotkey/Automator on Mac) that:

  1. Selects the content of your current text box
  2. Sends it to a cleaning API
  3. Replaces the text in place

You review the cleaned text and hit send. The raw version never enters any context.

Option 2: CLI pipe (best for one-shots)

Pipe your prompt through a cleaner before starting Claude Code:

cat messy_prompt.txt | clean_prompt | claude code

This works because the cleaning happens before the Claude Code process starts.

Option 3: MCP for downstream calls only

Use MCP cleaning for prompts Claude Code generates — RAG queries, sub-agent instructions, pipeline calls. Those never see the raw version, so savings are real.

The Honest Architecture Summary

MCP tool ❌ (adds tokens) Runs after raw text is in context Hooks ❌ Add-context / block only, no mutation Slash command + bash injection ❌ Raw persists in command-args; ~4× as a skill CLI pipe ✅ one-shots only Cleans before the process starts In-place hotkey before send ✅ Raw never enters any context MCP for downstream calls ✅ for those calls Sub-calls never see the raw

The one takeaway: know where the meter starts. A lot of "token optimization" tooling operates after that point and quietly makes things worse.


Source: dev.to

Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from multiple verified sources, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

Claude Code users should immediately audit any MCP tools they've installed that claim to optimize prompts. If the tool processes *your* prompts (not downstream ones), it's costing you tokens, not saving them. Remove those tools from your MCP configuration. For actual token savings, adopt a pre-send workflow. The simplest approach: use a CLI pipe for batch operations (`cat prompt.txt | cleaner | claude code`), or set up a global hotkey for interactive sessions. The AI Token Cleaner mentioned in the source provides both a REST API and a hotkey tool, but the principle works with any prompt cleaner. For MCP tools that *do* make sense: focus on tools that clean prompts Claude Code generates internally — RAG queries, sub-agent instructions, or pipeline calls to external APIs. Those are where MCP's post-context execution model actually delivers savings.

Mentioned in this article

Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Open Source

View all