symgraph 2026.6.14

Semantic code intelligence library and MCP server - build knowledge graphs of codebases
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# symgraph

[![CI](https://github.com/grahambrooks/symgraph/actions/workflows/ci.yml/badge.svg)](https://github.com/grahambrooks/symgraph/actions/workflows/ci.yml)
[![Release](https://github.com/grahambrooks/symgraph/actions/workflows/release.yml/badge.svg)](https://github.com/grahambrooks/symgraph/actions/workflows/release.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Rust](https://img.shields.io/badge/rust-1.70%2B-blue.svg)](https://www.rust-lang.org)
[![MCP](https://img.shields.io/badge/MCP-compatible-green.svg)](https://modelcontextprotocol.io)

Semantic code intelligence MCP server - build knowledge graphs of codebases to enhance AI-assisted code exploration.

symgraph is a rust implementation of https://github.com/colbymchenry/codegraph. Why? Ongoing exploration of compiled
binary deployment of MCP Servers.

## Features

- **Multi-language support**: Rust, TypeScript, JavaScript, Python, Go, Java, C, C++
- **Symbol extraction**: functions, classes, methods, structs, interfaces, traits, enums, constants
- **Relationship tracking**: calls, contains, imports, exports, extends, implements
- **Impact analysis**: trace the effect of changes through the codebase
- **Advanced code intelligence**:
    - Find call paths between functions
    - Detect unused/dead code
    - Explore class hierarchies
    - Locate all interface implementations
    - Analyze change impact by line range
- **Incremental indexing**: only re-indexes changed files using content hashing
- **Dual transport**: stdio (default) and HTTP server modes

## Installation

### macOS & Linux

```sh
curl -fsSL https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.sh | bash
```

To also configure symgraph as an MCP server for Claude Code and Claude Desktop:

```sh
curl -fsSL https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.sh | bash -s -- --mcp
```

Install a specific version:

```sh
SYMGRAPH_VERSION=2026.3.30 curl -fsSL https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.sh | bash
```

### Windows (PowerShell)

```powershell
irm https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.ps1 -OutFile install.ps1; .\install.ps1
```

To also configure symgraph as an MCP server for Claude Code and Claude Desktop:

```powershell
irm https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.ps1 -OutFile install.ps1; .\install.ps1 -Mcp
```

Install a specific version:

```powershell
$env:SYMGRAPH_VERSION="2026.3.30"; irm https://raw.githubusercontent.com/grahambrooks/symgraph/main/install.ps1 -OutFile install.ps1; .\install.ps1
```

Both scripts install to `~/.symgraph/bin/` by default. Override with `SYMGRAPH_INSTALL_DIR`.

### Claude Desktop (MCPB Bundle)

Download and install the MCPB bundle for your platform:

| Platform              | Download                                                                                   |
|-----------------------|--------------------------------------------------------------------------------------------|
| macOS (Apple Silicon) | [symgraph-x.x.x-darwin-arm64.mcpb]https://github.com/grahambrooks/symgraph/releases/latest |
| macOS (Intel)         | [symgraph-x.x.x-darwin-x64.mcpb]https://github.com/grahambrooks/symgraph/releases/latest   |
| Windows               | [symgraph-x.x.x-windows-x64.mcpb]https://github.com/grahambrooks/symgraph/releases/latest  |
| Linux                 | [symgraph-x.x.x-linux-x64.mcpb]https://github.com/grahambrooks/symgraph/releases/latest    |

1. Download the `.mcpb` file for your platform from [Releases]https://github.com/grahambrooks/symgraph/releases/latest
2. Open Claude Desktop
3. Drag and drop the `.mcpb` file onto Claude Desktop, or use **File > Install MCP Server**
4. Configure the project root when prompted

### From Source

```bash
git clone https://github.com/grahambrooks/symgraph
cd symgraph
make install
```

## Usage

### Index a Codebase

```bash
# Index current directory
symgraph index

# Index specific directory
symgraph index ~/projects/myapp
```

### Start MCP Server

```bash
# Start with stdio transport (for Claude Desktop)
symgraph serve

# Start with HTTP transport
symgraph serve --port 8080
```

### CLI Commands

Almost every MCP tool is also a CLI subcommand (handy for testing and for
agents driven by a CLI skill instead of MCP). Run `symgraph help` for the full
list with arguments and options.

```bash
# Core
symgraph index [path]                 # Index a codebase
symgraph serve [--port <PORT>]        # Start the MCP server (stdio / HTTP)
symgraph status [path]                # Show index statistics
symgraph search <query>               # Find symbols by name
symgraph context <task...>            # Build context for a task
symgraph where [path]                 # Show where the index is stored
symgraph prune                        # Remove stale cached indexes

# Symbol relationships (query the current project's index)
symgraph callers <symbol>             # Who calls this symbol
symgraph callees <symbol>             # What this symbol calls
symgraph references <symbol>          # All references to a symbol
symgraph node <symbol>                # Detailed symbol info
symgraph definition <symbol>          # Source of a symbol [--context-lines N]
symgraph hierarchy <symbol>           # Parent/child (contains) hierarchy
symgraph implementations <symbol>     # Interface/trait implementations
symgraph file <path>                  # Symbols defined in a file
symgraph path <from> <to>             # Call path(s) between two symbols
symgraph unused                       # Dead code (no incoming references)

# Impact, git history & coupling
symgraph impact <symbol> [--churn]    # Change impact + coupling breakdown
symgraph diff-impact [--git-ref REF]  # Impact of a region / diff
symgraph blame <symbol>               # git blame a symbol's definition
symgraph churn [path] [--days N]      # File change frequency (volatility)
symgraph module-graph [--granularity file|dir|module]   # Deps, fan-in/out, cycles
symgraph coupling-score [--churn]     # Rank coupling: strength × distance × volatility
symgraph god-struct [--churn]         # Structs ranked by architectural debt
symgraph dispatch-sites <enum>        # Files that match/switch on an enum
```

Add `--format json` for machine-readable output (supported by every command
except `blame`, `churn`, and `diff-impact`), and `--db <path>` to point at a
specific index database. The MCP tools accept the same `format: "json"`
argument — both surfaces render through one shared `ops` layer, so CLI and
server output match.

## MCP Tools

### Core Tools

| Tool                 | Description                                       |
|----------------------|---------------------------------------------------|
| `symgraph-context`    | Build focused code context for a specific task    |
| `symgraph-search`     | Quick symbol search by name                       |
| `symgraph-callers`    | Find all callers of a symbol                      |
| `symgraph-callees`    | Find all callees of a symbol                      |
| `symgraph-impact`     | Impact + inbound coupling breakdown (contract/model/intrusive) |
| `symgraph-node`       | Get detailed symbol information                   |
| `symgraph-definition` | Get the full source code of a symbol with context |
| `symgraph-file`       | List all symbols defined in a specific file       |
| `symgraph-references` | Find all references to a symbol                   |
| `symgraph-reindex`    | Trigger incremental reindexing of changed files   |
| `symgraph-status`     | Get index statistics                              |

### Advanced Tools

| Tool                      | Description                                             |
|---------------------------|---------------------------------------------------------|
| `symgraph-hierarchy`       | Get class/module hierarchy (parent/child relationships) |
| `symgraph-path`            | Find call paths between two symbols                     |
| `symgraph-unused`          | Find unused/dead code with no incoming references       |
| `symgraph-implementations` | Find all implementations of an interface/trait          |
| `symgraph-diff-impact`     | Analyze the impact of changing a specific code region   |

### Git-aware Tools

| Tool               | Description                                              |
|--------------------|---------------------------------------------------------|
| `symgraph-blame`   | Git blame a symbol's definition lines                   |
| `symgraph-churn`   | File change frequency over a recent window (volatility) |

### Coupling Analysis Tools

These fold the resolved graph onto the strength × distance × volatility
framework. Edges come from `accesses` (field reads), `mutates` (field
writes / `&mut`), `imports`, and enum-dispatch `references` — so **run
`symgraph-reindex` after code changes** to populate them. Resolution is
name-based (heuristic), best for ranking hotspots. All accept `format="json"`.

| Tool                      | Description                                                        |
|---------------------------|-------------------------------------------------------------------|
| `symgraph-module-graph`   | Dependency adjacency, fan-in/fan-out, and cycles (SCCs) at a `file`/`dir`/`module` boundary |
| `symgraph-coupling-score` | Rank module-pair coupling by strength × distance × volatility (churn) |
| `symgraph-god-struct`     | Rank structs/classes by pub-field × inbound-refs × churn (architectural debt) |
| `symgraph-dispatch-sites` | Find every file that matches/switches on an enum's members (control coupling) |

### Example Use Cases

**Find dead code for cleanup:**

```
Use symgraph-unused to find all unused functions and classes
```

**Understand function call chains:**

```
Use symgraph-path with from="main" and to="database_query" to see how data flows
```

**Assess change impact:**

```
Use symgraph-diff-impact with file_path="src/auth.rs" start_line=45 end_line=60
to see what would be affected by changes in that region
```

**Explore OOP hierarchies:**

```
Use symgraph-hierarchy with symbol="BaseHandler" to see all parent/child relationships
```

**Find all trait implementations:**

```
Use symgraph-implementations with symbol="Iterator" to find all structs implementing Iterator
```

## Project Setup

Add symgraph to your project in two steps: index your code, then configure your AI tool.

### Step 1: Index Your Project

```bash
cd /path/to/your/project
symgraph index
```

This creates a `.symgraph/` directory containing the SQLite knowledge graph. Add `.symgraph/` to your `.gitignore`.

Re-run `symgraph index` after significant code changes, or use the `symgraph-reindex` MCP tool to incrementally update from within your AI tool.

### Step 2: Configure Your AI Tool

#### Claude Code

Register symgraph as an MCP server for your project:

```bash
cd /path/to/your/project
claude mcp add symgraph -- symgraph serve
```

Or add `.mcp.json` to your project root:

```json
{
  "mcpServers": {
    "symgraph": {
      "type": "stdio",
      "command": "symgraph",
      "args": ["serve"]
    }
  }
}
```

**Optional: Add the `/explore-code` skill** for guided code exploration:

```bash
mkdir -p .claude/skills
cp -r /path/to/symgraph/.claude/skills/explore-code .claude/skills/
```

Then use it in Claude Code:

```
/explore-code how does the authentication middleware work?
/explore-code what would break if I changed the User struct?
```

#### Claude Desktop

**Via MCPB bundle (easiest):**

1. Download the `.mcpb` file for your platform from [Releases]https://github.com/grahambrooks/symgraph/releases/latest
2. Drag and drop onto Claude Desktop, or use **File > Install MCP Server**
3. Set the project root when prompted

**Via manual config** — add to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "symgraph": {
      "command": "symgraph",
      "args": ["serve"],
      "env": {
        "SYMGRAPH_ROOT": "/path/to/your/project"
      }
    }
  }
}
```

#### GitHub Copilot

**Per-repository** — add `.copilot/mcp.json` to your project:

```json
{
  "mcpServers": {
    "symgraph": {
      "command": "symgraph",
      "args": ["serve"]
    }
  }
}
```

**VS Code user settings** — add to `settings.json`:

```json
{
  "github.copilot.chat.mcp.servers": {
    "symgraph": {
      "command": "symgraph",
      "args": ["serve"],
      "env": {
        "SYMGRAPH_ROOT": "${workspaceFolder}"
      }
    }
  }
}
```

See [GitHub Copilot MCP documentation](https://docs.github.com/copilot/customizing-copilot/using-model-context-protocol/extending-copilot-chat-with-mcp) for more details.

#### OpenAI Codex

```bash
codex mcp add symgraph --command "symgraph" --args "serve"
```

Or add to `~/.codex/config.toml`:

```toml
[mcp_servers.symgraph]
command = "symgraph"
args = ["serve"]
```

See [OpenAI Codex MCP documentation](https://developers.openai.com/codex/mcp/) for more details.

#### HTTP Mode (Any MCP Client)

For shared or remote setups, run symgraph as an HTTP server:

```bash
symgraph serve --port 8080
```

Then point your MCP client at `http://localhost:8080/mcp`.

### Environment Variables

| Variable             | Description                                   | Default           |
|----------------------|-----------------------------------------------|-------------------|
| `SYMGRAPH_ROOT`      | Project root directory                        | Current directory |
| `SYMGRAPH_DB`        | Explicit index database path (highest priority) ||
| `SYMGRAPH_STORAGE`   | Index location strategy: `git` / `cache` / `local` | auto         |
| `SYMGRAPH_IN_MEMORY` | `1` ⇒ ephemeral in-memory index (no disk writes) | off            |
| `SYMGRAPH_AUTH_TOKEN`| Bearer token for HTTP `/mcp`                  ||

### Index Storage

The index is persistent and shared between the CLI and the MCP server, so you
`symgraph index` once and both use it. The location is resolved by this chain
(use `symgraph where` to see what's chosen):

1. **`--db <path>` / `SYMGRAPH_DB`** — explicit override.
2. **`--in-memory` / `SYMGRAPH_IN_MEMORY=1`** — ephemeral (good for long-running
   MCP sessions, CI, and read-only checkouts; rebuilt on start).
3. **`SYMGRAPH_STORAGE`** strategy, or the **auto** default:
   - reuse an existing `.symgraph/` if present (back-compat), else
   - **`git`**`<git-common-dir>/symgraph/index.db` — co-located with the repo,
     never tracked, **no `.gitignore` entry needed** (the default in a git repo;
     handles worktrees/submodules), else
   - **`cache`** → an OS cache dir keyed by the repo path (for non-git dirs).

`symgraph prune` removes cached indexes whose source repo no longer exists.
`local` storage writes a self-`.gitignore` so even in-tree indexes don't dirty
`git status`.

## Architecture

```
symgraph/
├── src/
│   ├── main.rs          # CLI entry point
│   ├── lib.rs           # Core indexing logic
│   ├── types.rs         # Type definitions (Node, Edge, etc.)
│   ├── db/              # SQLite database operations
│   ├── extraction/      # Tree-sitter code extraction
│   ├── graph/           # Graph traversal algorithms
│   ├── context/         # Context building for AI tasks
│   └── mcp/             # MCP protocol handlers
└── .symgraph/
    └── index.db         # SQLite database (per-project)
```

### Core Concepts

- **Node**: A code symbol (function, class, method, etc.)
- **Edge**: A relationship between nodes (calls, contains, imports, etc.)
- **Knowledge Graph**: The complete set of nodes and edges for a codebase

## Development

### Prerequisites

- Rust 1.70+
- SQLite (bundled via rusqlite)

### Building

```bash
make build           # Release build
make test            # Run tests
make check           # Format, lint, and test
make install         # Build and install to /usr/local/bin
```

### Project Structure

| Module       | Description                                                |
|--------------|------------------------------------------------------------|
| `types`      | Core type definitions (NodeKind, EdgeKind, Language, etc.) |
| `db`         | SQLite database schema and operations                      |
| `extraction` | Tree-sitter based code parsing and symbol extraction       |
| `graph`      | Graph algorithms (callers, callees, impact analysis)       |
| `context`    | Context builder for AI task assistance                     |
| `mcp`        | MCP protocol server implementation                         |

## License

MIT