Skip to content
Skillpedia
● Free and open sourceπŸ’» LocalπŸ”“ No API keyProgramming

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

NameWhat it isRequired
ORCHESTRATOR_PROVIDERLLM provider for the orchestrator agent (openai, anthropic, google, azure, cohere, ollama)No
ORCHESTRATOR_MODELModel name for the orchestrator agentNo
ORCHESTRATOR_API_KEYAPI key for the orchestrator LLM provider (not needed for the default local ollama provider)No
CYPHER_PROVIDERLLM provider for Cypher query generation (openai, anthropic, google, azure, cohere, ollama)No
CYPHER_MODELModel name for Cypher query generationNo
CYPHER_API_KEYAPI key for the Cypher LLM provider (not needed for the default local ollama provider)No
MEMGRAPH_HOSTHostname of the Memgraph databaseNo
MEMGRAPH_PORTPort of the Memgraph databaseNo
TARGET_REPO_PATHPath 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

Python 3.12+ and ripgrep. Install with uv tool install or pipx. No database server or Docker is needed by default. See the installation guide for model and environment setup.

Skills that pair well

⭐ Skillpedia MCP Β· freeYour agent finds the right skill on its ownInstall our MCP and your agent searches 15,000+ skills whenever it needs one.Install for free β†’

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.