Code-Graph-RAG

Developer toolsData and AI

Knowledge-graph RAG for multi-language codebases: index, query and edit code in natural language.

Your AI app calls the Code-Graph-RAG MCP server, which does the developer tools and data and AI work and sends the result back to the chat.

About Code-Graph-RAG

Code-Graph-RAG is a community MCP server from vitali87, filed in our directory under developer tools and data and ai. Knowledge-graph RAG for multi-language codebases: index, query and edit code in natural language.

Code-Graph-RAG runs on your own machine: your AI app starts it with the command uvx code-graph-rag==0.7.180 mcp-server and talks to it over standard input and output.

Code-Graph-RAG is listed in the official MCP registry as io.github.vitali87/code-graph-rag, version 0.7.180.

At a glance

Publisher
vitali87 (community)
Runs
Locally on your machine
Install from
Python package on PyPI: code-graph-rag
Written in
Python
License
MIT
GitHub stars
5,463
Official MCP registry
io.github.vitali87/code-graph-rag

How to set up Code-Graph-RAG

  1. Install uv on the machine that runs your AI app, because Code-Graph-RAG starts with uvx and fetches its Python package on first run.
  2. Check the Code-Graph-RAG README for keys or settings; the registry lists none that Code-Graph-RAG requires.
  3. Add Code-Graph-RAG to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Code-Graph-RAG tools to confirm the connection.
  5. Run one read-only task with Code-Graph-RAG first, and keep your app asking before each tool call until the results look right.

Code-Graph-RAG compared with similar servers

  • Fallow by fallow-rs has fewer GitHub stars than Code-Graph-RAG (5.4k against 5.5k); both are community servers, and both run locally.
  • Fast Anything by EL4CTEO has more GitHub stars than Code-Graph-RAG (5.5k against 5.5k); both are community servers, and both run locally.
  • Hyperresearch by jordan-gibbs has fewer GitHub stars than Code-Graph-RAG (5.2k against 5.5k); both are community servers, and both run locally.

Before you connect Code-Graph-RAG

  • Give Code-Graph-RAG its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Code-Graph-RAG tool call until you trust what it does with them.
  • Treat text that Code-Graph-RAG fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Code-Graph-RAG on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Code-Graph-RAG

How marketing and sales teams put Code-Graph-RAG to work, by company size. Pick the size closest to yours and start Code-Graph-RAG on one use case.

Small business

  • A small business with a developer can use Code-Graph-RAG to ship site and tracking fixes faster, with the AI reading the code it changes.
  • Technical founders can ask Code-Graph-RAG to explain and fix a marketing site issue without context switching between tools.
  • A small team can use Code-Graph-RAG to clean and enrich a lead list or a spreadsheet in one pass, instead of hours of copy and paste.
  • Code-Graph-RAG runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineers can use Code-Graph-RAG to build landing pages, tracking and integrations in fewer cycles, with reviews kept in the normal flow.
  • Marketing ops engineers can connect Code-Graph-RAG to keep scripts and automations documented and versioned as they change.
  • Marketing ops can connect Code-Graph-RAG to enrich and score inbound leads, so sales sees fit and intent before the first call.
  • Start Code-Graph-RAG on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprise engineering teams can roll out Code-Graph-RAG with repo scopes and audit logs, so agents work only where they are allowed.
  • Platform teams can standardize on Code-Graph-RAG so web and marketing engineering share one reviewed way of working with AI.
  • Enterprises can run Code-Graph-RAG inside their own cloud and data boundary, so models and data stay where governance requires.
  • Code-Graph-RAG is a community server, so have security review the code and pin a version before Code-Graph-RAG touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Code-Graph-RAG README

From vitali87/code-graph-rag on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

Code-Graph-RAG

Code-Graph-RAG parses a multi-language codebase with Tree-sitter, sharpened by compiler-grade frontends and runtime traces where available, builds a knowledge graph of its structure in an embedded graph database that needs no server, and lets you query, edit, and optimise that code in plain English. It works across a monorepo of mixed languages under one unified graph schema.

1. Index: cgr start --update-graph parses a repository into a knowledge graph (sped up)

