context-mode  by mksglu

AI context optimization for large tool outputs

Created 1 month ago
7,000 stars

Top 7.3% on SourcePulse

GitHubView on GitHub
Project Summary

This project addresses the significant challenge of large tool outputs consuming valuable context windows in AI agents like Claude Code. It provides an MCP server that compresses these outputs, reducing context usage by up to 99%, thereby extending the effective session length and improving AI agent efficiency and capability.

How It Works

Inspired by Cloudflare's Code Mode, Context Mode acts as an intermediary MCP server. It processes tool outputs within isolated sandboxes, capturing only essential summaries or relevant snippets instead of raw data. This approach drastically reduces the data sent to the AI model, saving significant context window space and enabling more complex operations within a single session. The system supports eleven language runtimes and utilizes advanced techniques like BM25 ranking and multi-layer fuzzy search for efficient knowledge retrieval.

Quick Start & Requirements

  • Primary Install (Claude Code Plugin):
    /plugin marketplace add mksglu/claude-context-mode
    /plugin install context-mode@claude-context-mode
    
    Followed by restarting Claude Code.
  • MCP-only Install:
    claude mcp add context-mode -- npx -y context-mode
    
  • Local Development:
    claude --plugin-dir ./path/to/context-mode
    
  • Prerequisites: Node.js 18+
  • Optional: Bun (for 3-5x faster JS/TS execution)
  • Setup Time/Footprint: Not explicitly detailed, but installation appears straightforward via plugin or npm.

Highlighted Details

  • Achieves up to 99% context reduction, transforming 315 KB of raw output into 5.4 KB.
  • Sandboxed execution environments support 11 languages (JS, TS, Python, Shell, Ruby, Go, Rust, PHP, Perl, R, Elixir) with auto-detection for Bun for faster JS/TS execution.
  • Features a multi-layer search fallback (Porter stemming, trigram substring, Levenshtein distance) for robust querying of indexed content, including smart snippet extraction.
  • Includes diagnostic and upgrade commands (/context-mode:stats, /context-mode:doctor, /context-mode:upgrade) for session monitoring and maintenance.

Maintenance & Community

The project welcomes contributions, with details provided in CONTRIBUTING.md. No specific community links (Discord/Slack) or notable sponsors/partnerships are mentioned in the provided text.

Licensing & Compatibility

  • License: MIT
  • Compatibility: Permissive MIT license generally allows for commercial use and integration into closed-source projects.

Limitations & Caveats

Primarily designed for use with Claude Code and MCP-compatible environments. The "MCP-only install" option omits hooks and slash commands, limiting functionality compared to the full plugin installation.

Health Check
Last Commit

5 hours ago

Responsiveness

Inactive

Pull Requests (30d)
52
Issues (30d)
74
Star History
3,053 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.