Tokenectomy-Razor
Tokenectomy-Razor is a local MCP server that surgically cleans crash logs, redacts secrets, analyzes code, and safely applies fixes to help AI coding agents save tokens and avoid hallucination.
get_error_context: Feed a raw stack trace/error log to get a sanitized trace (secrets redacted, framework noise stripped), relevant local source snippets, and git diff context.
search_stack_overflow: Search Stack Exchange for solutions using a clean, redacted error query.
apply_code_patch: Apply an atomic, syntax-verified code edit with rollback on failure; supports dry-run validation.
analyze_code: Perform offline Tree-sitter AST analysis (currently Python) for resource leaks, security issues, and syntax flaws with precise line/column coordinates.
audit_context_health: Audit any log or prompt payload for token bloat, framework noise, and credential leaks, returning savings metrics and a health grade.
Also supports CLI piping/scrubbing, MCP integration with Cursor/Claude/Windsurf/VS Code, a local AI gateway reverse proxy, and a FinOps dashboard (from README).
Supports Ollama as a local/offline AI model provider for the server.
Supports OpenAI as one of the AI model providers for the server.
Queries Stack Exchange APIs to search for and inject relevant Stack Overflow solutions into the AI context.
โก 10-Second Quickstart
Add Tokenectomy to your coding agent with zero configuration. Works immediately via npx (no Rust toolchain required):
1. Cursor IDE
Add to .cursor/mcp.json in your workspace root (or global ~/.cursor/mcp.json):
{
"mcpServers": {
"tokenectomy": {
"command": "npx",
"args": ["-y", "tokenectomy-razor", "--mcp"]
}
}
}2. Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"tokenectomy": {
"command": "npx",
"args": ["-y", "tokenectomy-razor", "--mcp"]
}
}
}3. Or Pipe Directly in Your Terminal
npm test 2>&1 | npx tokenectomy-razorRelated MCP server: uacos
๐ 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.
Raw Terminal Crash (45,820 tokens + Leaked Secrets)
โ
โผ <0.2ms Local Rust DFA Engine
[Redact Passwords & Keys] โโโบ [Strip Third-Party Framework Frames] โโโบ [Isolate Root Cause]
โ
โผ
Clean Context (118 tokens โข Zero Secrets โข Sub-millisecond)๐ Before & After Comparison
โ Without Tokenectomy: AI Hallucinates & Burns 45,000 Tokens
TypeError: Cannot read properties of undefined (reading 'digest')
at Object.<anon> (/node_modules/next/bundle5.js:142:31)
at __webpack_require__ (/node_modules/next/bundle5.js:198:12)
at Object.execute (/node_modules/next/dev-server.js:412:19)
at processTicksAndRejections (task_queues:95:5)
Database connection failed: postgresql://admin:super_secret_password@db.prod.internal:5432/primary
API key leaked: sk-ant-api03-abcdef1234567890abcdef1234567890
[... 480 internal dependency frames flooding your context window ...]What Claude does: Tries to understand
bundle5.js, suggests modifying your webpack bundle or adjusting Next.js internals, and eats a massive chunk of your context window. Leaks your database credentials to external logs.
โ With Tokenectomy: Clean Context & Instant Fix
// [Tokenectomy Surgery: 480 framework frames pruned (99.7%)]
// Source: src/components/Header.tsx:42
42 | const user = useSession( ;
| ^ Expected ')'
๐ก๏ธ [CONNECTION_STRING_REDACTED]
๐ก๏ธ [REDACTED_ANTHROPIC_KEY]What Claude does: Instantly identifies that line 42 in
Header.tsxis missing a closing parenthesis). Applies the exact 1-line fix in 2 seconds. Credentials redacted before transmission. 99.7% token reduction.
๐ฌ 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.
$ cargo test --release --test stress_benchmark -- --nocapture
=====================================================================================
๐งช TOKENECTOMY OSS VERIFIABLE HEAVY STRESS BENCHMARK (100% REPRODUCIBLE IN OSS)
Hardware: 10-Core / 12-Thread Intel Core i5-1235U | OS: Arch Linux | Kernel Telemetry Active
Initial Baseline Process Memory (VmRSS): 3.45 MB
=====================================================================================
๐ฅ [TEST 1/3] QUARTER-MILLION LINES LOG REDACTION TORTURE (250,000 LINES / 25MB+ BUFFER)
โโโ Buffer Size: 24.44 MB (250000 lines)
โโโ Redaction Latency: 471.05ms (51.9 MB/sec)
โโโ Line Throughput: 530,735 lines/sec
โโโ Peak Memory (VmRSS): 76.05 MB (Delta: +72.60 MB)
โโโ Status: โ
PASSED (100% of 250,000 lines sanitized, zero memory balloon)
๐ฅ [TEST 2/3] REDOS CATASTROPHIC BACKTRACKING TORTURE (50,000 CHARS PAYLOAD)
โโโ Attack Payload Size: 50,082 characters
โโโ Execution Latency: 1.165 ms
โโโ Status: โ
PASSED (Linear O(N) evaluation, ReDoS-resistant on tested payloads)
๐ฅ [TEST 3/3] HIGH-CONCURRENCY TORTURE (100 PARALLEL OS THREADS)
โโโ Thread Concurrency: 100 concurrent OS threads
โโโ Successful Operations: 100/100 (100.0%)
โโโ Total Elapsed: 11.31ms
โโโ Concurrency Throughput: 17,688 ops/sec
โโโ Final VmRSS: 78.99 MB
โโโ Status: โ
PASSED (Zero race condition, zero deadlock)
=====================================================================================
๐ TOKENECTOMY OSS STRESS BENCHMARK: 3/3 PASSED (100% GREEN)
Total Suite Duration: 580.83ms
Bounded Final VmRSS: 78.99 MB
=====================================================================================
test test_oss_heavy_stress_benchmark ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.58sBenchmark Target | Workload Under Test | Verified Measurement | Result |
Log Redaction Throughput | 250,000 lines (24.44 MB) enterprise dump with API keys & connection URIs | 530,735 lines/sec (471.0 ms, 51.9 MB/s) | Pass |
ReDoS Resilience | 50,000-character pathological backtracking regex payload | 1.16 ms (Deterministic Linear $O(N)$ DFA Evaluation) | Pass |
Thread Concurrency | 100 concurrent OS threads executing simultaneous redaction | 17,688 ops/sec (100/100 completed in 11.31 ms) | Pass |
Memory Footprint | Peak Resident Memory during 250k-line continuous stress test | 76.05 MB VmRSS via | Pass |
Release Test Suite | Full integration test matrix across extractors, filters, and analyzers | 57 / 57 Verified Green (Zero panics, zero leaks) | Pass |
๐ก๏ธ Automated Redaction & Secret Sanitization Benchmark
Automated evaluation across 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.
1. Per-Category Precision, Recall & F1-Score
Secret Category | Ground Truth | Razor Recall | Razor F1 | Gitleaks Recall | Gitleaks F1 | Sanitization Advantage |
Anthropic Claude API Key ( | 1 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
AWS Access Key ID ( | 1 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
AWS Secret Access Key | 1 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
Database URI (PostgreSQL, MySQL, Redis, Mongo) | 4 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
Generic Passwords / Auth Secrets (YAML/JSON) | 3 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
GitHub Personal Access Token ( | 1 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
GitLab Personal Access Token ( | 1 | 100.0% | 100.0% | 100.0% | 100.0% | Parity (100% caught) |
HuggingFace API Token ( | 1 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
JSON Web Token (RFC 7519 / Truncated) | 2 | 100.0% | 100.0% | 100.0% | 100.0% | Parity (100% caught) |
npm Registry Access Token ( | 1 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
OpenAI API Key ( | 1 | 100.0% | 100.0% | 100.0% | 100.0% | Parity (100% caught) |
PEM Private RSA Key Block | 1 | 100.0% | 100.0% | 100.0% | 100.0% | Parity (100% caught) |
PyPI Package Upload Token ( | 1 | 100.0% | 100.0% | 100.0% | 100.0% | Parity (100% caught) |
SendGrid API Key ( | 1 | 100.0% | 100.0% | 0.0% | 0.0% | +100% Recall (M2M zero-leak) |
Slack Bot/User Token ( | 1 | 100.0% | 100.0% | 100.0% | 100.0% | Parity (100% caught) |
Stripe Live/Test Secret Key ( | 1 | 100.0% | 100.0% | 100.0% | 100.0% | Parity (100% caught) |
2. Head-to-Head Performance & Architectural Summary
Dimension | Tokenectomy Razor ( | Gitleaks v8.30.1 | Architectural Rationale |
Overall Secret Recall | 100.0% (22/22) | 36.4% (8/22) | Razor captures unquoted URIs, DB ports & AI keys missed by diff rules |
Overall Precision | 100.0% (0 False Positives) | 88.9% | Zero false triggers on compiler errors & minified traces |
Overall F1-Score | 100.0% | 51.6% | Comprehensive coverage engineered specifically for crash context |
Execution Engine | Zero-allocation Rust DFA ($O(N)$) | Go regex scanner + Git tree crawler | Sub-millisecond latency for agent streaming backtraces |
ReDoS Resilience | Deterministic Linear Time ($O(N)$) | Engine dependent | Non-backtracking DFA regex prevents catastrophic backtracking on tested dumps |
Sanitization Action | Inline token redaction ( | Warning log only (No scrub) | Directly sanitizes text before ingestion by LLM cortex |
3. Token Reduction & LLM Context Savings (tiktoken cl100k_base)
Metric | Measured Value | Operational Impact for AI Coding Agents |
Mean Token Reduction | 41.67% | Consistently shrinks raw crash trace token footprint |
Median Reduction (P50) | 42.95% | Typical credential and connection dump reduction |
90th Percentile (P90) | 61.42% | Eliminates long multi-line keys and credentials |
Min / Max Spread | 0.00% โ 81.36% | 0% on clean negative controls (zero distortion), up to 81.4% on leaks |
Total Tokens Preserved / Saved | 920 tokens (44.02% net) | Prevents context window saturation and reduces LLM billing |
๐ Quick Start
1. Model Context Protocol (MCP) Setup
Tokenectomy Razor operates natively over JSON-RPC 2.0 stdio, compliant with the official Model Context Protocol specification.
Cursor Composer
Add to .cursor/mcp.json in your workspace root:
{
"mcpServers": {
"tokenectomy": {
"command": "npx",
"args": ["-y", "tokenectomy-razor", "--mcp"]
}
}
}Claude Desktop
Add to claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"tokenectomy": {
"command": "npx",
"args": ["-y", "tokenectomy-razor", "--mcp"]
}
}
}Windsurf (Codeium)
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"tokenectomy": {
"command": "npx",
"args": ["-y", "tokenectomy-razor", "--mcp"]
}
}
}VS Code (Cline / Roo Code)
In Cline or Roo Code settings (cline_mcp_settings.json):
{
"mcpServers": {
"tokenectomy": {
"command": "npx",
"args": ["-y", "tokenectomy-razor", "--mcp"],
"disabled": false,
"autoApprove": ["get_error_context", "analyze_code"]
}
}
}Google Antigravity CLI
agy mcp add tokenectomy-razor -- npx -y tokenectomy-razor --mcp2. Standalone CLI & Terminal Piping
When debugging or piping terminal output directly:
# Pipe terminal test failures through the surgical redactor:
npm test 2>&1 | razor --scrub
# Sanitize a specific raw log file:
razor --scrub --file /var/log/app/error.log > sanitized.log
# Offline local air-gapped mode (zero external network calls):
cat failure.log | razor --scrub --local-only3. AI Gateway Reverse Proxy (--proxy)
Tokenectomy Razor can operate as a high-throughput local HTTP reverse proxy on 127.0.0.1:8080. It intercepts outbound prompt streams, performs real-time token excision and credential sanitization, and forwards clean requests upstream to OpenAI, Anthropic, or Ollama.
# Start local gateway proxy forwarding to OpenAI:
razor --proxy --proxy-bind 127.0.0.1:8080 --upstream-url https://api.openai.com/v1
# Start local gateway forwarding to Ollama:
razor --proxy --proxy-bind 127.0.0.1:8080 --upstream-url http://127.0.0.1:11434/v1Point any standard SDK client to the local proxy:
export OPENAI_BASE_URL="http://127.0.0.1:8080/v1"FinOps Economics Dashboard
Open http://127.0.0.1:8080/dashboard in any browser to monitor real-time token savings, dollar savings (blended LLM pricing), total requests, and active security redactions.
๐ ๏ธ Exposed MCP Tools
Tokenectomy Razor complies with Glama Grade A Tool Definition Quality Score (TDQS) with explicit parameter boundaries:
Tool Name | Capability Description |
| Performs trace surgery on error dumps, removes framework noise, redacts credentials, and extracts relevant local source context bounded to the workspace. |
| Performs static AST code analysis to detect resource leaks, unclosed handles, and syntax vulnerabilities with bounded execution limits and precise LSP UTF-16 coordinates. |
| Applies atomic file modifications with post-write language syntax verification ( |
| Queries Stack Exchange API for relevant error signatures using sanitized, redacted search terms. |
| Audits raw logs, traces, or prompt payloads for token bloat, framework noise, and credentials. Returns M2M telemetry, savings metrics, and context health grades. |
๐ Supported Polyglot Ecosystems
Language | Frameworks Supported | Excluded Framework Internals |
Rust | Tokio, Actix-web, Axum |
|
TypeScript / JS | Next.js, Express, NestJS, Vite |
|
Python | Django, FastAPI, Flask, PyTorch |
|
Golang | Gin, Fiber, Stdlib Panics |
|
Java / Kotlin | Spring Boot 3, Tomcat, Netty |
|
C / C++ | AddressSanitizer, GDB / LLDB |
|
C# (.NET) | ASP.NET Core, .NET Runtime |
|
Ruby on Rails | Rails, Sinatra, Bundler |
|
PHP | Laravel, Symfony |
|
๐ฆ Installation Options
Method 1: Instant via npx (Zero Toolchain Setup)
npx -y tokenectomy-razor --mcpMethod 2: Cargo (crates.io)
cargo install tokenectomyMethod 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-gnumacOS:
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)
docker pull ghcr.io/tokenectomy-labs/razor:latest
docker run -i ghcr.io/tokenectomy-labs/razor:latest --mcpโ๏ธ Edition Comparison
Capability | Razor (Community OSS) | Sentinel (Commercial Tier) |
Polyglot Stack Trace Surgery | Yes (4 Languages) | Yes (All 7 Languages) |
O(N) ReDoS-Safe Secret Redaction | Yes | Yes |
JSON-RPC 2.0 MCP Server | Yes | Yes |
AI Gateway Reverse Proxy ( | Yes | Yes |
SHA-256 Idempotency Cache (24h TTL) | Yes | Yes |
FinOps Metrics Dashboard | Yes | Yes |
Tree-sitter AST Syntax Healing | โ | Yes |
Anti-Hallucination Scope Guard | โ | Yes |
Automated Test Rollback (0 Dirty Diff) | โ | Yes |
Multi-File Atomic Transactions | โ | Yes |
Time Machine Undo Engine ( | โ | Yes |
Autonomous Healing State Machine | โ | Yes |
Need Enterprise AST Self-Healing? Explore the Sentinel Tier
๐บ๏ธ Roadmap & Milestones
Milestone / Capability | Status | Target |
Core Polyglot Log Surgery & $O(N)$ ReDoS Redaction | โ Complete | v1.0.0 |
AI Gateway Reverse Proxy ( | โ Complete | v1.1.0 |
Multi-arch Docker & GitHub Actions Marketplace Action | โ Complete | v1.1.3 |
Static AST Analysis Engine ( | โ Complete | v1.1.5 |
Glama.ai Tool Definition Quality Score (TDQS Grade A) | โ Complete | v1.1.5 |
Precompiled Standalone Binaries (Linux, macOS, Windows) | โ Complete | v1.1.6 |
Official MCP Registry Listing ( | โ Complete | v1.1.7 |
| โ Complete | v1.1.7 |
Java/Kotlin (Spring Boot 3) & C/C++ (ASan) Extractors | โ Complete | v1.2.0 |
C# (.NET) & Ruby on Rails Deep Stack Surgery | โ Complete | v1.2.2 |
User-defined custom redaction & noise rules ( | โ Complete | v1.2.2 |
Autonomous Context Health Audit ( | โ Complete | v1.2.2 |
Automated Redaction Benchmark & CI Gate | โ Complete | v1.2.2 |
Declarative Advisory M2M Control Plane ( | โ Complete | v1.3.0 |
Interactive Multi-Strategy Budgeting ( | โ Complete | v1.2.3 |
GitHub Actions OIDC Official Registry Publishing Gate | โ Complete | v1.2.3 |
| โ Complete | v1.2.4 |
Inline Dropped Frame Identities ( | โ Complete | v1.3.1 |
Content-Addressable Raw Log Cache & Verification Hash ( | โ Complete | v1.3.1 |
Native VS Code & JetBrains companion extensions | ๐ Planned | v1.4.0 |
Server-Sent Events (SSE) remote MCP transport | ๐ Planned | v1.4.0 |
๐ Security & Invariants
Zero-Knowledge Architecture: All parsing, filtering, and secret redaction execute on physical local hardware. No logs are ever transmitted to third-party telemetry servers.
Deterministic Linear-Time Pattern Matching: All pattern matchers utilize finite automaton evaluation (Rust non-backtracking DFA regex engine and Aho-Corasick) providing deterministic $O(N)$ linear time guarantees on tested adversarial inputs.
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.
๐ค Community & Resources
๐ Official Website
๐ Documentation
๐๏ธ System Architecture
๐ Changelog
๐ Security Policy
โ๏ธ Disclaimer & Liability
Available Tools
5 toolsanalyze_codeA
Performs static AST code analysis using Tree-sitter to detect resource leaks (such as unclosed file handles), security vulnerabilities, and logic flaws with bounded execution limits and precise LSP UTF-16 coordinates.
โข Side Effects: None. Strictly read-only analysis of in-memory code; does not execute code, spawn subprocesses, or write to disk. โข Auth & Permissions: None required. Fully offline, in-memory parser. โข Rate Limits: None. Bounded to 1MB max source size, 128 max AST depth, and 50,000 max node visits per call. โข Return Shape: Returns a JSON object containing 'language', 'findings_count', 'duration_ms' (latency metric), and 'findings' (array of objects with rule_id, message, severity, line [1-indexed], column [1-indexed UTF-16 code units], and remediation). โข Failure Modes: Returns findings: [] if the code contains no detected defects. Returns an error message if the language is unsupported or if source code exceeds the 1MB or 128 AST depth limits. โข When to use: Use proactively before committing or running code, or when reviewing Python files for unclosed file handles, resource leaks, or AST defects. โข When NOT to use: Do NOT use when you have an active runtime crash log (use get_error_context instead), and do NOT use to apply fixes automatically (use apply_code_patch instead). โข Prerequisites: Supported languages currently include Python ('python', 'py').
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Raw source code string to analyze. Must not exceed 1,000,000 bytes (1MB). Does not execute runtime code; strictly parsed via Tree-sitter AST. | |
| language | Yes | Programming language identifier for the code snippet. Case-insensitive. Supported values: 'python', 'py'. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description fully discloses side effects (None, read-only), auth requirements (None required, offline), rate limits (1MB, 128 depth, 50k node visits), return shape (JSON with language, findings_count, duration_ms, findings array), and failure modes (empty findings, error on unsupported language or exceeded limits). This is comprehensive and leaves nothing ambiguous.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is long but tightly organized in bullet points with clear headers. Every sentence adds value: side effects, auth, rate limits, return shape, failure modes, when/when-not, and prerequisites are all addressed. It front-loads the core purpose and then details specifics without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
This is a complex tool (static analysis, multiple detection categories, limits, error conditions) with no annotations or output schema. The description fully compensates by specifying the exact return structure, failure modes, prerequisites (supported languages), and constraints. An agent has everything needed to call it correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already offers 100% description coverage for both parameters, including constraints (size limit, case-insensitivity, supported values). The description adds little new meaning for parameters beyond what the schema provides; it reiterates the 1MB limit but that's behavioral context rather than parameter semantics. Baseline 3 applies because the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly states the verb 'Performs static AST code analysis using Tree-sitter' and the resource 'code', and specifies the exact detection categories (resource leaks, security vulnerabilities, logic flaws). It names alternatives in the 'When NOT to use' section (get_error_context, apply_code_patch), distinguishing this tool from siblings clearly.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides a dedicated 'When to use' section recommending proactive use before commits or for Python file review, and a 'When NOT to use' section explicitly naming two sibling tools (get_error_context and apply_code_patch) with conditions for each. This is explicit routing guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
apply_code_patchA
Applies an atomic, verified code edit to a specific file by substituting original_code with new_code, with automatic syntax validation and instant rollback on failure.
โข Side Effects: Modifies the target file on the local filesystem. If syntax checks pass, the file is overwritten with patched contents; if syntax validation fails, the file is immediately restored to its exact original state (zero dirty diff). โข Auth & Permissions: Requires write permissions for the target file on the host filesystem within the workspace boundary. Path traversal outside workspace root is blocked. โข Rate Limits: None. Local disk I/O. โข Return Shape: Returns a JSON object with 'status' ('success' or 'error'), 'file_path', 'lines_changed', 'verification' ('passed' or 'reverted'), and 'message'. โข Failure Modes: Fails and aborts without touching the file if file_path is not found, if original_code does not match the file content uniquely, or if the compiler/linter check fails after patch application. โข When to use: Use when you have finalized a bug fix or refactoring snippet and need safe, transactional application with zero risk of syntax corruption. โข When NOT to use: Do NOT use for speculative edits without prior diagnosis (use get_error_context first), and do NOT use for whole-file generation when only a small block changes. โข Prerequisites: Target file must exist and be within the current workspace directory.
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | Optional. When true, validates that the patch matches uniquely and checks syntax without writing any changes to disk. Defaults to false. | |
| new_code | Yes | The replacement code block to substitute in place of original_code. Must maintain correct language syntax and indentation matching the surrounding code. | |
| file_path | Yes | Target file path to modify. Can be relative to the workspace root or an absolute path located inside the workspace boundary. Path traversal outside the workspace is rejected. | |
| original_code | Yes | The exact character-for-character contiguous code block to be replaced, including exact leading indentation, newlines, and whitespace. Must match exactly one location in the file. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and covers it comprehensively: side effects, permissions, rate limits, return shape, rollback behavior, and failure modes. It explicitly states that the file is overwritten on success, restored on failure, and that path traversal is blocked. This is far beyond the typical threshold.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with clear sections (side effects, auth, rate limits, return shape, failure modes, usage, prerequisites) and front-loads the core function. It is slightly redundantโsyntax validation and rollback are stated both in the opening sentence and in side effects/failure modesโbut every section otherwise earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a mutation tool with 4 parameters, no annotations, and no output schema, the description is complete: it explains side effects, permissions, rate limits, return shape, failure modes, prerequisites, and when to use it. Nothing an agent needs to invoke this tool safely and correctly is missing. The return shape section compensates for the absent output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3, and the description does not add parameter-specific detail beyond the schema. It repeats some constraints already in the schema (exact match, syntax/indentation), so the description adds no meaningful new parameter semantics, but the schema itself is already rich.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb ('Applies') tied to a resource ('atomic, verified code edit to a specific file') and a clear mechanism (substituting original_code with new_code). It also names distinct behaviors like automatic syntax validation and rollback, which separates it from siblings focused on analysis or context retrieval.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description includes explicit 'When to use' and 'When NOT to use' sections, with conditions and an alternative ('use get_error_context first'). It clearly states when the tool is appropriate (finalized fix needing safe transactional application) and when it is not (speculative edits, whole-file generation), leaving no ambiguity.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
audit_context_healthA
Audits a raw error log, code snippet, or prompt payload for token bloat, framework noise, and credential leaks. Returns actionable M2M telemetry and savings recommendations without mutating workspace state.
โข Side Effects: None. Read-only in-memory evaluation. โข Auth & Permissions: None. โข Rate Limits: None. โข Return Shape: Returns JSON with 'raw_characters', 'estimated_raw_tokens', 'clean_characters', 'estimated_clean_tokens', 'tokens_saved', 'noise_reduction_pct', 'secrets_detected', 'health_grade' ('OPTIMAL', 'MODERATE_BLOAT', 'CRITICAL_BLOAT'), and 'recommendation'. โข When to use: Call proactively when dealing with large terminal dumps or before sending long logs to the LLM to verify context efficiency. โข When NOT to use: Do NOT use to apply file edits (use apply_code_patch) or query stack overflow.
| Name | Required | Description | Default |
|---|---|---|---|
| payload | Yes | Raw string, stack trace, or prompt payload to audit for token bloat and credentials. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It explicitly states side effects are none, it is read-only in-memory evaluation, requires no auth, has no rate limits, and details the exact return shape including fields and possible health grade values.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is structured with bullet points and front-loads the core purpose. Each section adds distinct value: side effects, auth, rate limits, return shape, when to use, and when not to use. Nothing feels redundant.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given one parameter, no output schema, and no annotations, the description fully compensates: it explains input expectations, return format, safety profile, and usage boundaries. An agent has everything needed to select and invoke the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% and the parameter description already explains that payload is a raw string, stack trace, or prompt payload. The tool description adds mild extra context about error logs and code snippets but does not fundamentally expand parameter semantics beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool audits raw error logs, code snippets, or prompt payloads for token bloat, framework noise, and credential leaks. It differentiates itself from siblings by explicitly saying it does not apply file edits or query Stack Overflow.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides explicit when-to-use guidance: proactively for large terminal dumps or before sending long logs to an LLM. It also gives clear when-not-to-use guidance, naming apply_code_patch and search_stack_overflow as alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_error_contextA
Extracts focused source code snippets and git diffs from a raw error log or stack trace, stripping framework noise (node_modules, site-packages) and redacting credentials.
โข Side Effects: None. Strictly read-only; does not modify workspace files, git state, or environment variables. โข Auth & Permissions: None required. Reads local filesystem within the current workspace boundary. โข Rate Limits: None. Runs entirely locally on native machine code. โข Return Shape: Returns a JSON object with 'sanitized_trace' (string without secrets/noise), 'source_frames' (array of objects with file, line, code_snippet), and 'git_diff' (string or null). โข Failure Modes: If source files referenced in the trace do not exist locally, omits code snippets for those frames while still returning the sanitized trace. Returns an error JSON on unreadable input. โข When to use: Call immediately when receiving a runtime exception, test failure, or compiler error to isolate the root cause before planning code fixes. โข When NOT to use: Do NOT use to search web solutions (use search_stack_overflow), do NOT use to modify files (use apply_code_patch), and do NOT use to statically lint clean code without an error log (use analyze_code). โข Prerequisites: Workspace directory must be accessible locally; git repository recommended for diff extraction.
| Name | Required | Description | Default |
|---|---|---|---|
| log | Yes | Raw error stack trace, compiler panic, or terminal stderr string to analyze (e.g. Python traceback, Node.js error, Rust panic). Must be non-empty UTF-8 text up to 1MB. Automatically sanitized of API keys, JWTs, and passwords. | |
| strategy | No | Context pruning and token budgeting strategy. Options: 'aggressive' (default: excises all framework internals and idle threads), 'conservative' (retains boundary transition frames), or 'lossless_compact' (preserves all frames, compressing only whitespace and redacting credentials). | |
| context_lines | No | Number of source code lines to retrieve above and below each detected error line. Integer between 0 and 100. Defaults to 10 lines. Larger values expand the context window but consume more LLM tokens. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With zero annotations provided, the description carries the full burden and discharges it completely: it declares no side effects (read-only, no workspace/git/env mutation), no auth required, no rate limits (local execution), the JSON return shape with field-level detail, and concrete failure modes (missing source files โ omitted snippets with sanitized trace still returned; unreadable input โ error JSON). It also lists prerequisites. Nothing about actual behavior is left to inference.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The definition is long but every bullet earns its place: purpose sentence up front, then tightly grouped bullets for side effects, auth, rate limits, return shape, failure modes, usage routing, and prerequisites. Since annotations and output schema are both absent, this length is justified rather than padded โ each section answers a distinct question an agent would have before invoking.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite having no annotations and no output schema, the description covers every category an agent needs: purpose, when/when-not with alternatives, behavioral safety profile, exact return structure (including nullable git_diff), failure modes, and prerequisites. A tool with 3 parameters, one enum, and nuanced output is fully specified for correct invocation with no unresolved questions.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so per the rubric the baseline is 3. The schema's own descriptions are thorough โ log includes format/size/sanitization semantics, strategy explains each enum value with its default, and context_lines gives range, default, and token tradeoff. The description's Return Shape section adds light contextual interplay (strategy affects output) but doesn't need to compensate for any schema gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Opens with a specific verb-and-resource statement: 'Extracts focused source code snippets and git diffs from a raw error log or stack trace.' The scope is precise (error logs/traces only, noise stripped, credentials redacted), and the 'When NOT to use' section names each sibling tool with its distinct purpose, so an agent can unambiguously tell this apart from search_stack_overflow, apply_code_patch, and analyze_code.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicit 'When to use' states the exact trigger conditions: 'Call immediately when receiving a runtime exception, test failure, or compiler error.' The 'When NOT to use' section gives exclusion criteria AND names the correct alternative for each (web search โ search_stack_overflow, file modification โ apply_code_patch, linting clean code โ analyze_code). This is the gold standard for routing guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_stack_overflowA
Queries the public Stack Overflow / Stack Exchange API for verified programming solutions and discussions matching an error signature.
โข Side Effects: None. Strictly read-only network search; does not mutate local files or repository state. โข Auth & Permissions: No API key required for standard rate-limited anonymous queries. โข Rate Limits: Subject to public Stack Exchange API rate limits (~300 requests/day per IP). Results are cached locally when possible. โข Return Shape: Returns a JSON object containing 'query', 'total_results', and 'results' (array of objects with title, url, score, is_answered, answer_count, and answer excerpt). โข Failure Modes: Returns empty results array if no matching questions exist. Returns an error message if network connectivity fails or API quota is exhausted. โข When to use: Use when local code context from get_error_context is insufficient and external community patterns, known library bugs, or API migration examples are needed. โข When NOT to use: Do NOT use with raw un-sanitized logs containing private tokens or file paths, do NOT use for local codebase inspection (use get_error_context), and do NOT use to edit code (use apply_code_patch). โข Prerequisites: Outbound HTTP internet access to api.stackexchange.com.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Targeted search query string (e.g. 'ValueError: unsupported operand type(s) for +: int and str'). Must be free of project-specific paths, private tokens, or proprietary variable names. 3 to 150 characters recommended. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and covers side effects (strictly read-only), auth requirements (no API key), rate limits, return shape, and failure modes. This is precisely the behavioral context an agent needs before invoking an external network tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with the core purpose and then organized into clearly labeled bullet sections. Every bullet conveys necessary operational guidance, and there is no filler or redundant restatement of the tool name.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that there is no output schema and the tool depends on external network behavior, the description fully covers return shape, failure modes, rate limits, and prerequisites. An agent has all the information needed to decide whether and how to call this tool safely and correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema already documents the query parameter at 100% coverage, so the baseline is 3. The description adds valuable semantics beyond the schema by advising that the query must be free of project-specific paths/tokens and recommending a 3-150 character length, which helps the agent formulate a valid and safe query.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: 'Queries the public Stack Overflow / Stack Exchange API' for solutions matching an error signature. It also differentiates from siblings by referencing local context tools and code-editing tools, so an agent can clearly tell what this tool is for.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description includes explicit 'When to use' and 'When NOT to use' sections naming sibling tools get_error_context and apply_code_patch as alternatives. It specifies the conditions under which this tool is preferred and when it must be avoided, leaving no room for inference.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v1.1.8- Added
analyze_code - Changed
apply_code_patch4 fields changed- added
Input schema / properties / dry_runAdded value: +{ + "description": "Optional. When true, validates that the patch matches uniquely and checks syntax without writing any changes to disk. Defaults to false.", + "type": "boolean" +} - changed
Input schema / properties / file_path / descriptionPrevious value: -"Absolute path to the file"New value: +"Target file path to modify. Can be relative to the workspace root or an absolute path located inside the workspace boundary. Path traversal outside the workspace is rejected." - changed
Input schema / properties / new_code / descriptionPrevious value: -"The new code block"New value: +"The replacement code block to substitute in place of original_code. Must maintain correct language syntax and indentation matching the surrounding code." - changed
Input schema / properties / original_code / descriptionPrevious value: -"The exact code block to be replaced"New value: +"The exact character-for-character contiguous code block to be replaced, including exact leading indentation, newlines, and whitespace. Must match exactly one location in the file."
- Added
audit_context_health - Changed
get_error_context3 fields changed- added
Input schema / properties / context_lines / descriptionAdded value: +"Number of source code lines to retrieve above and below each detected error line. Integer between 0 and 100. Defaults to 10 lines. Larger values expand the context window but consume more LLM tokens." - added
Input schema / properties / log / descriptionAdded value: +"Raw error stack trace, compiler panic, or terminal stderr string to analyze (e.g. Python traceback, Node.js error, Rust panic). Must be non-empty UTF-8 text up to 1MB. Automatically sanitized of API keys, JWTs, and passwords." - added
Input schema / properties / strategyAdded value: +{ + "description": "Context pruning and token budgeting strategy. Options: 'aggressive' (default: excises all framework internals and idle threads), 'conservative' (retains boundary transition frames), or 'lossless_compact' (preserves all frames, compressing only whitespace and redacting credentials).", + "enum": [ + "aggressive", + "conservative", + "lossless_compact" + ], + "type": "string" +}
- Changed
search_stack_overflow1 field changed- added
Input schema / properties / query / descriptionAdded value: +"Targeted search query string (e.g. 'ValueError: unsupported operand type(s) for +: int and str'). Must be free of project-specific paths, private tokens, or proprietary variable names. 3 to 150 characters recommended."
3 tool updates
v0.1.0- First observed
apply_code_patch - First observed
get_error_context - First observed
search_stack_overflow
TDQS
Scored across 5 tools
get_error_context and audit_context_health overlap heavily: both consume raw error logs, strip framework noise, and detect credentials, differing mainly in output metrics vs. source extraction. The other tools are distinct, but these two create real ambiguity about which to call for a given error log.
All tool names follow a consistent verb_noun snake_case pattern: get_error_context, search_stack_overflow, apply_code_patch, analyze_code, audit_context_health. The verbs clearly describe the action and the nouns identify the target.
Five tools is well-scoped for an error-diagnosis-and-patching workflow. Each tool serves a distinct stage (extract context, search external knowledge, analyze statically, apply patch, audit token health) without redundant or excessive surface area.
The core flow from error context to search to analysis to patching is present, but there is no tool to verify behavior after a patch or revert a syntactically valid but logically incorrect change. Additionally, audit_context_health reports token savings but does not return a cleaned/trimmed payload, leaving a notable gap for a context-optimization-focused server.
Maintenance
Related MCP Connectors
Nifty's MCP server โ exposes tasks, projects, messages, and files as tools for AI agents.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA lightning-fast, language-agnostic code analysis MCP (Model Context Protocol) server built in Rust9-
- AlicenseNot gradedqualityBmaintenanceLocal-first code intelligence and safety layer for AI coding agents. MCP server exposes dependency graph, impact analysis, and AST-compressed repo context, backed by typed local memory, patch-scope safety gates, and git-independent transaction rollback.1MIT
- FlicenseNot gradedqualityAmaintenanceLocal MCP server that lets your AI coding agent query its own cross-tool project history - file/command freshness, past test failures, cost & token spend, cache status, and session handoff - over stdio, 100% local, no telemetry.46-
- AlicenseNot gradedqualityAmaintenanceLocal-first MCP server that provides project context, verification gates, and structured tools for coding agents to discover knowledge, run diagnostics, and execute allowlisted commands within a repository.24 npmMIT