
Tokenectomy Razor
io.github.daffa2555Published by GitHub account daffa2555v1.1.1Updated Oct 24, 2026
Autonomous log surgery & secret redaction MCP server for AI coding agents.
Overview
Local MCP server and AI gateway that trims framework noise from error logs, redacts leaked secrets, and offers code analysis and patching tools.
- What you can do
- Clean and diagnose error logs: strip third-party stack frames, redact credentials, and pull relevant local source context
- Analyze code statically for resource leaks, unclosed handles, and syntax issues
- Apply atomic file patches with post-write syntax checks and rollback on failure
- Audit logs or prompts for token bloat, framework noise, and secrets, with savings metrics
- Search Stack Exchange for error signatures using sanitized search terms
- When to use it
- Useful when coding agents drown in long framework stack traces, burn context or rate limits on crash dumps, or risk forwarding database passwords, API keys and tokens to a model provider. Also handy for quick static checks and guarded file edits inside a project workspace.
- Requirements
- Runs as a local process on the user's machine, started via npx, cargo, a precompiled binary, or Docker. The optional gateway mode binds a local port and forwards requests to upstream model providers, which need their own credentials. Outbound network access is used only for the Stack Exchange search tool.
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
1- v1.1.1LatestSep 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