2. Ask: cgr start answers questions and edits code, grounded in that graph

Latest News 🔥

  • Handoff Enhancements: Go index sections, engine comparison, and a preview flag have been added to the handoff feature. Imports are now listed after incremental runs on a new updater, and deleted module imports are dropped from reused updaters.
  • Go Type Checker Fixes: Several fixes address issues with the Go type checker, including handling bad input as failed runs, ensuring bare calls name the package function, and managing GOFLAGS -modfile in various scenarios.
  • Lean 4 Support: Lean 4 is now officially supported.

See NEWS.md for the full history.

What It Does

Point Code-Graph-RAG at a repository and it reads every source file, extracts functions, classes, methods, modules, and the relationships between them, and stores the result as an interconnected graph. Once the graph exists you can:

  • Ask questions about the codebase in natural language and get answers grounded in the real structure.
  • Retrieve the actual source of any function, class, or method by name or by intent.
  • Edit code through the agent with AST-based surgical patching and a diff preview before anything changes.
  • Optimise code against language best practices or your own coding standards.
  • Find dead code by walking call and reference edges from entry points.
  • Search and rewrite structurally by AST pattern with ast-grep.
  • Overlay runtime behaviour: trace a test run (or pull production eBPF profiles) with cgr trace and merge the calls that actually happened into the graph, exposing dispatch that static analysis cannot see.

How It Works

