Local-first code knowledge graph MCP server
Project description
Code GraphRAG MCP Server
A Model Context Protocol server for source-code introspection. It keeps a local-first knowledge graph for your repositories: Tree-sitter derived symbols and relations, AST-aligned chunks, EmbeddingGemma vectors stored in sqlite-vec, and graph traversal through bfsvtab. Wheels ship the native extensions, so the server starts instantly with uvx.
Features
- Hybrid retrieval combining vector search and breadth-first graph expansion over code relations
- Live repository sync via filesystem watcher and job queue
- Deterministic provenance for every symbol, relation, and chunk
- Bundled sqlite-vec and bfsvtab binaries—no manual compilation required
Installation
uvx code-graph-rag-mcp serve --config /workspace/config.yaml
MCP manifest example
{
"mcpServers": {
"code-graph": {
"command": "uvx",
"args": ["code-graph-rag-mcp", "serve", "--config", "/workspace/config.yaml"],
"env": {
"CODE_GRAPH_RAG_WATCH_DIR": "/workspace/repo",
"CODE_GRAPH_RAG_DB_PATH": "/workspace/data/code.sqlite"
}
}
}
}
This manifest block works for Claude Desktop (claude_desktop_config.json), Cursor (~/.cursor/mcp.json), or any other MCP host.
Configuration
Minimal config.yaml
watch:
dir: "/workspace/repo"
database:
sqlite_path: "/workspace/data/code.sqlite"
Environment overrides
| Variable | Description |
|---|---|
CODE_GRAPH_RAG_CONFIG |
Alternate path to the YAML config. |
CODE_GRAPH_RAG_WATCH_DIR |
Override repository directory to watch. |
CODE_GRAPH_RAG_WATCH_DEBOUNCE_MS |
Debounce delay (ms) for watcher events. |
CODE_GRAPH_RAG_DB_PATH |
Override SQLite database location. |
CODE_GRAPH_RAG_EXTENSIONS_DIR |
Directory containing custom sqlite-vec/bfsvtab binaries. |
CODE_GRAPH_RAG_SQLITE_VEC / CODE_GRAPH_RAG_BFSVTAB |
Explicit extension paths. |
CODE_GRAPH_RAG_RETRIEVAL_K |
Default semantic top-k. |
CODE_GRAPH_RAG_RETRIEVAL_HOPS |
Graph expansion hop count. |
CODE_GRAPH_RAG_EMBED_MODEL / CODE_GRAPH_RAG_EMBED_ENDPOINT |
Embedding model overrides. |
Available tools
| Tool | Purpose |
|---|---|
ingest_repo |
Full ingest or reingest of the repository. |
refresh_path |
Reindex a single file. |
purge_path |
Remove a file and its graph artifacts. |
hybrid_search |
Semantic + graph search returning chunks with BFS neighbors. |
symbol_lookup |
Fuzzy lookup of symbols by name. |
explain_symbol |
Show metadata, owning chunk, and outgoing edges for a node ID. |
status |
Report ingest counts and extension readiness. |
Architecture overview
- Watcher → queue –
watchfilesmonitors the repo and enqueues jobs on create/modify/delete. - Indexer – Tree-sitter adapters extract symbols/relations; the chunker builds AST-aligned snippets; EmbeddingGemma generates embeddings.
- SQLite – files, nodes, edges, chunks, and vectors live in sqlite-vec tables; bfsvtab enables efficient BFS traversal.
- MCP surface – tools expose ingest, search, and introspection over stdio to any MCP client.
Example workflow
- Start the server with
uvxand point it at your repository. - Call
ingest_repoto seed the database. - Use
hybrid_searchto find relevant code; responses include semantic scores plus graph neighbors. - Inspect specific nodes with
explain_symbolorsymbol_lookup. - Work normally—the watcher reindexes files as they change.
Development
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pytest
Rebuild the bundled sqlite-vec/bfsvtab binaries (only if needed) with:
python scripts/build_sqlite_extensions.py
Support
- File issues or feature requests in this repository.
- Learn more about MCP at modelcontextprotocol.io.
- License: MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_graph_rag_mcp-0.1.2.tar.gz.
File metadata
- Download URL: code_graph_rag_mcp-0.1.2.tar.gz
- Upload date:
- Size: 95.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dc3fffd81f9a18b89a59c3a846e5676b017048235a74bb90aed0b79254d433e
|
|
| MD5 |
e84fb473796d5719b62111fe1f1a94ca
|
|
| BLAKE2b-256 |
ae20376db8320c4a28b1043cf458df15c220ad11f24fe25f4df0a14b27f96e95
|
File details
Details for the file code_graph_rag_mcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: code_graph_rag_mcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 105.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
783fcad1549ab469c9cba01e7efc0c72247d542b0a3d0fa1b5aa7be054159405
|
|
| MD5 |
f4ac6d5a0741634680b9668d9924db9f
|
|
| BLAKE2b-256 |
e8b2f414633cb3b0ad2b278f679bd3a134ef00170601507fe42a50bc1dd0059d
|