# Code-Graph-RAG

> Code-Graph-RAG is an open-source MCP server for knowledge and memory. Turns a multi-language codebase into a graph you can query and edit in plain English. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted
- **Website:** https://code-graph-rag.com
- **Repository:** https://github.com/vitali87/code-graph-rag
- **MCP Registry name:** io.github.vitali87/code-graph-rag
- **Categories:** knowledge and memory, developer tools
- **Listing updated:** 2026-11-14

## About

Instead of searching files by text, this server first parses a repository with Tree-sitter into a graph of functions, classes, modules and the calls and imports between them. Questions you type are translated into Cypher queries against that graph, so answers point at real structure rather than guessed context.

Where a toolchain is installed it layers compiler-level facts on top: libclang for C and C++, go/types for Go, and optional Roslyn, javac and Jedi for C#, Java and Python. A `cgr trace` command can also merge calls observed at runtime into the graph, which exposes dispatch that static parsing cannot see.

The graph lives in an embedded SQLite file by default; Memgraph and Neo4j are opt-in backends that run the same Cypher. The orchestrator and the query-writing model are configured separately, with ollama as the default and OpenAI, Anthropic, Google, Azure and Cohere as options. The website says the MCP integration exposes 15 tools for indexing, querying, editing and searching.

## Features

- **Tree-sitter graph index:** Parses 14 languages into one graph schema of functions, classes, modules and dependencies.
- **Natural-language queries:** Translates plain-English questions into Cypher queries over the code graph.
- **AST-based editing:** Replaces specific functions with a diff preview shown before anything changes.
- **Dead code detection:** Walks call and reference edges from entry points to find unreachable functions.
- **Structural search and replace:** Uses ast-grep patterns to match and rewrite code by structure, not text.
- **Runtime trace overlay:** Merges calls observed in a test run into the graph with the cgr trace command.
- **Choice of graph backend:** Embedded SQLite by default, with Memgraph or Neo4j as opt-in alternatives.

## Good for

- Ask how a function is reached in an unfamiliar monorepo
- Find unreachable functions before a cleanup
- Apply a pattern-based rewrite across a whole codebase
- Check what calls a function before changing its signature
- Let an agent edit one function surgically, with a diff to review

## Install

### Claude Code (Terminal)

```sh
claude mcp add code-graph-rag --env ORCHESTRATOR_API_KEY='<ORCHESTRATOR_API_KEY>' --env CYPHER_API_KEY='<CYPHER_API_KEY>' -- uvx code-graph-rag
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "code-graph-rag": {
      "command": "uvx",
      "args": [
        "code-graph-rag"
      ],
      "env": {
        "ORCHESTRATOR_API_KEY": "<ORCHESTRATOR_API_KEY>",
        "CYPHER_API_KEY": "<CYPHER_API_KEY>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "code-graph-rag": {
      "command": "uvx",
      "args": [
        "code-graph-rag"
      ],
      "env": {
        "ORCHESTRATOR_API_KEY": "<ORCHESTRATOR_API_KEY>",
        "CYPHER_API_KEY": "<CYPHER_API_KEY>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "code-graph-rag": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "code-graph-rag"
      ],
      "env": {
        "ORCHESTRATOR_API_KEY": "<ORCHESTRATOR_API_KEY>",
        "CYPHER_API_KEY": "<CYPHER_API_KEY>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "code-graph-rag": {
      "command": "uvx",
      "args": [
        "code-graph-rag"
      ],
      "env": {
        "ORCHESTRATOR_API_KEY": "<ORCHESTRATOR_API_KEY>",
        "CYPHER_API_KEY": "<CYPHER_API_KEY>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "code-graph-rag": {
      "command": "uvx",
      "args": [
        "code-graph-rag"
      ],
      "env": {
        "ORCHESTRATOR_API_KEY": "<ORCHESTRATOR_API_KEY>",
        "CYPHER_API_KEY": "<CYPHER_API_KEY>"
      }
    }
  }
}
```

## FAQ

### Which LLM does it use?

The orchestrator and the Cypher generator are set separately through environment variables. The registry entry lists openai, anthropic, google, azure, cohere and ollama, with ollama and llama3.2 as the defaults.

### Does the graph need a database server?

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

### Which languages are supported?

The website lists 14, among them Python, TypeScript, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart and Julia.

### Is there paid support?

The core is free and open source. The website also offers support contracts, consulting, training, custom parsers and managed or on-prem deployment; prices are not published.

### Is Code-Graph-RAG free?

Yes. Code-Graph-RAG is open source, so you can use and self-host it for free.

### How do I add Code-Graph-RAG to Claude Code?

Run this command in your terminal: claude mcp add code-graph-rag --env ORCHESTRATOR_API_KEY='<ORCHESTRATOR_API_KEY>' --env CYPHER_API_KEY='<CYPHER_API_KEY>' -- uvx code-graph-rag

### What are the best alternatives to Code-Graph-RAG?

The closest alternatives to Code-Graph-RAG are REA, Codebase Memory, GitHub, Serena MCP: the IDE for your agent and XERJ.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.
- [Ouroboros](https://ai-powered.com/mcp/ouroboros): Ouroboros is an open-source MCP server for developer tools.
- [Claude Code Ultimate Guide](https://ai-powered.com/mcp/claude-code-ultimate-guide): Claude Code Ultimate Guide is an open-source MCP server for ai models and llm tooling.
- [Nautilus Compass Memory](https://ai-powered.com/mcp/nautilus-compass-memory): Nautilus Compass Memory is an open-source MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/code-graph-rag
