Graph Context

by yuqiaohan95

347 downloads
Not rated
GitHub

About

MCP server for intelligent code context — 87%+ token savings, zero resource overhead.

Details

Author
yuqiaohan95
Downloads
347
Categories
Other

- AST call graph for precise cross‑file dependency resolution
- BM25 ranking with self‑evolving rules engine
- Dynamic tool loading — only 2 tools at startup (~270 tokens)
- MVCC snapshots for read‑write isolation in multi‑agent setups
- Zero external dependencies: pure CPU, no GPU, no network calls
- Built‑in Chinese‑English synonym mapping for cross‑language queries

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Graph Context
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install with pip install graph-context (or graph-context[full] for Chinese tokenization and file watching). Run as an MCP server with the command graph-context, optionally setting environment variables like PROJECT_ROOT, MCP_MAX_TOKENS, and MCP_TOP_K. Integrate with Claude Desktop, Cursor, or Cline via a JSON configuration pointing to the command. Programmatic usage is also available via the VibeCodingEngine class.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "graph context": {
            "graph-context": {
                "command": "python",
                "args": [
                    "-m",
                    "tests.experiment"
                ]
            }
        }
    }
}

McpServers

{
    "graph-context": {
        "command": "python",
        "args": [
            "-m",
            "tests.experiment"
        ]
    }
}

Graph Context

MCP server for intelligent code context — 87%+ token savings, zero resource overhead.

An MCP context engine built on AST call graphs + BM25 ranking, delivering precise code context retrieval for AI coding assistants. No GPU, no external services, pure Python, ready to use out of the box.

中文文档

Why Graph Context

| Metric | Without MCP (full context) | With MCP (Graph Context) |
|--------|---------------------------|-------------------------|
| Per-turn token usage | Entire codebase | Only relevant chunks (precision retrieval) |
| 10-turn conversation | Linear growth, triggers forgetting | Stable at ~2,000 tokens/turn |
| Multi-agent collaboration | Each agent reloads context independently | MVCC snapshots, shared index, read-write isolation |
| Token savings | — | 87%+ (single-agent & multi-agent) |
| Resource consumption | — | Zero (pure CPU, no model calls) |

How It Works

User query → Synonym expansion (CN/EN) → BM25 ranking (AST call graph weighted)
                                              ↓
                                        IDF noise filtering → Coarse-to-fine (class → method drill-down)
                                              ↓
                                        Rule boost (self-evolving rules engine)
                                              ↓
                                        Return top-k precise chunks

Three-layer retrieval, progressively refined:

1. AST Call Graph — Function-to-function precise mapping, not token co-occurrence. Cross-file dependencies in one hop.
2. BM25 Ranking — Standard information retrieval scoring, combined with chunk type weights (function > class > imports).
3. Self-evolving Rules — New rules enter observation period first, decay based on accuracy (not time), low-performing rules auto-pruned.

Quick Start

Install

```bash
pip install graph-context

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.