Code-Graph-RAG
Lets your AI agent index a multi-language codebase into a knowledge graph, then query and edit it in plain English.
5.3k stars on GitHubby vitali87License MITUpdated 18 days ago
How to install
This MCP is local: it runs on your computer.
It works in apps installed on your PC (Claude Desktop, Claude Code, Cursor, VS Codeβ¦). Choose your app:
Paste in the terminal:
claude mcp add code-graph-rag -- uvx code-graph-rag mcp-server
What to fill in
| Name | What it is | Required |
|---|---|---|
ORCHESTRATOR_PROVIDER | LLM provider for the orchestrator agent (openai, anthropic, google, azure, cohere, ollama) | No |
ORCHESTRATOR_MODEL | Model name for the orchestrator agent | No |
ORCHESTRATOR_API_KEY | API key for the orchestrator LLM provider (not needed for the default local ollama provider) | No |
CYPHER_PROVIDER | LLM provider for Cypher query generation (openai, anthropic, google, azure, cohere, ollama) | No |
CYPHER_MODEL | Model name for Cypher query generation | No |
CYPHER_API_KEY | API key for the Cypher LLM provider (not needed for the default local ollama provider) | No |
MEMGRAPH_HOST | Hostname of the Memgraph database | No |
MEMGRAPH_PORT | Port of the Memgraph database | No |
TARGET_REPO_PATH | Path to the repository to analyze (auto-detected from working directory if not set) | No |
Ready! Now test it
Restart the app and paste one of these requests in the chat:
Index this repository and then tell me how the login flow works.
Find dead code in this project.
What it is
Code-Graph-RAG reads every source file in a repository with Tree-sitter and builds a graph of functions, classes, methods and how they relate. You can then ask questions, fetch the source of any function, edit code with a diff preview and find dead code. It runs as an MCP server for Claude Code and other clients, and the graph is stored in a local SQLite file by default.
What it can do
- Index a repository into a graph with cgr start --update-graph
- Ask questions in natural language, answered from the graph
- Retrieve the source of a function, class or method
- Edit code with AST-based patching and a diff preview
- Find dead code from entry points
- Search and rewrite by AST pattern with ast-grep
- Overlay runtime calls with cgr trace
When to use
- βΊWhen you work in a large monorepo and need answers grounded in the real code structure.
- βΊWhen you want to find functions that nothing calls.
- βΊWhen you want to make an edit across a codebase and see the diff first.
What you need
Skills that pair well
MCP or skill?
The MCP gives the agent the hands. The skill teaches the right way to use them. Together, the result is better and uses fewer tokens.
codegraphHelps your agent analyze an indexed codebase through its call graph, dependencies, dead code, hotspots and semantic search.explore-codebaseHelps your agent find its way around an unfamiliar codebase by searching the code knowledge graph for modules and relationships.graph-queryLets your agent query a code dependency graph to find callers, related components and the impact of a change before the code is edited.Frequently asked questions
Is it free and open source?
Yes, it is MIT licensed. The readme says it is free to use, with paid cloud and on-premise services for organizations.
Which languages are supported?
Fully supported are Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart and Julia. Others have structural support.
Do I need a graph database?
No. The graph lives in an embedded SQLite file by default. Memgraph and Neo4j are optional backends.
Where is the graph stored?
In ~/.cgr/graph.sqlite by default. Set SQLITE_GRAPH_PATH to move it.
Will --clean delete only this project?
No. The readme says --clean deletes every project in the shared graph and asks for confirmation when other projects would be lost.
Which version do I get from PyPI?
The newest release, which can be behind the newest git tag. Install from git to get newer code.
If it does not work
- βΊCheck you have Python 3.12 or newer. Older system Python needs the interpreter pinned, as the installation guide explains.
- βΊInstall ripgrep, which is required.
- βΊRun cgr start --update-graph first so the graph exists before you ask questions.
5 new skills a week. 1 minute to read.