{
  "id": 7464942,
  "title": "How I Cut 45,000 Next.js Error Tokens to 118 in <0.2ms Using a Rust MCP Server",
  "url": "https://urgent.news/2026/09/15/how-i-cut-45-000-next-js-error-tokens-to-118-in-0-2ms-using-a-rust",
  "topic": "ai",
  "section": "AI",
  "published": "2026-09-15T03:19:09.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/daffa2555/how-i-cut-45000-nextjs-error-tokens-to-118-in-02msusing-a-rust-mcp-server-1c7j"
  },
  "original_language": "en",
  "account": "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.\n\nTo 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.\n\nTo 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.",
  "summary": "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…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}