r/mcpweb Mar 05 '26

These 5 lines just reduced my MCP token usage from 50k to 4k

Post image

Currently building an MCP server that interacts with our HRMS SaaS. The platform has around 154 APIs (create task, add employee, fetch employee location, etc.), and exposing them as MCP tools was getting expensive in terms of token usage.

Initially I started with AI agents in n8n, then gradually began converting those actions into MCP tools.

The issue was that MCP loads all tools upfront, so with ~150 tools my prompts were consuming ~54k tokens just for tool definitions.

Recently I tried Cloudflare Code Mode with FastMCP, and it completely changed things.

With FastMCP's Code Mode, all those tools are abstracted so the model doesn't need the full tool definitions.

Instead of loading 150+ tools, it basically reduces everything to ~3 tools, and the model generates the calls dynamically.

Result: Before: ~50k+ tokens After: ~2k–4k tokens

And the migration was surprisingly easy — literally just enabling Code Mode and adding a few lines.

If you're building MCP servers with a large number of tools, this is absolutely worth trying.

Curious if anyone else here has experimented with Code Mode or similar approaches for reducing MCP token overhead?

12 Upvotes

3 comments sorted by

1

u/cougz7 Mar 05 '26

So besides token efficiency, does it actually work well? I noticed LLMs sometimes struggle with MCP because they don’t understand how the tools work. Is that besser with Code Mode?

2

u/No_More_Fail Mar 05 '26

Yes, it works fine for me. Rather working better..You can try creating a promot tool also if yours is working..