
Tokenectomy Razor
io.github.Tokenectomy-LabsPublished by GitHub account Tokenectomy-Labsv1.3.3Updated Oct 24, 2026
Cut 95% of framework noise and token bloat from error logs for AI agents.
Overview
A local Rust MCP server and AI gateway that strips framework noise from error logs, redacts leaked credentials, and analyzes or patches code.
- What you can do
- Process error dumps: run trace surgery to remove framework noise, redact credentials and pull relevant local source context, and audit logs or prompts for token bloat and secrets with savings metrics and health grades. Analyze code: static AST checks for resource leaks, unclosed handles and syntax issues. Modify files: apply atomic patches with post-write syntax verification and rollback on failure. Search the web: query Stack Exchange with sanitized, redacted error signatures.
- When to use it
- Useful when debugging crashes in large framework stacks (Node, Python, Rust, Java and others) and you want the assistant to see only the relevant frames, without secrets, before it proposes a fix. Also fits workflows where the assistant should analyze code and apply verified patches.
- Requirements
- Runs locally as a stdio process, typically started with npx (Node.js) or installed via Cargo, precompiled binaries or Docker. No API keys or environment variables are declared. The optional gateway mode binds a local port and routes to upstream providers such as Anthropic, OpenAI, Groq or Ollama. The Stack Exchange search tool needs outbound network access, which can be disabled with a local-only flag.
Installation
In SourceWeft
- Open Tokenectomy Razor in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
Tokenectomy Razor
Fix Claude Code & Cursor Rate Limits: Zero-Latency Local AI Gateway & Context-Surgery MCP Server in Rust
Stop burning 20,000 tokens on node_modules stack traces. Tokenectomy Razor is a sub-millisecond local AI Gateway reverse proxy (127.0.0.1:8080) & companion MCP server written in safe Rust. Excises 41.7%–99.7% framework noise from terminal error logs, redacts leaked DB credentials/JWTs, and caches prompts for free.
[Official MCP Registry] [crates.io] [npm] [OpenSSF Scorecard] [OpenSSF Best Practices] [CI] [License]
Quick Start (10s) • Architecture • The Problem • Before & After • Live Interactive Demo • Benchmarks
⚡ Quick Start (10s)
0. Zero-Config One-Liner Wrapper (wrap)
Run any coding agent or test suite directly behind Tokenectomy's privacy & caching gateway with zero manual environment variable setup:
1. Launch the Standalone AI Gateway (Manual Mode)
💡 Smart Multi-Provider Auto-Routing & Universal LLM Transpiler ON by default! Tokenectomy automatically analyzes request paths and headers. Need to run Claude Code against DeepSeek or Ollama? Tokenectomy transparently transpiles Anthropic
/v1/messagesformat into OpenAI/v1/chat/completionson-the-fly and vice-versa.
2. Connect Your Favorite Agent
Point your coding agent or CLI to the local gateway on 127.0.0.1:8080:
3. Real-Time FinOps & Security Dashboard
Open http://127.0.0.1:8080/dashboard in your browser to observe live token reductions, prompt cache hits, dollar savings, and redacted credentials in real time.
4. Companion MCP Server Setup (Sub-Cortex)
For agents calling deep diagnostic tools (get_error_context, analyze_code, apply_code_patch):
Claude Code CLI
Google Antigravity / Gemini CLI
Cursor Composer (.cursor/mcp.json)
Claude Desktop (claude_desktop_config.json)
5. Terminal Piping & CLI Scrubbing
🛑 The Problem: Why Your AI Hits Rate Limits & Hallucinates
When your app crashes during development (Next.js, Express, FastAPI, Tokio), the runtime dumps hundreds of lines of third-party plumbing from node_modules or site-packages.
When you paste that raw crash dump into Cursor or Claude:
- Eats Your 5-Hour Rate Limit: A single Express/Prisma error can dump 5,000 to 45,000 tokens of third-party library code you never wrote. A few crash loops easily burn your session limit.
- Triggers AI Hallucinations: Claude gets lost in framework internals (
node_modules/express/lib/router/layer.jsorstarlette/routing.py) and tries to edit library files instead of your actual application code. - Leaks Secrets & Credentials: Connection strings with raw database passwords, JWT bearer tokens, and cloud keys embedded in error traces get forwarded to external model servers.
🔍 Before & After Comparison
❌ Without Tokenectomy: AI Hallucinates & Burns Context
What Claude does: Analyzes
load-components.jsandnext-server.js, speculates on Webpack / Next.js internals, and leaks connection credentials to remote inference logs.
✅ With Tokenectomy: Clean Context & Instant Fix
What Claude does: Instantly identifies that line 42 in
checkout.tsattempted to access.tokenon undefined headers. Suggests optional chainingreq.headers.authorization?.tokenimmediately. Credentials redacted before transmission.
🔬 Verifiable Benchmarks
All performance claims are hardware-grounded and independently reproducible on physical hardware (measured on 10-Core Intel Core i5-1235U @ 15W running Arch Linux, Kernel 6.13):
Hardware Dependency Notice: Performance is hardware-dependent; reported throughput represents measured results on the specified test hardware (10-Core Intel Core i5-1235U @ 15W TDP). Throughput scales with higher TDP desktop/server CPUs and faster memory buses. Developers are encouraged to independently audit performance using the reproduction command below.
📋 Click to expand full raw benchmark terminal log ($ cargo test --release)
🛡️ Automated Redaction & Secret Sanitization Benchmark
Evaluated across an internal benchmark test fixture (tests/fixtures/) of 12 polyglot crash traces (Rust, Python, TypeScript, Go, YAML) containing 22 ground-truth credentials and clean negative controls. Evaluated head-to-head against Gitleaks v8.30.1 (default ruleset).
Architectural Note: Gitleaks is designed primarily as a repository commit/diff scanner, not an in-memory runtime trace redactor. Tokenectomy Razor is engineered specifically for runtime stream sanitization and stack trace surgery.
1. Per-Category Precision, Recall & F1-Score
2. Head-to-Head Performance & Architectural Summary
3. Token Reduction & LLM Context Savings (tiktoken cl100k_base)
🔌 Advanced Agent & Gateway Configuration
1. Multi-Provider AI Gateway Options (--proxy)
Tokenectomy's gateway runs locally on 127.0.0.1:8080 with zero manual configuration. In complex development environments or containerized agent topologies, you can customize binding and routing:
Real-Time Metrics & Prometheus Export
Tokenectomy exposes live FinOps and token economics data via JSON:
Returns instant telemetry for rate_limits_mitigated, circuit_breaker_trips, last_latency_ms, current_hourly_tokens, cache_hits, cache_tokens_saved, and estimated_cost_saved_usd.
2. Standalone CLI & Terminal Scrubbing
When debugging or piping terminal test output directly:
🛠️ Exposed MCP Tools
Tokenectomy Razor complies with Glama Grade A Tool Definition Quality Score (TDQS) with explicit parameter boundaries:
🌐 Supported Polyglot Ecosystems
📦 Installation Options
Method 1: Instant via npx (Zero Toolchain Setup)
Method 2: Cargo (crates.io)
Method 3: Precompiled Standalone Binaries
Zero-dependency, standalone release binaries available on GitHub Releases:
- Linux:
x86_64-unknown-linux-gnu,x86_64-unknown-linux-musl,aarch64-unknown-linux-gnu - macOS:
aarch64-apple-darwin(Apple Silicon M1/M2/M3/M4),x86_64-apple-darwin(Intel) - Windows:
x86_64-pc-windows-msvc.exe
Method 4: Multi-Arch Docker Container (GHCR)
⚖️ Edition Comparison
Need Enterprise AST Self-Healing? Explore the Sentinel Tier
🗺️ Roadmap & Milestones
🔒 Security & Invariants
- Local Execution by Default: All stack trace parsing, frame pruning, and secret redaction execute locally on physical hardware.
- Documented Network Egress: In MCP server mode,
search_stack_overflowis the sole tool with outbound network egress (HTTPS toapi.stackexchange.com). The payload is strictly limited to sanitized, redacted error signature text (no code lines, no local paths, zero credentials). In air-gapped environments, use--local-onlyto disable network search entirely. - Deterministic Linear-Time Pattern Matching: All pattern matchers utilize non-backtracking DFA regex engines ($O(N)$ linear time) and Aho-Corasick automaton evaluation.
- Path Traversal Boundary Isolation: File operations are strictly locked within the active workspace root (
CWD). Path traversals (../) and unauthorized symlinks are blocked. - Safe Rust Implementation: Core execution paths enforce safe Rust memory guarantees with bounded stream readers (
.take()) preventing resource exhaustion.
For vulnerability disclosures, please review our Security Policy.
⚖️ Legal & Downstream Fork Disclaimer
Tokenectomy Razor is provided strictly for lawful developer productivity, observability, log surgery, and defensive credential redaction. Any downstream forks, clones, redistributions, or private deployments operate completely independently of the original authors. Tokenectomy Labs and its maintainers assume zero liability for unlawful, malicious, or unauthorized actions committed by third parties using this codebase or derivatives thereof. All downstream operators bear 100% individual responsibility for compliance with local and international cybersecurity laws. See DISCLAIMER.md for full legal terms.
❓ Frequently Asked Questions (FAQ)
How does Tokenectomy Razor prevent Claude Code & Cursor from hitting rate limits?
When tests or terminal builds crash, frameworks like Next.js, Express, Jest, and Django dump thousands of internal stack frames (node_modules, site-packages). Sending raw 5,000-line crash logs consumes 15,000 to 45,000 tokens per prompt, draining your 5-hour session limit in minutes. Tokenectomy Razor intercepts logs and strips 95% of non-actionable framework plumbing, reducing a 40,000-character crash log to under 200 essential tokens in <0.2ms.
How do I stop Cursor from sending node_modules error logs to LLMs?
Run Tokenectomy Razor as a local AI Gateway reverse proxy (npx -y tokenectomy-razor --proxy). In Cursor settings, point your OpenAI Base URL to http://127.0.0.1:8080/v1. Any terminal error output pasted or referenced by Composer will be automatically sanitized, scrubbed, and cached on the fly before reaching model servers.
How does Tokenectomy prevent credential leakage in error logs?
All log surgery and secret redaction execute 100% locally on your machine in memory before outbound transmission. Razor uses deterministic linear-time regex and Aho-Corasick automata to detect and redact PostgreSQL/MongoDB connection URIs, JWT bearer tokens, and cloud API keys with [REDACTED] tokens. Zero cloud egress is required for scrubbing.
🤝 Community & Resources
- 🌐 Official Website
- 📖 Documentation
- 🏗️ System Architecture
- 📋 Changelog
- 🤝 Contributing Guidelines
- 🔒 Security Policy
- ⚖️ Disclaimer & Liability
Tokenectomy Labs • Autonomous M2M Sub-Cortex
Engineered with precision by Daffa (@daffa2555)
Licensed under the MIT License
Source: README.md at commit 29ff8de
Tools
0Version history
3- v1.3.3LatestSep 19, 2026
- v1.3.2Sep 18, 2026
- v1.3.1Sep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts