# better-code-review-graph [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/n24q02m/crg  
**GitHub Stars:** 76  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/better-code-review-graph

## Description
Knowledge graph for token-efficient code reviews with fixed search and configurable embeddings

## Tools
Capabilities this server exposes over MCP:

- **graph** — Build and manage the code knowledge graph. Actions: build (full_rebuild, base, repo_root), update (base, repo_root), stats (repo_root), embed (repo_root), export (format, output_path, repo_root), import (import_path, repo_root), summarize (max_nodes, repo_root). Use `help` tool for full docs.
- **query** — Query the code knowledge graph for relationships, search, and impact analysis. Actions: query (pattern, target), search (search_query), impact (changed_files|base), large_functions (min_lines), spot_check (n -- random callsite snippets from last callers_of/callees_of/inheritors_of/importers_of result), renamed_in_diff (base -- symbols whose callsite line shifted vs base ref), diff (from_sha, to_sha -- nodes added/removed/modified between two commit SHAs). Use `help` tool for full docs.
- **review** — Generate token-efficient review context for code changes. Actions: context (default — auto-detects changed files from git diff, returns structural summary, impacted nodes, source snippets, and review guidance), delta (from_sha, to_sha — wraps the `query.diff` buckets and, when show_line_shifts=true, surfaces qualified_names whose line_start moved between the two commits for refactor auditing). Context params: changed_files (auto), max_depth=2, include_source=true, max_lines_per_file=200, base='HEAD~1', repo_root (auto). Delta params: from_sha, to_sha, show_line_shifts=false, repo, repo_root. Use `help` tool for full docs.
- **config** — Server configuration, status, and model-cell setup. Actions: status (show state), set (key, value -- keys: log_level), cache_clear (wipe embeddings), setup_status (state + configured model cells), setup_start (where the host configures keys), setup_skip (local mode), setup_reset (reset to local), setup_complete (re-resolve from host config). Use `help` tool for full docs.
- **help** — Get full documentation for any tool. Topics: graph | query | review | config | security | recipes. Use when compressed descriptions are insufficient.
- **security** — Security scanning over the code knowledge graph. Actions: scan (engine='heuristic'|'semgrep', repo_root), report (format='json'|'sarif', repo_root), suppress (rule_id, remove=false, repo_root), rule_list (engine='heuristic'|'semgrep'). Use `help` tool for full docs.

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/n24q02m/crg), copied verbatim. Run them in order; they are not an mcpServers config.

1. Install:

```sh
pip install n24q02m-crg
```

2. Add to Claude Code:

```sh
claude mcp add crg -- uvx --python 3.13 n24q02m-crg
```

3. Start the server:

```sh
uvx --python 3.13 n24q02m-crg
```

4. Start the server:

```sh
uv run n24q02m-crg server start
```

5. Configure:

```sh
cp docker-config/config.example.toml docker-config/config.toml
```

## Documentation

## What better-code-review-graph does

better-code-review-graph turns a repository into a queryable code knowledge graph. Parsing is performed with Tree-sitter, with graph data centered on functions, classes, imports, call relationships, and other structural connections. The server exposes this graph through MCP and can also be used through its `crg` command-line interface.

The review workflow is designed to reduce the amount of source an agent must inspect. Review context can identify changed files from Git, summarize affected structure, find impacted nodes, include selected source snippets, and return review guidance. The graph also supports semantic search, relationship queries, call-site inspection, inheritance and import analysis, and comparisons between commits.

## How it works

Build the graph with the `graph` tool, either from scratch or incrementally. Other graph actions report statistics, create embeddings, export or import graph data, and produce summaries. The `query` tool then searches the graph or examines relationships and change impact. It can also identify large functions, sample call-site snippets, detect symbols whose callsite lines moved, and compare nodes added, removed, or modified between two commit SHAs.

The `review` tool provides two review-oriented paths. `context` derives a focused review package from a Git diff, while `delta` compares two commits and can optionally report qualified names whose starting lines changed. Graph nodes and edges include temporal columns for tracking validity across revisions.

Semantic search uses the local ONNX model registry from `fastretrieval` by default, so the local path requires no API key. An optional cloud embedding chain is available when a different embedding setup is appropriate.

## Setup and configuration

The package is distributed on PyPI as `n24q02m-crg`, and the primary command is `crg`. It supports Python 3.13. A one-off graph operation can run through `uvx`, for example:

```bash
uvx --python 3.13 --from n24q02m-crg crg graph build --full-rebuild \
  --repo-root /path/to/repo
```

Install the package with `pip install n24q02m-crg` when persistent console scripts are preferred. The optional Semgrep security engine is installed with the `security` extra.

MCP can run over stdio or self-hosted HTTP. For stdio clients, register the package command with `uvx --python 3.13 n24q02m-crg` and set `MCP_TRANSPORT=stdio`. Self-hosted HTTP exposes an MCP endpoint at `/mcp`; the documented local development mode uses loopback, while always-on deployment uses token authentication. Configuration is stored under `CRG_CONFIG_DIR` or `~/.crg`.

The `config` tool reports server state, changes the log level, clears embedding caches, and manages model-cell setup. Setup can use host-provided model configuration or be switched to local mode.

## Tools and capabilities

- `graph`: Build, update, inspect, embed, summarize, export, and import the knowledge graph.
- `query`: Search code and resolve relationships, impact, callers, callees, inheritors, importers, line shifts, and commit deltas.
- `review`: Generate focused context for changed files or compare two commits for review.
- `security`: Run heuristic or Semgrep scans, list rules, suppress findings, and emit JSON or SARIF reports.
- `config`: Inspect configuration, manage logging and embedding caches, and control model setup.
- `help`: Retrieve detailed documentation for tools, security behavior, and usage recipes.

## Limitations and notes

The project is CLI-first; its MCP adapter is a secondary interface. HTTP operation is self-hosted rather than provided through a hosted endpoint. The Semgrep scanner requires the optional security installation. Opening a graph created before the schema change automatically applies the migration and saves a pre-migration database backup, so deployments should account for that database transition.

_Full upstream README: https://allmcps.com/mcp/better-code-review-graph/readme_

