# Code-Graph-RAG MCP server

> Parses a multi-language codebase into a knowledge graph so an AI client can query, retrieve, and edit code in plain English.

- Repository: https://github.com/vitali87/code-graph-rag
- Page: https://hostedmcp.org/servers/vitali87/code-graph-rag
- Transport: stdio
- Stars: 5354
- License: MIT
- Latest version: 0.6.30

## Install

### Claude Code

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

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

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

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

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

### VS Code CLI

```sh
code --add-mcp '{"name":"code-graph-rag","type":"stdio","command":"uvx","args":["code-graph-rag"],"env":{"CYPHER_API_KEY":"<YOUR_CYPHER_API_KEY>","ORCHESTRATOR_API_KEY":"<YOUR_ORCHESTRATOR_API_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

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

### Codex

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

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.code-graph-rag]
command = "uvx"
args = ["code-graph-rag"]

[mcp_servers.code-graph-rag.env]
CYPHER_API_KEY = "<YOUR_CYPHER_API_KEY>"
ORCHESTRATOR_API_KEY = "<YOUR_ORCHESTRATOR_API_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'CYPHER_API_KEY=<YOUR_CYPHER_API_KEY>' -e 'ORCHESTRATOR_API_KEY=<YOUR_ORCHESTRATOR_API_KEY>' code-graph-rag uvx -- code-graph-rag
```

### Gemini settings.json (`~/.gemini/settings.json`)

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

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `CYPHER_API_KEY` | no | yes | API key for the Cypher LLM provider (not needed for the default local ollama provider) |
| `ORCHESTRATOR_API_KEY` | no | yes | API key for the orchestrator LLM provider (not needed for the default local ollama provider) |
| `CYPHER_MODEL` | no | no | Model name for Cypher query generation |
| `CYPHER_PROVIDER` | no | no | LLM provider for Cypher query generation (openai, anthropic, google, azure, cohere, ollama) |
| `MEMGRAPH_HOST` | no | no | Hostname of the Memgraph database |
| `MEMGRAPH_PORT` | no | no | Port of the Memgraph database |
| `ORCHESTRATOR_MODEL` | no | no | Model name for the orchestrator agent |
| `ORCHESTRATOR_PROVIDER` | no | no | LLM provider for the orchestrator agent (openai, anthropic, google, azure, cohere, ollama) |
| `TARGET_REPO_PATH` | no | no | Path to the repository to analyze (auto-detected from working directory if not set) |

## FAQ

### What does code-graph-rag do with a repository?

It parses every source file, extracts functions, classes, methods, modules and their relationships, and stores them as an interconnected graph you can query.

### Which programming languages are supported?

Python, TypeScript, TSX, JavaScript, Rust, Go, Java, C, C++, C#, PHP, Lua, Dart and Julia are fully supported, with structural support for several more languages.

### Where is the code graph stored?

By default the graph is stored in an embedded SQLite file, with Memgraph and Neo4j available as opt-in backends.

### Can it find dead code?

Yes, it finds dead code by walking call and reference edges from entry points.
