# code-graph MCP server

> Indexes codebases into a structured AST knowledge graph to enable semantic search, call graph traversal, and impact analysis for AI coding assistants.

- Repository: https://github.com/sdsrss/code-graph-mcp
- Page: https://hostedmcp.org/servers/sdsrss/code-graph-mcp
- Transport: stdio
- Stars: 96
- License: MIT

## Install

### Claude Code

```sh
claude mcp add code-graph-mcp -- npx -y @sdsrs/code-graph
```

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

```json
{
  "mcpServers": {
    "code-graph-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@sdsrs/code-graph"
      ]
    }
  }
}
```

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

```json
{
  "servers": {
    "code-graph-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@sdsrs/code-graph"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"code-graph-mcp","type":"stdio","command":"npx","args":["-y","@sdsrs/code-graph"]}'
```

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

```json
{
  "mcpServers": {
    "code-graph-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@sdsrs/code-graph"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add code-graph-mcp -- npx -y @sdsrs/code-graph
```

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

```toml
[mcp_servers.code-graph-mcp]
command = "npx"
args = ["-y", "@sdsrs/code-graph"]
```

### Gemini CLI

```sh
gemini mcp add -s user code-graph-mcp npx -- -y @sdsrs/code-graph
```

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

```json
{
  "mcpServers": {
    "code-graph-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@sdsrs/code-graph"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `CODE_GRAPH_MODEL_DIR` | no | no |  |
| `CODE_GRAPH_QUIET_HOOKS` | no | no |  |

## Tools (7)

- `project_map`
- `semantic_code_search`
- `get_call_graph`
- `get_ast_node`
- `module_overview`
- `ast_search`
- `find_references`

## FAQ

### What programming languages are supported?

It supports a wide range of languages including TypeScript, JavaScript, Go, Python, Rust, Java, C#, Kotlin, Ruby, PHP, Swift, Dart, C, and C++, with varying levels of AST depth.

### How does it handle code changes?

It uses incremental indexing with Merkle tree change detection and a file system watcher to re-index only changed files.

### Can it trace HTTP routes?

Yes, it can map route paths to backend handler functions for Express/Connect, Flask/FastAPI, Go net/http, and Rust axum.
