Skip to main content

Universal token optimization, intelligent context management, and codebase navigation for AI coding assistants, IDEs, and MCP servers.

Project description

RootMatrix 🧠

Universal token optimization, intelligent context management, and codebase navigation for AI IDEs and MCP servers.

RootMatrix (formerly Context-Gate) is a Model Context Protocol (MCP) server that acts as a "Second Brain" for AI agents (Cursor, Windsurf, Trae, Claude Code). It intercepts file read requests and enforces a strict progressive context strategy, forcing the AI to navigate codebases surgically instead of blindly reading massive raw files.

This prevents context window exhaustion, drastically speeds up AI generation, and eliminates hallucination caused by context noise.


🚀 Installation

Install the package via pip:

pip install rootmatrix

💻 Quick Start & IDE Integration

RootMatrix integrates seamlessly into your favorite AI IDEs with a single command.

Navigate to your project directory and run:

# 1. Initialize the project context constraints
rootmatrix init-project

# 2. Inject the RootMatrix MCP Server into your IDE
rootmatrix init --ide cursor    # Or: windsurf, trae, claude-desktop

Once you restart your IDE, your AI agent will automatically have access to all RootMatrix optimization tools.


🛠️ Key Functionality & MCP Tools

When connected, AI agents automatically use these surgical tools instead of naive file reads:

  • get_project_map: Generates a structural tree representation of the workspace, automatically filtering out noise (node_modules, venv, etc.).
  • read_optimized_file: The default file inspection tool. Uses AST (Tree-sitter and Python native) to strip out inner implementation logic, leaving only imports, classes, signatures, and docstrings. (Slashes a 4k-token file down to ~400 tokens).
  • read_function: Surgically extracts and returns only the code body of a specific function, keeping the rest of the file out of context.
  • search_codebase: Local semantic RAG search powered by ChromaDB. Helps the AI find exact snippets using natural language.
  • find_references: Locates global occurrences of a specific function or class across the workspace to map dependencies safely.
  • get_context_budget: Enforces a strict daily token limit.

🔗 Manual MCP Integration

If you want to manually configure the MCP server for an IDE or AI agent instead of using the CLI, you can add the following configuration to your client's MCP settings file (e.g., mcp.json or cline_mcp_settings.json):

// ~/.cursor/mcp.json
{
  "mcpServers": {
    "rootmatrix": {
      "command": "python",
      "args": ["-m", "rootmatrix.server"]
    }
  }
}
// PROJECT_FOLDER/.vscode/mcp.json
{
  "mcpServers": {
    "rootmatrix": {
      "type": "stdio",
      "command": "python",
      "args": [
        "-m",
        "rootmatrix.server"
      ]
    }
  }
}

Ensure that the Python environment where rootmatrix is installed is accessible in your system's PATH, or provide the absolute path to your Python executable in the "command" field.


⚙️ Requirements

  • Python 3.10+

📄 License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rootmatrix-0.1.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rootmatrix-0.1.0-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file rootmatrix-0.1.0.tar.gz.

File metadata

  • Download URL: rootmatrix-0.1.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for rootmatrix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f9546104bd17f50351139e18083b3285f1120c5e87610b7fa8273dc7d93969a3
MD5 b0214a2d133480d1ec5013df687f328e
BLAKE2b-256 ce788abd7de9273200097e8e00f539be3a7eb9544d5feb5696c6c0424b45578f

See more details on using hashes here.

File details

Details for the file rootmatrix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rootmatrix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for rootmatrix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c17e381af0875793fa86dbf02b336bcce271e88615f1f66c82ae2e6a367168cd
MD5 5ac7b031eb71c72bf49da1306313dd34
BLAKE2b-256 6b43650bceb5a61bb64c169ab266c04a90d90148f201bf05c248ceace074d0c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page