# crg

Builds a code knowledge graph using Tree-sitter. Delivers precise structural context for reviews so agents do not load whole repositories.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 76
- Author: n24q02m
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/n24q02m/crg
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/mcp/crg

## What it does

The server parses codebases with Tree-sitter to index relationships among functions, classes, and imports. Default semantic search runs offline through local ONNX models via `fastretrieval`, avoiding mandatory external embedding API keys.

This design keeps token consumption predictable during reviews. Instead of reading complete directories, the client queries call graphs and resolves qualified symbols directly over MCP.

Remember that the CLI binary is `crg`, but the PyPI package is named `better-code-review-graph`. Running it via `uvx` requires Python 3.13.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `EMBEDDING_MODELS`, `LOCAL_EMBEDDING_MODEL`, `LOCAL_RERANK_MODEL`, `LOCAL_EMBEDDING_DIM`, `LOCAL_EMBEDDING_MODEL_FILE`, `LOCAL_EMBEDDING_POOLING`, `LOCAL_EMBEDDING_NORMALIZE`, `HULL_EMBED_API_KEY`, `HULL_CHAT_API_KEY`, `EMBEDDING_BACKEND` — 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 EMBEDDING_MODELS=<EMBEDDING_MODELS> --env LOCAL_EMBEDDING_MODEL=<LOCAL_EMBEDDING_MODEL> --env LOCAL_RERANK_MODEL=<LOCAL_RERANK_MODEL> --env LOCAL_EMBEDDING_DIM=<LOCAL_EMBEDDING_DIM> --env LOCAL_EMBEDDING_MODEL_FILE=<LOCAL_EMBEDDING_MODEL_FILE> --transport stdio crg -- uvx better-code-review-graph
```
Replace <…> with your own values. 5 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 better-code-review-graph <command>

### Codex

**Platform CLI**
```bash
codex mcp add crg --env EMBEDDING_MODELS=<EMBEDDING_MODELS> --env LOCAL_EMBEDDING_MODEL=<LOCAL_EMBEDDING_MODEL> --env LOCAL_RERANK_MODEL=<LOCAL_RERANK_MODEL> --env LOCAL_EMBEDDING_DIM=<LOCAL_EMBEDDING_DIM> --env LOCAL_EMBEDDING_MODEL_FILE=<LOCAL_EMBEDDING_MODEL_FILE> -- uvx better-code-review-graph
```
Replace <…> with your own values. 5 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 better-code-review-graph <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "crg": {
            "command": "uvx",
            "args": [
                "better-code-review-graph"
            ],
            "env": {
                "EMBEDDING_MODELS": "<EMBEDDING_MODELS>",
                "LOCAL_EMBEDDING_MODEL": "<LOCAL_EMBEDDING_MODEL>",
                "LOCAL_RERANK_MODEL": "<LOCAL_RERANK_MODEL>",
                "LOCAL_EMBEDDING_DIM": "<LOCAL_EMBEDDING_DIM>",
                "LOCAL_EMBEDDING_MODEL_FILE": "<LOCAL_EMBEDDING_MODEL_FILE>"
            }
        }
    }
}
```
Replace <…> with your own values. 5 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 better-code-review-graph <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "crg": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "better-code-review-graph"
            ],
            "env": {
                "EMBEDDING_MODELS": "<EMBEDDING_MODELS>",
                "LOCAL_EMBEDDING_MODEL": "<LOCAL_EMBEDDING_MODEL>",
                "LOCAL_RERANK_MODEL": "<LOCAL_RERANK_MODEL>",
                "LOCAL_EMBEDDING_DIM": "<LOCAL_EMBEDDING_DIM>",
                "LOCAL_EMBEDDING_MODEL_FILE": "<LOCAL_EMBEDDING_MODEL_FILE>"
            }
        }
    }
}
```
Replace <…> with your own values. 5 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 better-code-review-graph <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e EMBEDDING_MODELS=<EMBEDDING_MODELS> -e LOCAL_EMBEDDING_MODEL=<LOCAL_EMBEDDING_MODEL> -e LOCAL_RERANK_MODEL=<LOCAL_RERANK_MODEL> -e LOCAL_EMBEDDING_DIM=<LOCAL_EMBEDDING_DIM> -e LOCAL_EMBEDDING_MODEL_FILE=<LOCAL_EMBEDDING_MODEL_FILE> crg uvx better-code-review-graph
```
Replace <…> with your own values. 5 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 better-code-review-graph <command>

## When to use it
- build call graphs for functions and class hierarchies
- run local semantic code search without API tokens
- reduce prompt context overhead during pull request reviews
- trace dependency chains across imported modules

## Example prompts
- Build the call graph for the authentication handler and display callers
- Search the codebase semantically for database connection retry logic
- Map imported dependencies for the payment processing class

## Similar
- [Front-End Checklist](https://affpapa.org/en/nevibecode/mcp/front-end-checklist.md) — MCP server · ★ 74559
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [Serena MCP: the IDE for your agent](https://affpapa.org/en/nevibecode/mcp/serena-mcp-the-ide-for-your-agent.md) — MCP server · ★ 30677
- [Repomix](https://affpapa.org/en/nevibecode/mcp/repomix.md) — MCP server · ★ 29027
- [Repowise](https://affpapa.org/en/nevibecode/mcp/repowise.md) — MCP server · ★ 7891
- [sem](https://affpapa.org/en/nevibecode/mcp/sem.md) — MCP server · ★ 3422

---
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