The system has two components:

  1. Multi-language parser. A Tree-sitter based parser reads the codebase and ingests functions, classes, methods, modules, and their relationships into the graph under a single language-agnostic schema. Where a toolchain is available, compiler-grade frontends layer exact facts on top (libclang for C/C++, go/types for Go, and opt-in Roslyn, javac and Jedi for C#, Java and Python), and dynamic tracing merges calls observed at runtime. Tree-sitter stays the backbone: a trace only sees code that ran, and a compiler frontend only covers what its toolchain can build.
  2. RAG system (codebase_rag/). An interactive CLI that turns natural language into Cypher queries, retrieves matching code, and drives AI-powered editing and optimisation.
Source Code -> Tree-sitter Parser -> AST Analysis -> Knowledge Graph
                                                             |
User Query -> AI Model (Cypher Gen) -> Cypher Query -> Graph Results -> Response

The graph is stored in an embedded SQLite file by default. Memgraph and Neo4j are opt-in backends that run the same Cypher; Graph Backends compares them.

See the Architecture Overview and Graph Schema for the full picture.

Supported Languages

Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart, Julia, and Lean 4 are fully supported. Scala is in development, and Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, and Nix have structural support (modules, functions, classes where the language has them, and imports) through the pluggable ast-grep tier. See the Language Support matrix for per-language capabilities.

Installation

cgr is published to PyPI. Install it system-wide with the treesitter-full (tree-sitter grammars), ast-grep (Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, Nix) and semantic (vector search) extras:

# with uv (recommended)
uv tool install "code-graph-rag[treesitter-full,ast-grep,semantic]"

# or with pipx
pipx install "code-graph-rag[treesitter-full,ast-grep,semantic]"
Which version am I getting?

Three version lines exist and they intentionally differ:

where what it tracks
git tags every version, one per merge
GitHub Releases (binaries, signatures) every 50th version, plus any security fix, breaking change or merge labelled release now
PyPI every 50th version, plus any security fix, breaking change or merge labelled release now

So the newest tag on main usually runs ahead of the newest release, often by tens of patch versions; they coincide only just after a release. Nothing is stuck, the cadences differ by design. A security fix, a breaking change or a merge a maintainer labels release now does NOT wait for the cadence: each ships a release and a PyPI upload immediately.

uv tool install and pipx install give you the newest PyPI version, which is the newest RELEASE, not the newest tag. Interim tags exist so every merge is addressable; binaries and PyPI uploads follow the cadence above.

To run code newer than the latest release, install from git:

uv tool install "code-graph-rag[treesitter-full,ast-grep,semantic] @ git+https://github.com/vitali87/code-graph-rag@main"

To upgrade an existing install, run uv tool upgrade code-graph-rag (with pipx, pipx upgrade code-graph-rag, or pipx reinstall code-graph-rag for a git install). Upgrade covers the other install methods.

You also need Python 3.12+ and ripgrep. The graph lives in an embedded SQLite file by default, so there is no database server to run: no Docker and no cmake. Memgraph and Neo4j remain available as opt-in backends (Graph Backends). Full prerequisites, source installs, and environment setup are in the Installation guide.

[!NOTE] cgr requires its native extension, cgr-graph-rs, which ships for CPython 3.12 or newer on Linux (x86_64, aarch64), macOS and Windows x64, so it installs on those platforms only. Older system interpreters (Debian Bookworm ships 3.11) need the interpreter pinned explicitly; see Installation for the commands.

Quick Start

# Parse a repository into the graph, then query it
cgr start --repo-path /path/to/repo --update-graph
cgr start --repo-path /path/to/repo

The graph is written to ~/.cgr/graph.sqlite (set SQLITE_GRAPH_PATH to move it). To use Memgraph instead, install the driver with the memgraph extra, set GRAPH_BACKEND=memgraph, and start the packaged Memgraph + Qdrant stack with cgr daemon up.

Repeat the first command for each repository you want indexed; the graph is shared, and syncing one project leaves the others alone. To start over from an empty graph, add --clean, it deletes every project in the shared graph, not just this one, and asks for confirmation first when other projects would be destroyed.

A default index leaves out the opt-in capture groups; add them with --capture or CGR_CAPTURE.

The Quick Start guide walks through parsing, querying, and exporting in five minutes.

MCP Server

Code-Graph-RAG runs as an MCP server so Claude Code and other MCP clients can query and edit your codebase directly. See the MCP Server guide for setup.

Documentation

Getting Started

User Guide

Architecture

Python SDK

Advanced

Enterprise Services

Code-Graph-RAG is open source and free to use. For organisations that need more, we offer fully managed cloud-hosted solutions and on-premise deployments:

  • Cloud-Hosted Deployment: Managed cloud infrastructure for both the graph database and the AI agent connection. Zero infrastructure overhead, so we handle scaling, updates, and availability while your team focuses on building.
  • On-Premise & Air-Gapped Deployment: Deploy Code-Graph-RAG entirely within your own environment, including air-gapped networks. Full data sovereignty for regulated industries and security-sensitive organisations.

We also offer custom development, integration consulting, technical support contracts, and team training.

View plans & pricing at code-graph-rag.com

Contributing

Please see CONTRIBUTING.md for contribution guidelines. Good first PRs come from the To do issues.

Support

For issues or questions, check the Troubleshooting guide first, then open an issue.

If cgr is useful to you, please consider pledging support on GitHub Sponsors. cgr links the page under cgr --version and, in a terminal, after most commands finish; set CGR_SPONSOR_PLEDGE=false to hide that line.

Accessibility

ACCESSIBILITY.md describes what cgr and its documentation support for people using assistive technology or alternative settings, the known limitations and their workarounds, and how to report a barrier.

License

MIT. See LICENSE.

Third-party components and their licences are credited on the Credits page.

Questions about Code-Graph-RAG

What is the Code-Graph-RAG MCP server?

Knowledge-graph RAG for multi-language codebases: index, query and edit code in natural language. Code-Graph-RAG is maintained by vitali87 on GitHub at vitali87/code-graph-rag, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Code-Graph-RAG MCP server?

Add Code-Graph-RAG to your AI app's MCP config with the command uvx code-graph-rag==0.7.180 mcp-server. In Claude Code, run claude mcp add --transport stdio code-graph-rag -- uvx code-graph-rag==0.7.180 mcp-server. To run Code-Graph-RAG this way you need uv installed.

Does Code-Graph-RAG need an API key?

The registry lists no required keys for Code-Graph-RAG. Check the Code-Graph-RAG README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Code-Graph-RAG an official MCP server?

No. Code-Graph-RAG is a community server maintained by vitali87. Community servers can be excellent; read the code and the open issues before you give Code-Graph-RAG access to company data.

What license is Code-Graph-RAG under?

Code-Graph-RAG is released under the MIT license, according to its GitHub repository. The license covers the code of Code-Graph-RAG; the service it connects to has its own terms.