
Tokenectomy Razor
io.github.daffa2555由 GitHub 帳號 daffa2555 發布v1.1.1更新於 Oct 24, 2026
Autonomous log surgery & secret redaction MCP server for AI coding agents.
概覽
本機 MCP 伺服器兼 AI 閘道,可裁掉錯誤日誌中的框架雜訊、遮蔽外洩的密鑰,並提供程式碼分析與修補工具。
- 可以做什麼
- 清理與診斷錯誤日誌:剔除第三方堆疊框架、遮蔽憑證並取出相關的本機原始碼上下文
- 靜態分析程式碼,找出資源洩漏、未關閉的控制代碼與語法問題
- 以原子方式套用檔案修補,寫入後做語法檢查,失敗時自動回復
- 稽核日誌或提示詞中的 token 膨脹、框架雜訊與密鑰,並提供節省指標
- 以遮蔽後的搜尋詞到 Stack Exchange 查詢錯誤特徵
- 適用情境
- 適合程式編寫助理被冗長的框架堆疊淹沒、因崩潰日誌耗盡上下文或速率額度,或擔心把資料庫密碼、API 金鑰與權杖送給模型服務商的情況。也適合在專案工作區內做快速靜態檢查與受控的檔案修改。
- 執行需求
- 以本機程序在使用者電腦上執行,可透過 npx、cargo、預先編譯的執行檔或 Docker 啟動。選用的閘道模式會綁定本機連接埠並把請求轉送到上游模型服務商,這些服務商需要各自的憑證。只有 Stack Exchange 搜尋工具需要對外網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Tokenectomy Razor,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
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
來源:README.md,提交 29ff8de
工具
0版本歷史
1- v1.1.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分