How I Cut 45,000 Next.js Error Tokens to 118 in <0.2ms Using a Rust MCP Server
If you use Cursor, Claude Desktop, or Cline daily, you have probably watched your rate limits evaporate because of a single runtime crash. A Next.js build fails or a Python script panics, and your terminal vomits 500 lines of stack traces. The LLM eagerly ingests all 45,000 tokens of internal node_modules machinery, webpack bundles, and event loop frames. You just paid $0.15 for an AI model to…
When using Cursor, Claude Desktop, or Cline, it is not uncommon for rate limits to quickly deplete due to a single runtime crash. If a Next.js build fails or a Python script panics, the AI agent is flooded with 45,000 tokens of internal framework code, web pack bundles and event loop frames. The $0.15 cost of an AI model to read uneditable code, clearing the prompt cache and causing the agent to hallucinate, becomes a significant issue.
Sending sensitive information like DATABASE_URL and API keys to an external API in the terminal's standard error line is also problematic.
To address this issue, an open-source Rust Model Context Protocol (MCP) server called Tokenectomy Razor has been created. This local server intercepts logs, strips out framework internals, and redacts all secrets using a deterministic DFA regex before sending a smaller, cleaner error log to the AI agent. The error log is reduced from 45,820 tokens to just 118 tokens, a reduction of 99.7%.
No credentials are leaked, and logs, environment variables, and proprietary code remain on the local machine. The server runs in sub-millisecond latency, has a lightweight footprint, and provides AST verification and rollback capabilities.
To set up Tokenectomy Razor, pre-built native binaries are distributed via npm for Linux, macOS (Apple Silicon & Intel), and Windows. Add a few lines to your claude_desktop_config.json or Cursor MCP settings or install it using cargo. With Tokenectomy Razor, the next time an agent encounters a large error log, the token bill will be thankful.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.