Code Graph Rag logo

Code Graph Rag

Indexes mixed-language monorepos into a queryable code graph for grounded analysis, source retrieval, editing, optimization, and tracing.

Install Code Graph Rag

Pick your client, then add it in one click or paste the config.

No confirmed install command yet

We only publish a config when the install details come from the project itself — its README, its docs, or a verified owner. We haven’t found those for code-graph-rag, and we’d rather show nothing than a guess you’d paste into your client.

Open setup steps on GitHub

Overview

The code-graph-rag MCP server parses mixed-language repositories with Tree-sitter and stores code structure in an embedded graph database. It combines natural-language questions with generated Cypher queries to retrieve functions, classes, methods, modules, and relationships from the indexed codebase. Use it for monorepo exploration, AST-aware edits with diff previews, dead-code analysis, structural search, and runtime call tracing. Python 3.12+, ripgrep, and the optional language extras are required for installation.

Use cases

  • Index a mixed-language monorepo for structural code questions
  • Retrieve implementation details by function, class, or intent
  • Review AST-based edits before applying them
  • Trace runtime calls and merge them with static relationships
  • Find dead code through call and reference edges

Key features

  • Tree-sitter parsing across multiple programming languages
  • Embedded SQLite knowledge graph
  • Natural-language to Cypher code retrieval
  • AST-based editing with diff previews
  • ast-grep structural search and rewriting
  • Static graph analysis with runtime trace overlays

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked Today

Recent health check succeeded.

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars5.3kStargazers on the source repository.
Last commitTodayMost recent push to the default branch.

How Code Graph Rag works

What code-graph-rag does

code-graph-rag MCP server indexes a repository as a language-agnostic knowledge graph, allowing an agent to reason about code relationships rather than relying only on text search. It extracts functions, classes, methods, modules, imports, and other structural relationships from a multi-language codebase.

The indexed graph supports natural-language questions about repository structure, retrieval of source by name or intent, and code changes through AST-based patches. Changes can be reviewed through a diff preview before they are applied. The system can also inspect code against language practices or user-defined standards, identify potentially unused code by following call and reference edges, and search or rewrite code using AST patterns through ast-grep.

Supported languages with full support include Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart, and Julia. Scala is in development. Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, and Nix receive structural support through the ast-grep layer.

How it works

Tree-sitter provides the base parsing layer. The parser converts source files into AST information and places the resulting entities and relationships into one graph schema shared across languages. When the relevant toolchain is available, additional facts can come from libclang for C and C++, go/types for Go, and optional Roslyn, javac, and Jedi integrations for C#, Java, and Python.

The interactive RAG layer turns a natural-language request into a Cypher query, runs that query against the graph, and uses the returned code context to produce an answer or guide an edit. The default graph is an embedded SQLite file, so a separate database service is not needed. Memgraph and Neo4j can be selected as alternative backends and use the same Cypher query model.

Runtime information can be added with cgr trace, which records calls from a test run or imports production eBPF profiles. These observations supplement static analysis and can reveal dispatch paths that static parsing cannot establish alone.

Setup and configuration

Install the package from PyPI with uv or pipx. The recommended installation includes the treesitter-full, ast-grep, and semantic extras:

bash
uv tool install "code-graph-rag[treesitter-full,ast-grep,semantic]"

The same package can be installed with pipx. Running the indexer uses cgr start --update-graph; starting the interactive experience uses cgr start. Python 3.12 or newer and ripgrep are required. The default embedded SQLite backend needs no Docker, database server, or CMake. Installing from the repository is available when the latest development code is needed.

Tools and capabilities

  • Index repositories into a shared, multi-language knowledge graph.
  • Ask natural-language questions grounded in indexed code relationships.
  • Retrieve functions, classes, and methods by name or intent.
  • Apply AST-based edits with a reviewable diff preview.
  • Optimize code against language practices or custom standards.
  • Find dead code through call and reference relationships.
  • Search and rewrite code with ast-grep patterns.
  • Merge test or eBPF runtime traces into the graph.

Limitations and notes

Tree-sitter remains the baseline, so compiler-derived facts depend on the corresponding toolchain being available. Runtime tracing only covers code that actually executes, while compiler frontends only cover code their toolchains can build. Scala support is still in development, and the ast-grep languages provide structural rather than the same full level of analysis as the primary supported languages.

The default graph is local and embedded in SQLite. Memgraph and Neo4j are optional rather than required. Package releases and repository tags follow different release cadences, so installing from PyPI and installing from the repository can produce different code states.

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Code Graph Rag

code-graph-rag is an MCP server that connects an AI agent to an indexed code repository and its knowledge graph. Its main tools support natural-language code queries, source retrieval, AST-based editing with diff previews, structural search and rewriting, dead-code analysis, optimization, and runtime call tracing across supported languages.

Install it from PyPI with `uv tool install "code-graph-rag[treesitter-full,ast-grep,semantic]"` or the equivalent `pipx install` command. Python 3.12 or newer and `ripgrep` are required. The default embedded SQLite graph does not require Docker, CMake, or a separate database server.

code-graph-rag fully supports Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart, and Julia. Scala is in development. Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash, and Nix have structural support through ast-grep.

Yes. Run `cgr trace` to capture calls from a test run or import production eBPF profiles, then merge those observations into the knowledge graph. Runtime data complements static parsing and can expose dispatch paths that were not visible through source analysis alone.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewCode Graph Rag AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/code-graph-rag?style=directory)](https://allmcps.com/mcp/code-graph-rag)
HTML Embed
<a href="https://allmcps.com/mcp/code-graph-rag"><img src="https://allmcps.com/api/badge/code-graph-rag?style=directory" alt="Code Graph Rag on AllMCPs" /></a>