Skip to main content
Glama
ContextCut
by j-straber

ContextCut MCP Server (v1.3.0 - Polyglot & ROI Analytics)

Website License: ISC MCP Python Node

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."""
    pass

Real-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 dashboard
  • Live 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.jsonl anytime 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


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 init

This 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: *.py or *.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 tools
check_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

    A3.9/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: pruning code, checking license status, and generating savings reports. There is no overlap or ambiguity between them.

    Naming Consistency4/5

    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.

    Tool Count4/5

    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.

    Completeness3/5

    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

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Provides 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.
      9
      4
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables LLMs to efficiently read, write, and refactor code using precise AST-based operations, reducing token usage and context window waste.
      25
      318 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI coding agents to efficiently analyze codebases by extracting AST skeletons, reducing token usage while preserving type contracts and interfaces.
      2 npm
      1
      MIT