Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

Code-Graph-RAG

MCP server by vitali87 Community

Code-Graph-RAG indexes multi-language codebases into a knowledge graph and lets you query, edit and optimise that code in plain English. It is aimed at developers working in mixed-language monorepos.

  • Score 94
  • 5.5k stars
  • MIT
  • Updated

Install Code-Graph-RAG

Built from the published package, never by AI.

claude mcp add code-graph-rag -- uvx code-graph-rag

Run in your terminal. Add --scope user to use it in every project.

Step-by-step: install Code-Graph-RAG in Claude Code

MCP servers run with your permissions and can read what you give them access to. Some need an API key: check the README and add it under env in the code-graph-rag block.

About

Code-Graph-RAG is an MCP server that parses a multi-language codebase into a knowledge graph. It uses Tree-sitter as the parser, with compiler-grade frontends and runtime traces added where available. The graph records functions, classes, methods, modules and the relationships between them. By default it is stored in an embedded SQLite file, so no database server is needed.

Once the graph exists, users can ask questions in natural language, retrieve the source of named functions or classes, and edit code with AST-based patching and a diff preview. The tool can also optimise code, find dead code, search and rewrite by AST pattern with ast-grep, and merge runtime call traces into the graph. It is aimed at developers and teams who want an AI assistant to work over a mixed-language codebase. It also runs as an MCP server for clients such as Claude Code.

Written from the project's README and checked against it.

Tools it gives your assistant

  • Index a repositoryParses a repository into a knowledge graph with the cgr start --update-graph command.
  • Ask questionsAnswers natural language questions about the codebase, grounded in the graph structure.
  • Retrieve source codeReturns the actual source of a function, class or method by name or by intent.
  • Edit codeEdits code with AST-based surgical patching and a diff preview before any change is made.
  • Optimise codeOptimises code against language best practices or the user's own coding standards.
  • Find dead codeWalks call and reference edges from entry points to find dead code.
  • Structural search and rewriteSearches and rewrites code by AST pattern with ast-grep.
  • Runtime call tracingTraces a test run with cgr trace and merges the observed calls into the graph.

What you need

  • Python 3.12 or newer
  • ripgrep
  • Linux (x86_64, aarch64), macOS or Windows x64
SettingNeededWhat it is
ORCHESTRATOR_PROVIDEREnvironment variableOptionalLLM provider for the orchestrator agent (openai, anthropic, google, azure, cohere, ollama) Default: ollama
ORCHESTRATOR_MODELEnvironment variableOptionalModel name for the orchestrator agent Default: llama3.2
ORCHESTRATOR_API_KEYEnvironment variable, secretOptionalAPI key for the orchestrator LLM provider (not needed for the default local ollama provider)
CYPHER_PROVIDEREnvironment variableOptionalLLM provider for Cypher query generation (openai, anthropic, google, azure, cohere, ollama) Default: ollama
CYPHER_MODELEnvironment variableOptionalModel name for Cypher query generation Default: llama3.2
CYPHER_API_KEYEnvironment variable, secretOptionalAPI key for the Cypher LLM provider (not needed for the default local ollama provider)
MEMGRAPH_HOSTEnvironment variableOptionalHostname of the Memgraph database Default: localhost
MEMGRAPH_PORTEnvironment variableOptionalPort of the Memgraph database Default: 7687
TARGET_REPO_PATHEnvironment variableOptionalPath to the repository to analyze (auto-detected from working directory if not set)

From the publisher's entry in the official MCP Registry. Required settings are already in the install config below as placeholders.

Try asking

  • Index this repository and then tell me how the payment module is structured.
  • Show me the source of the function that handles user login.
  • Find dead code in this project starting from the main entry points.

Good to know

  • The native extension cgr-graph-rs installs only on the listed platforms and CPython 3.12 or newer.
  • A runtime trace only sees code that ran during the trace.
  • A compiler frontend only covers code that its toolchain can build.
  • Running cgr start with --clean deletes every project in the shared graph.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: README.md. This looks for known risky patterns and is not a full audit. How grades work

Alternatives to Code-Graph-RAG

All alternatives →

Compare with GitDiagram, mockserver or XcodeBuildMCP

Code-Graph-RAG: common questions

Does Code-Graph-RAG need a database server?

No. The graph is stored in an embedded SQLite file by default, and Memgraph and Neo4j are optional backends.

Which programming languages does Code-Graph-RAG support?

Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart, Julia and Lean 4 are listed as fully supported. Ruby, Kotlin, Swift, Elixir, Haskell, Solidity, Bash and Nix have structural support.

Is Code-Graph-RAG free to use?

The source says Code-Graph-RAG is open source and free to use under the MIT licence. It also mentions paid managed cloud and on-premise options as separate enterprise services.

How do I install Code-Graph-RAG?

In Claude Code run claude mcp add code-graph-rag -- uvx code-graph-rag. For Claude Desktop, Cursor and VS Code, paste the config shown above and restart. See the install guides.

Is Code-Graph-RAG the official server?

Code-Graph-RAG is a community project by vitali87, not verified by a company domain.

Is Code-Graph-RAG free?

The code is published under the MIT licence. The service it connects to may have its own pricing.

Is Code-Graph-RAG safe to use?

It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to Code-Graph-RAG?

Similar MCP servers: GitDiagram, mockserver, XcodeBuildMCP, draw.io.

Does Code-Graph-RAG work with ChatGPT?

Not directly. It runs locally, and ChatGPT only connects to remote servers with a URL. Use it in Claude Code, Claude Desktop, Cursor, VS Code or Codex.

Code-Graph-RAG Install

Add to stack

Loading.