ContextCut
ContextCut is an MCP server that prunes code to its essential interfaces to reduce token usage and cost for LLM coding agents.
Prune source code with
prune_code_context: Accepts a file path, directory path, or rawcode_contentstring and returns AST-stripped stubs preserving signatures, types, interfaces, and docstrings.Support Python, TypeScript, and JavaScript with optional language hints and glob filtering for directory scans.
Choose pruning depth:
interfaces_onlykeeps docstrings;minimalstrips them for maximum compression.Validate licensing with
check_license: Check Free vs Pro tier status; TypeScript/JavaScript pruning requires a Pro license key.Generate ROI reports with
get_savings_report: Aggregate token and cost savings over daily, weekly, monthly, or all-time intervals in Markdown or JSON.Track persistent local analytics: Savings are recorded to a private append-only ledger at
~/.contextcut/history.jsonl.Provide MCP resources: Expose on-demand pruned stubs via
contextcut://pruned/{filepath}.Offer an architecture-analysis prompt:
analyze_architectureguides agents to inspect high-level code structure without implementation noise.Include CLI utilities: Install agent integration (
contextcut-mcp install), clipboard quick-trimming (clip), project initialization/autopilot rules (init), savings reports (report), and an interactive dashboard (dashboard).
Allows pruning JavaScript source files by removing function and method bodies in favor of stubs while keeping signatures and docstrings intact.
Allows pruning Python source files by stripping function and method bodies into stubs while preserving signatures, type hints, dataclasses, and docstrings for reduced context usage.
Allows pruning TypeScript source files by reducing implementation bodies to stubs while retaining interfaces, signatures, type annotations, and docstrings.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ContextCut Prune the src folder to stubs and show token savings"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ContextCut MCP Server (v1.3.0 - Polyglot & ROI Analytics)
ContextCut is a local-first, AST-based code context pruner for LLMs and AI coding agents (Claude Desktop, Cursor, Antigravity, Roo Code) via the Model Context Protocol (MCP).
It parses Python and TypeScript/JavaScript files and directories, stripping out internal function and method bodies down to stubs while retaining 100% of signatures, interfaces, type hints, dataclasses, and docstrings.
πΈ Verified Live in Claude Desktop
TypeScript AST Pruning (48.1% Token Reduction) | Python Architecture Analysis (55.2% Token Reduction) |
Related MCP server: mcp-agent-opt
β‘ What it Does
# Before ContextCut (~350 tokens of internal loops, regex, and logging):
def process_data(uri: str) -> dict:
"""Loads and normalizes schema."""
if not uri:
raise ValueError("Invalid")
# ... 40 lines of heavy implementation logic ...
return result
# After ContextCut (~35 tokens, 90% reduction):
def process_data(uri: str) -> dict:
"""Loads and normalizes schema."""
passReal-Time Telemetry Header
Every pruned output automatically injects an instant token and cost savings summary:
"""
[ContextCut Telemetry]
----------------------------------------
Files Pruned: 3
Original Size: 14,250 chars (~3,562 tokens)
Pruned Size: 3,810 chars (~952 tokens)
Token Savings: 73.3% reduction (~2,610 tokens saved)
Est. Cost Saved: $0.0078 per prompt (@ $3.00/1M tokens)
----------------------------------------
"""π Persistent ROI Analytics & Reporting (New in v1.3.0)
ContextCut automatically records cumulative token and dollar savings to a private, local append-only ledger at ~/.contextcut/history.jsonl.
100% Local & Private: Only anonymous token counts and timestamps are logged. No source code or prompts ever leave your machine.
Quantifiable ROI: Generate aggregated cost-benefit reports on any interval (daily, weekly, monthly, or all-time).
Terminal CLI Report:
# View all-time savings report
node build/index.js report
# View weekly report
node build/index.js report --interval=weekly
# Raw JSON output for custom dashboards
node build/index.js report --interval=monthly --jsonπ Visual Interactive Dashboard (Web UI & CLI):
Launch an interactive visual dashboard in your browser to visualize savings over time, track top pruned files, and export executive PDF reports:
# Launch offline visual dashboard in your default browser:
node build/index.js dashboard
# Or when installed via npm:
npx contextcut-mcp dashboardLive Dynamic Sync: Automatically refreshes live as your AI coding agents prune files in real-time.
Executive PDF Export: One-click print-ready formatted report for leadership and CFO reviews.
100% Client-Side Web Viewer: Drag-and-drop your
~/.contextcut/history.jsonlanytime at π 5tra83rstudios.com/viewer (zero telemetry leaves your machine).
π Quick Start
β‘ 1. 1-Click Automated Machine Setup (Zero JSON Editing)
Connect ContextCut to all your installed AI desktop apps in 2 seconds:
# Automatically finds Claude Desktop, Cursor, Antigravity, and Windsurf:
npx contextcut-mcp installβοΈ 2. Clipboard Quick-Trimmer (For Web ChatGPT & Gemini)
Using ChatGPT or Gemini in your web browser? Prevent the dreaded 5-hour usage limit lockout:
# 1. Copy bloated code or functions to clipboard (Cmd+C)
# 2. Run the quick-trimmer:
npx contextcut-mcp clip
# 3. Paste trimmed interfaces directly into ChatGPT / Gemini (Cmd+V)!Or trim code 100% online directly in your browser: π 5tra83rstudios.com/viewer/#trimmer
3. Enable Agent Autopilot Mode (Recommended)
Never forget to use ContextCut again. Run this 1-click command inside any project directory:
node /ABSOLUTE/PATH/TO/contextcut-mcp/build/index.js init
# Or when installed via npm:
npx contextcut-mcp initThis automatically writes the Autopilot rule to your .cursorrules and CLAUDE.md:
# ContextCut Agent Autopilot Rule
# -----------------------------------------------------------------------------
# When exploring, surveying, or analyzing code architecture, class definitions,
# or public API interfaces, ALWAYS invoke the `prune_code_context` MCP tool first
# to eliminate token bloat. Only inspect raw, unpruned function bodies if you are
# explicitly modifying the internal implementation of that specific function.
# -----------------------------------------------------------------------------Your agents in Cursor, Claude Desktop, and Antigravity will now automatically route code through ContextCut before analyzing architecture, slashing token consumption on autopilot!
π Available Tools, Prompts & Resources
Tool: prune_code_context
target_path: Path to a source file or directory (Python, TypeScript, or JavaScript).code_content: Optional raw code string to prune directly in-memory.language: Optional language hint ("python","typescript", or"javascript").glob_pattern: Optional filter for directory scans (default:*.pyor*.ts).depth:"interfaces_only"(default): Preserves docstrings, signatures, and types."minimal": Strips docstrings for maximum token compression.
Tool: get_savings_report
Generates an aggregated cost-benefit ROI report over a specified interval.
interval:"daily","weekly","monthly", or"all_time"(default:"all_time").format:"markdown"(default) or"json".
Tool: check_license
Validates license tier status (Free Core vs Pro Polyglot).
Prompt: analyze_architecture
Guides your AI agent to inspect a repository's high-level architecture using pruned interface stubs without getting lost in implementation noise.
Resource: contextcut://pruned/{filepath}
Exposes on-demand pruned stubs as native MCP readable resources.
π§ͺ Testing
Run the automated test suite:
npm test
# Or: python3 -m unittest discover -s testsπΌ Business & Monetization
See MONETIZATION.md for the complete Go-To-Market roadmap, Lemon Squeezy payment integration, and community registry launch guide.
π License
Β© 2026 5tra83r Studios. All rights reserved.
Available Tools
3 toolscheck_licenseA
Checks ContextCut license tier status (Free vs Pro).
Inputs: license_key.
get_savings_reportA
Generates an aggregated cost-benefit and token savings ROI report over a specified interval (daily, weekly, monthly, or all_time) based on persistent local history.
Inputs: format, interval.
prune_code_contextA
Reads a source file or directory (or raw string) and returns an AST-pruned version containing only signatures, types, interfaces, and docstrings. Replaces function/method bodies with stubs to drastically cut token consumption and latency. Python pruning is free; TypeScript/JavaScript pruning is a Pro feature.
Inputs: depth, language, license_key, target_path, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: pruning code, checking license status, and generating savings reports. There is no overlap or ambiguity between them.
Tool names follow a consistent verb_noun pattern (prune_code_context, check_license, get_savings_report). Minor deviation: 'prune_code_context' uses a compound noun while the others use simpler nouns, but the pattern is still predictable.
Three tools is a reasonable, focused set for a utility server with a narrow purpose. It is slightly minimal but each tool serves a distinct function and the scope is appropriately narrow.
The core pruning workflow is covered, and license checking plus reporting support the main use case. However, there is no tool for managing history, configuring pruning options, or handling Pro feature access beyond checking license status, which leaves some minor gaps.
Related MCP Connectors
AST context pruner, token budget planner, fuzzy patcher, and code solvers.
Codebase intelligence for AI agents β dead code, blast radius, ownership.
Code-map tools for AI agents: see a repo's structure first, then edit only what matters.
Codebase intelligence for AI coding agents: graph, git history, docs, decisions, code health.
Related MCP Servers
- AlicenseAqualityDmaintenanceReduces Claude's context window costs by automatically summarizing inactive files to their public interfaces using AST parsing, keeping only the full contents of the currently active file.6MIT
- AlicenseAqualityDmaintenanceProvides code-aware context compression by stripping comments, docstrings, and whitespace while maintaining full logic fidelity for AI agents. It features tools for architectural mapping, symbol searching, and token-budgeted multi-file reading.94MIT
- AlicenseBqualityBmaintenanceEnables LLMs to efficiently read, write, and refactor code using precise AST-based operations, reducing token usage and context window waste.25318 npm3MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to efficiently analyze codebases by extracting AST skeletons, reducing token usage while preserving type contracts and interfaces.2 npm1MIT