# Code-Graph-RAG

Code-Graph-RAG MCP server indexes codebases into a knowledge graph using Tree-sitter for natural language queries. It runs during repository analysis.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 5392 repo stars
- Author: vitali87
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/vitali87/code-graph-rag
- Updated: 2026-11-16
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/code-graph-rag

## What it does

Code-Graph-RAG parses source files, extracts methods and modules, and stores them as an interconnected graph in an embedded SQLite database. It requires `ORCHESTRATOR_API_KEY` and `CYPHER_API_KEY` environment variables to operate.

The system translates user requests into Cypher queries over the generated graph structure. This supports searching source code, locating dead code, and performing AST-based patches.

To install it in Claude Code, run `claude mcp add code-graph-rag -e ORCHESTRATOR_API_KEY=<ORCHESTRATOR_API_KEY> -e CYPHER_API_KEY=<CYPHER_API_KEY> -- uvx code-graph-rag`.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `ORCHESTRATOR_PROVIDER`, `ORCHESTRATOR_MODEL`, `ORCHESTRATOR_API_KEY`, `CYPHER_PROVIDER`, `CYPHER_MODEL`, `CYPHER_API_KEY`, `MEMGRAPH_HOST`, `MEMGRAPH_PORT`, `TARGET_REPO_PATH` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env ORCHESTRATOR_PROVIDER=<ORCHESTRATOR_PROVIDER> --env ORCHESTRATOR_MODEL=<ORCHESTRATOR_MODEL> --env ORCHESTRATOR_API_KEY=<ORCHESTRATOR_API_KEY> --env CYPHER_PROVIDER=<CYPHER_PROVIDER> --env CYPHER_MODEL=<CYPHER_MODEL> --transport stdio code-graph-rag -- uvx code-graph-rag
```
Replace <…> with your own values. 4 more environment variables are in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from code-graph-rag <command>

### Codex

**Platform CLI**
```bash
codex mcp add code-graph-rag --env ORCHESTRATOR_PROVIDER=<ORCHESTRATOR_PROVIDER> --env ORCHESTRATOR_MODEL=<ORCHESTRATOR_MODEL> --env ORCHESTRATOR_API_KEY=<ORCHESTRATOR_API_KEY> --env CYPHER_PROVIDER=<CYPHER_PROVIDER> --env CYPHER_MODEL=<CYPHER_MODEL> -- uvx code-graph-rag
```
Replace <…> with your own values. 4 more environment variables are in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from code-graph-rag <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "code-graph-rag": {
            "command": "uvx",
            "args": [
                "code-graph-rag"
            ],
            "env": {
                "ORCHESTRATOR_PROVIDER": "<ORCHESTRATOR_PROVIDER>",
                "ORCHESTRATOR_MODEL": "<ORCHESTRATOR_MODEL>",
                "ORCHESTRATOR_API_KEY": "<ORCHESTRATOR_API_KEY>",
                "CYPHER_PROVIDER": "<CYPHER_PROVIDER>",
                "CYPHER_MODEL": "<CYPHER_MODEL>"
            }
        }
    }
}
```
Replace <…> with your own values. 4 more environment variables are in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from code-graph-rag <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "code-graph-rag": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "code-graph-rag"
            ],
            "env": {
                "ORCHESTRATOR_PROVIDER": "<ORCHESTRATOR_PROVIDER>",
                "ORCHESTRATOR_MODEL": "<ORCHESTRATOR_MODEL>",
                "ORCHESTRATOR_API_KEY": "<ORCHESTRATOR_API_KEY>",
                "CYPHER_PROVIDER": "<CYPHER_PROVIDER>",
                "CYPHER_MODEL": "<CYPHER_MODEL>"
            }
        }
    }
}
```
Replace <…> with your own values. 4 more environment variables are in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from code-graph-rag <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e ORCHESTRATOR_PROVIDER=<ORCHESTRATOR_PROVIDER> -e ORCHESTRATOR_MODEL=<ORCHESTRATOR_MODEL> -e ORCHESTRATOR_API_KEY=<ORCHESTRATOR_API_KEY> -e CYPHER_PROVIDER=<CYPHER_PROVIDER> -e CYPHER_MODEL=<CYPHER_MODEL> code-graph-rag uvx code-graph-rag
```
Replace <…> with your own values. 4 more environment variables are in the server README. uvx runs the command named after the package; if the README names another one, use uvx --from code-graph-rag <command>

## When to use it
- index a repository into a knowledge graph
- find functions or classes by intent or name
- locate dead code via call graph traversal
- edit code using AST patterns

## Example prompts
- Index the repository with `cgr start --update-graph`
- Find all callers of the authentication function
- Rewrite the logging module using an AST pattern

## Similar
- [rag-architect](https://affpapa.org/en/nevibecode/skills/httpsgithubcomjeffallan-rag-architect.md) — skill · 5100 installs
- [langchain4j-rag-implementation-patterns](https://affpapa.org/en/nevibecode/skills/langchain4j-rag-implementation-patterns.md) — skill · 3900 installs
- [langchain-rag](https://affpapa.org/en/nevibecode/skills/langchain-rag.md) — skill · 18600 installs
- [agent-platform-rag-engine-management](https://affpapa.org/en/nevibecode/skills/agent-platform-rag-engine-management.md) — skill · 8626 installs
- [rag](https://affpapa.org/en/nevibecode/skills/rag.md) — skill · 3900 installs
- [rag-blueprint](https://affpapa.org/en/nevibecode/skills/rag-blueprint.md) — skill · 3500 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
