# Configuration Options for code-review-graph: MCP, CLI, and Hooks Explained

> Explore code-review-graph configuration options including MCP, CLI, and hooks. Learn how to customize your code review workflow with detailed explanations and examples.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-07-19

---

**The code-review-graph tool is configured through a combination of MCP server definitions in [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json), user-level settings files, generated editor hooks, TypeScript path resolution, and command-line flags that control data directories and refresh behavior.**

The `code-review-graph` repository provides a configurable code analysis framework that integrates with editors via the Model Context Protocol (MCP). Understanding the available configuration options for code-review-graph allows you to customize server connections, editor hooks, and analysis behavior to fit your development workflow.

## MCP Server Configuration

The primary configuration mechanism for code-review-graph relies on MCP server definitions that define how the tool communicates with the broader MCP framework.

### Repository-Level Configuration (.mcp.json)

At the repository root, the [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json) file serves as the primary MCP configuration. This JSON file contains a top-level `mcpServers` key that maps server names to their execution details.

Each entry under `mcpServers` specifies the server type, command, and arguments required to launch the code-review-graph service. For example, the `code-review-graph` server entry defines how editor tools invoke the analysis engine.

```json
{
  "mcpServers": {
    "code-review-graph": {
      "type": "stdio",
      "command": "uvx",
      "args": ["serve"]
    }
  }
}

```

### User-Level Configuration Files

You can also register code-review-graph as an MCP server without modifying repository files. The tool respects configuration files in your home directory, including:

- `~/.qwen/settings.json`
- `~/.codex/config.toml`
- `~/.future-editor/mcp.json`

These user-level files follow the same `mcpServers` structure as the repository-level [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json), allowing you to maintain global MCP server definitions that persist across projects.

## Editor Hooks Configuration

The [`code_review_graph/skills.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/skills.py) module generates editor-specific hook configurations that automate code-review-graph actions during editor sessions.

### Generated Hooks Structure

The functions `generate_hooks_config()`, `generate_codex_hooks_config()`, and `generate_cursor_hooks_config()` produce JSON configurations that define when and how the tool executes during editor events. The generated configuration contains a top-level `hooks` object with keys such as `PostToolUse` and `SessionStart`.

Each hook type contains a list of descriptors specifying the command to execute and matching criteria:

```python
from code_review_graph.skills import generate_hooks_config
from pathlib import Path

config = generate_hooks_config(Path("/my/repo"))
print(config["hooks"]["PostToolUse"][0]["command"])

# Output: "code-review-graph"

```

### Hook Installation and Removal

The [`code_review_graph/uninstall.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/uninstall.py) module handles removal of these generated configurations while respecting the `mcpServers` contract. When uninstalling, the tool ensures that server definitions remain valid even after hook removal.

## TypeScript Path Resolution

For TypeScript and JavaScript projects, [`code_review_graph/tsconfig_resolver.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/tsconfig_resolver.py) reads your project's [`tsconfig.json`](https://github.com/tirth8205/code-review-graph/blob/main/tsconfig.json) to resolve module paths correctly during analysis.

The resolver extracts two critical fields from the `compilerOptions` section:

- **`baseUrl`**: The base directory for non-relative module resolution
- **`paths`**: The path mapping entries that remap import locations

This configuration ensures that code-review-graph accurately traces dependencies in TypeScript codebases without requiring manual path aliases.

## Command-Line Interface Options

The [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py) module exposes several command-line flags that control runtime behavior and data management.

### Data Directory Management

Use `--data-dir <path>` to override the default data directory location. This updates the registry to point at a custom path for cached analysis data:

```bash
crg-cli --data-dir /tmp/crg-data --refresh-all

```

### Refresh Control Flags

The CLI provides granular control over cache refresh behavior:

- **`--refresh`**: Force refresh of cached analysis data
- **`--refresh-all`**: Refresh all cached data regardless of staleness
- **`--refresh-type <type>`**: Refresh only specific analysis types
- **`--no-refresh`**: Disable automatic refresh entirely

### Dry Run Mode

The `--dry-run` flag allows you to preview uninstall or refresh operations without making permanent changes to your configuration files or data directory. This is useful for verifying what actions the tool would take before committing to them.

## Visualization UI Configuration

The [`code_review_graph/visualization.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/visualization.py) module generates an interactive HTML interface for exploring the knowledge graph. While not configured via static files, the UI exposes runtime options through HTML elements such as the **flow selector** (`<select id="flow-select">`) and dynamic option lists populated at runtime.

These UI elements allow you to filter and navigate the generated graph without modifying underlying configuration files, providing an interactive layer on top of the static MCP and CLI settings.

## Summary

- **MCP Configuration**: Define servers in [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json) or user-level files (`~/.qwen/settings.json`, `~/.codex/config.toml`) using the `mcpServers` key
- **Editor Hooks**: Generate hook configurations via `generate_hooks_config()` and related functions in [`code_review_graph/skills.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/skills.py) to automate tool execution during editor events
- **TypeScript Support**: Configure `baseUrl` and `paths` in your [`tsconfig.json`](https://github.com/tirth8205/code-review-graph/blob/main/tsconfig.json); [`code_review_graph/tsconfig_resolver.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/tsconfig_resolver.py) automatically respects these settings
- **CLI Control**: Use `--data-dir` for custom data locations, `--refresh` flags for cache management, and `--dry-run` for safe operation previews
- **UI Options**: Interact with the generated visualization through runtime HTML selectors rather than file-based configuration

## Frequently Asked Questions

### How do I configure code-review-graph as an MCP server?

Add a `code-review-graph` entry under the `mcpServers` key in either [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json) at your repository root or in user-level configuration files such as `~/.qwen/settings.json` or `~/.codex/config.toml`. Each entry must specify the `type`, `command`, and `args` required to launch the server.

### What CLI flags control cache refresh behavior?

According to [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py), you can use `--refresh` to force a refresh, `--refresh-all` to update all cached data, `--refresh-type <type>` to target specific analysis types, or `--no-refresh` to disable automatic refreshing entirely.

### Where does code-review-graph read TypeScript path mappings?

The [`code_review_graph/tsconfig_resolver.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/tsconfig_resolver.py) module reads your project's [`tsconfig.json`](https://github.com/tirth8205/code-review-graph/blob/main/tsconfig.json) file and extracts the `baseUrl` and `paths` fields from the `compilerOptions` section. This allows the tool to resolve module imports correctly during code analysis.

### Can I preview changes before applying hook configurations?

Yes. Use the `--dry-run` flag when running CLI commands to simulate uninstall or refresh operations without modifying your actual configuration files or data directory. This executes the logic but prevents permanent changes, as implemented in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py).