codecompass-mcp 2.4.0__tar.gz → 2.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/PKG-INFO +129 -1
  2. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/README.md +127 -0
  3. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/codecompass_mcp.egg-info/PKG-INFO +129 -1
  4. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/codecompass_mcp.egg-info/SOURCES.txt +4 -0
  5. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/codecompass_mcp.egg-info/entry_points.txt +1 -0
  6. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/codecompass_mcp.egg-info/requires.txt +1 -0
  7. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/codecompass_mcp.egg-info/top_level.txt +1 -0
  8. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/graph/code_query_cli.py +231 -117
  9. codecompass_mcp-2.6.0/ingestion/description_enricher.py +189 -0
  10. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/main.py +222 -10
  11. codecompass_mcp-2.6.0/mcp_server.py +228 -0
  12. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/pyproject.toml +4 -2
  13. codecompass_mcp-2.6.0/tests/test_description_enricher.py +95 -0
  14. codecompass_mcp-2.6.0/tests/test_mcp_server.py +102 -0
  15. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/LICENSE +0 -0
  16. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/codecompass_mcp.egg-info/dependency_links.txt +0 -0
  17. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/config.py +0 -0
  18. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/graph/__init__.py +0 -0
  19. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/graph/cli.py +0 -0
  20. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/graph/code_graph_client.py +0 -0
  21. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/graph/setup.py +0 -0
  22. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/__init__.py +0 -0
  23. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/chunker.py +0 -0
  24. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/code_normalizer.py +0 -0
  25. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/code_parser.py +0 -0
  26. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/entity_resolver.py +0 -0
  27. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/file_watcher.py +0 -0
  28. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/graph_writer.py +0 -0
  29. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/hierarchy_builder.py +0 -0
  30. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/reader_agent.py +0 -0
  31. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/ingestion/source_context.py +0 -0
  32. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/models/__init__.py +0 -0
  33. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/models/code_types.py +0 -0
  34. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/models/types.py +0 -0
  35. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/setup.cfg +0 -0
  36. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/tests/test_batch_impact.py +0 -0
  37. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/tests/test_blast_radius.py +0 -0
  38. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/tests/test_code_parser.py +0 -0
  39. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/tests/test_ingestion.py +0 -0
  40. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/tests/test_lit_css_parser.py +0 -0
  41. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/tests/test_php_parser.py +0 -0
  42. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/utils/__init__.py +0 -0
  43. {codecompass_mcp-2.4.0 → codecompass_mcp-2.6.0}/utils/formatting.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codecompass-mcp
3
- Version: 2.4.0
3
+ Version: 2.6.0
4
4
  Summary: Structural code context for AI coding agents — a local code knowledge graph for blast radius, impact, deps, dead code, and flow tracing
5
5
  Author: CodeCompass contributors
6
6
  License: MIT
@@ -18,6 +18,7 @@ Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: anthropic>=0.40.0
21
+ Requires-Dist: fastmcp>=2.0.0
21
22
  Requires-Dist: networkx>=3.0
22
23
  Requires-Dist: pypdf2>=3.0.0
23
24
  Requires-Dist: python-dotenv>=1.0.0
@@ -132,6 +133,35 @@ All commands default to the current directory.
132
133
  pip install codecompass-mcp
133
134
  ```
134
135
 
136
+ This gives you:
137
+ - the `codecompass` CLI
138
+ - the `codecompass-mcp` MCP server binary
139
+
140
+ ### Connect to an MCP client
141
+
142
+ The server speaks stdio MCP. It defaults to the process's current working directory, so if the client starts it inside a project it just works. To query a different project, the agent calls `set_repo`.
143
+
144
+ **Claude Desktop** — add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
145
+
146
+ ```json
147
+ {
148
+ "mcpServers": {
149
+ "codecompass": {
150
+ "command": "codecompass-mcp"
151
+ }
152
+ }
153
+ }
154
+ ```
155
+
156
+ **Cline / Cursor / other clients** — add a server with command `codecompass-mcp`.
157
+
158
+ Then ask the agent to run:
159
+
160
+ ```
161
+ Use the codecompass MCP server. If you need to switch projects, set_repo to /path/to/project, then query ...
162
+ ```
163
+
164
+ If you prefer a fixed default repo, set `CODECOMPASS_REPO=/path/to/project` in the MCP server environment. The server auto-initializes `.codecompass/` if missing. Call the `ingest()` tool from the agent to keep the graph up to date, or run `codecompass ingest-code` inside the project first.
135
165
 
136
166
  ### Index a project
137
167
 
@@ -159,6 +189,65 @@ Any AI agent that reads `AGENTS.md` (Claude Code, OpenCode, Cursor, etc.) will f
159
189
 
160
190
  ---
161
191
 
192
+ ## Hard enforcement for Claude Code & Pi (optional)
193
+
194
+ `AGENTS.md` is an instruction — a well-behaved agent follows it, but nothing
195
+ stops it from reaching for `grep`/`cat` out of habit. If you want that
196
+ actually blocked instead of just discouraged, both Claude Code and
197
+ [pi](https://pi.dev) support hard tool-call enforcement via hooks/extensions.
198
+
199
+ The block only covers what codecompass unambiguously replaces — searching or
200
+ reading code content (`grep`, `rg`, `cat`, the `Grep` tool). `ls`/`find` are
201
+ left alone; they have legitimate non-code uses (checking build output,
202
+ confirming a generated file exists, listing fixtures) that the graph doesn't
203
+ cover. Guide that judgment call with a decision-rule note in your agent
204
+ instructions rather than blocking it — see the `AGENTS.md` this tool
205
+ generates for the exact wording.
206
+
207
+ ### Claude Code
208
+
209
+ Add a `PreToolUse` hook in `.claude/settings.json`:
210
+
211
+ ```json
212
+ {
213
+ "hooks": {
214
+ "PreToolUse": [
215
+ { "matcher": "Bash", "hooks": [{ "type": "command", "command": "python3 .claude/hooks/block-file-search.py" }] },
216
+ { "matcher": "Grep", "hooks": [{ "type": "command", "command": "python3 .claude/hooks/block-file-search.py" }] }
217
+ ]
218
+ }
219
+ }
220
+ ```
221
+
222
+ `.claude/hooks/block-file-search.py` reads the tool call from stdin, blocks
223
+ `Grep` and `cat`/`grep`/`rg` inside `Bash` (exit code `2`, with the reason
224
+ printed to stderr so Claude sees it and redirects to codecompass), and
225
+ allows everything else.
226
+
227
+ ### Pi
228
+
229
+ Two files:
230
+
231
+ - `.pi/APPEND_SYSTEM.md` — appended to the system prompt every session,
232
+ stating the codecompass-first rule plus the graph-vs-`ls` decision rule.
233
+ - `.pi/extensions/codecompass-guard.ts` — a `tool_call` handler that blocks
234
+ the `grep` tool and `cat`/`grep`/`rg` inside `bash`.
235
+
236
+ ### Activating
237
+
238
+ Neither of these hot-reload into an already-running session:
239
+
240
+ - **Claude Code** — start a new session in the repo; accept the trust prompt
241
+ (hooks execute shell commands, so Claude Code asks first).
242
+ - **Pi** — project-local `.pi/` resources only load after the project is
243
+ trusted. Accept the trust prompt on startup, or run `/trust` and restart
244
+ `pi` once.
245
+
246
+ After that one-time trust, both pick the files up automatically on every
247
+ future session in the repo — nothing to re-inject manually.
248
+
249
+ ---
250
+
162
251
  ## Queries
163
252
 
164
253
  | Command | When to use it |
@@ -219,6 +308,45 @@ All commands default to `.` (current directory) when path is omitted.
219
308
 
220
309
  ---
221
310
 
311
+ ## MCP server
312
+
313
+ CodeCompass also runs as an MCP server so compatible clients can call graph queries as tools instead of parsing CLI output.
314
+
315
+ ### Run the server
316
+
317
+ ```bash
318
+ # Serve the current directory's graph over stdio (default MCP transport)
319
+ codecompass-mcp
320
+
321
+ # Serve a specific repo
322
+ CODECOMPASS_REPO=/path/to/repo codecompass-mcp
323
+
324
+ # Or use the CLI subcommand
325
+ codecompass mcp /path/to/repo
326
+ ```
327
+
328
+ ### Available tools
329
+
330
+ | Tool | What it returns |
331
+ |---|---|
332
+ | `set_repo(repo_path)` | Select the project to query (defaults to cwd) |
333
+ | `get_repo()` | The currently selected project |
334
+ | `init()` | Create `.codecompass/` and write `AGENTS.md` |
335
+ | `ingest()` | Re-index the repo |
336
+ | `blast_radius(target, hops=3)` | Files reachable from a file or symbol |
337
+ | `batch_impact(targets, hops=3)` | Union of blast radii for multiple targets |
338
+ | `impact(symbol, hops=3)` | Callers and importers of a symbol |
339
+ | `deps(file_path, hops=3)` | What a file imports or depends on |
340
+ | `trace(symbol, hops=3)` | Forward call chain from a symbol |
341
+ | `styles(element)` | CSS selectors that style an element |
342
+ | `flow(entry_symbol, hops=3, format="json", include_external=False)` | Call/import flow trace (json, mermaid, or drawio) |
343
+ | `dead_code(include_entrypoints=False)` | Entities with no inbound caller |
344
+ | `tree()` | Full project hierarchy |
345
+
346
+ Configure your MCP client (Claude Desktop, Cline, etc.) to run `codecompass-mcp` in the repo you want to query.
347
+
348
+ ---
349
+
222
350
  ## Supported languages
223
351
 
224
352
  | Language | Entity types extracted |
@@ -95,6 +95,35 @@ All commands default to the current directory.
95
95
  pip install codecompass-mcp
96
96
  ```
97
97
 
98
+ This gives you:
99
+ - the `codecompass` CLI
100
+ - the `codecompass-mcp` MCP server binary
101
+
102
+ ### Connect to an MCP client
103
+
104
+ The server speaks stdio MCP. It defaults to the process's current working directory, so if the client starts it inside a project it just works. To query a different project, the agent calls `set_repo`.
105
+
106
+ **Claude Desktop** — add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "codecompass": {
112
+ "command": "codecompass-mcp"
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ **Cline / Cursor / other clients** — add a server with command `codecompass-mcp`.
119
+
120
+ Then ask the agent to run:
121
+
122
+ ```
123
+ Use the codecompass MCP server. If you need to switch projects, set_repo to /path/to/project, then query ...
124
+ ```
125
+
126
+ If you prefer a fixed default repo, set `CODECOMPASS_REPO=/path/to/project` in the MCP server environment. The server auto-initializes `.codecompass/` if missing. Call the `ingest()` tool from the agent to keep the graph up to date, or run `codecompass ingest-code` inside the project first.
98
127
 
99
128
  ### Index a project
100
129
 
@@ -122,6 +151,65 @@ Any AI agent that reads `AGENTS.md` (Claude Code, OpenCode, Cursor, etc.) will f
122
151
 
123
152
  ---
124
153
 
154
+ ## Hard enforcement for Claude Code & Pi (optional)
155
+
156
+ `AGENTS.md` is an instruction — a well-behaved agent follows it, but nothing
157
+ stops it from reaching for `grep`/`cat` out of habit. If you want that
158
+ actually blocked instead of just discouraged, both Claude Code and
159
+ [pi](https://pi.dev) support hard tool-call enforcement via hooks/extensions.
160
+
161
+ The block only covers what codecompass unambiguously replaces — searching or
162
+ reading code content (`grep`, `rg`, `cat`, the `Grep` tool). `ls`/`find` are
163
+ left alone; they have legitimate non-code uses (checking build output,
164
+ confirming a generated file exists, listing fixtures) that the graph doesn't
165
+ cover. Guide that judgment call with a decision-rule note in your agent
166
+ instructions rather than blocking it — see the `AGENTS.md` this tool
167
+ generates for the exact wording.
168
+
169
+ ### Claude Code
170
+
171
+ Add a `PreToolUse` hook in `.claude/settings.json`:
172
+
173
+ ```json
174
+ {
175
+ "hooks": {
176
+ "PreToolUse": [
177
+ { "matcher": "Bash", "hooks": [{ "type": "command", "command": "python3 .claude/hooks/block-file-search.py" }] },
178
+ { "matcher": "Grep", "hooks": [{ "type": "command", "command": "python3 .claude/hooks/block-file-search.py" }] }
179
+ ]
180
+ }
181
+ }
182
+ ```
183
+
184
+ `.claude/hooks/block-file-search.py` reads the tool call from stdin, blocks
185
+ `Grep` and `cat`/`grep`/`rg` inside `Bash` (exit code `2`, with the reason
186
+ printed to stderr so Claude sees it and redirects to codecompass), and
187
+ allows everything else.
188
+
189
+ ### Pi
190
+
191
+ Two files:
192
+
193
+ - `.pi/APPEND_SYSTEM.md` — appended to the system prompt every session,
194
+ stating the codecompass-first rule plus the graph-vs-`ls` decision rule.
195
+ - `.pi/extensions/codecompass-guard.ts` — a `tool_call` handler that blocks
196
+ the `grep` tool and `cat`/`grep`/`rg` inside `bash`.
197
+
198
+ ### Activating
199
+
200
+ Neither of these hot-reload into an already-running session:
201
+
202
+ - **Claude Code** — start a new session in the repo; accept the trust prompt
203
+ (hooks execute shell commands, so Claude Code asks first).
204
+ - **Pi** — project-local `.pi/` resources only load after the project is
205
+ trusted. Accept the trust prompt on startup, or run `/trust` and restart
206
+ `pi` once.
207
+
208
+ After that one-time trust, both pick the files up automatically on every
209
+ future session in the repo — nothing to re-inject manually.
210
+
211
+ ---
212
+
125
213
  ## Queries
126
214
 
127
215
  | Command | When to use it |
@@ -182,6 +270,45 @@ All commands default to `.` (current directory) when path is omitted.
182
270
 
183
271
  ---
184
272
 
273
+ ## MCP server
274
+
275
+ CodeCompass also runs as an MCP server so compatible clients can call graph queries as tools instead of parsing CLI output.
276
+
277
+ ### Run the server
278
+
279
+ ```bash
280
+ # Serve the current directory's graph over stdio (default MCP transport)
281
+ codecompass-mcp
282
+
283
+ # Serve a specific repo
284
+ CODECOMPASS_REPO=/path/to/repo codecompass-mcp
285
+
286
+ # Or use the CLI subcommand
287
+ codecompass mcp /path/to/repo
288
+ ```
289
+
290
+ ### Available tools
291
+
292
+ | Tool | What it returns |
293
+ |---|---|
294
+ | `set_repo(repo_path)` | Select the project to query (defaults to cwd) |
295
+ | `get_repo()` | The currently selected project |
296
+ | `init()` | Create `.codecompass/` and write `AGENTS.md` |
297
+ | `ingest()` | Re-index the repo |
298
+ | `blast_radius(target, hops=3)` | Files reachable from a file or symbol |
299
+ | `batch_impact(targets, hops=3)` | Union of blast radii for multiple targets |
300
+ | `impact(symbol, hops=3)` | Callers and importers of a symbol |
301
+ | `deps(file_path, hops=3)` | What a file imports or depends on |
302
+ | `trace(symbol, hops=3)` | Forward call chain from a symbol |
303
+ | `styles(element)` | CSS selectors that style an element |
304
+ | `flow(entry_symbol, hops=3, format="json", include_external=False)` | Call/import flow trace (json, mermaid, or drawio) |
305
+ | `dead_code(include_entrypoints=False)` | Entities with no inbound caller |
306
+ | `tree()` | Full project hierarchy |
307
+
308
+ Configure your MCP client (Claude Desktop, Cline, etc.) to run `codecompass-mcp` in the repo you want to query.
309
+
310
+ ---
311
+
185
312
  ## Supported languages
186
313
 
187
314
  | Language | Entity types extracted |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codecompass-mcp
3
- Version: 2.4.0
3
+ Version: 2.6.0
4
4
  Summary: Structural code context for AI coding agents — a local code knowledge graph for blast radius, impact, deps, dead code, and flow tracing
5
5
  Author: CodeCompass contributors
6
6
  License: MIT
@@ -18,6 +18,7 @@ Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: anthropic>=0.40.0
21
+ Requires-Dist: fastmcp>=2.0.0
21
22
  Requires-Dist: networkx>=3.0
22
23
  Requires-Dist: pypdf2>=3.0.0
23
24
  Requires-Dist: python-dotenv>=1.0.0
@@ -132,6 +133,35 @@ All commands default to the current directory.
132
133
  pip install codecompass-mcp
133
134
  ```
134
135
 
136
+ This gives you:
137
+ - the `codecompass` CLI
138
+ - the `codecompass-mcp` MCP server binary
139
+
140
+ ### Connect to an MCP client
141
+
142
+ The server speaks stdio MCP. It defaults to the process's current working directory, so if the client starts it inside a project it just works. To query a different project, the agent calls `set_repo`.
143
+
144
+ **Claude Desktop** — add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
145
+
146
+ ```json
147
+ {
148
+ "mcpServers": {
149
+ "codecompass": {
150
+ "command": "codecompass-mcp"
151
+ }
152
+ }
153
+ }
154
+ ```
155
+
156
+ **Cline / Cursor / other clients** — add a server with command `codecompass-mcp`.
157
+
158
+ Then ask the agent to run:
159
+
160
+ ```
161
+ Use the codecompass MCP server. If you need to switch projects, set_repo to /path/to/project, then query ...
162
+ ```
163
+
164
+ If you prefer a fixed default repo, set `CODECOMPASS_REPO=/path/to/project` in the MCP server environment. The server auto-initializes `.codecompass/` if missing. Call the `ingest()` tool from the agent to keep the graph up to date, or run `codecompass ingest-code` inside the project first.
135
165
 
136
166
  ### Index a project
137
167
 
@@ -159,6 +189,65 @@ Any AI agent that reads `AGENTS.md` (Claude Code, OpenCode, Cursor, etc.) will f
159
189
 
160
190
  ---
161
191
 
192
+ ## Hard enforcement for Claude Code & Pi (optional)
193
+
194
+ `AGENTS.md` is an instruction — a well-behaved agent follows it, but nothing
195
+ stops it from reaching for `grep`/`cat` out of habit. If you want that
196
+ actually blocked instead of just discouraged, both Claude Code and
197
+ [pi](https://pi.dev) support hard tool-call enforcement via hooks/extensions.
198
+
199
+ The block only covers what codecompass unambiguously replaces — searching or
200
+ reading code content (`grep`, `rg`, `cat`, the `Grep` tool). `ls`/`find` are
201
+ left alone; they have legitimate non-code uses (checking build output,
202
+ confirming a generated file exists, listing fixtures) that the graph doesn't
203
+ cover. Guide that judgment call with a decision-rule note in your agent
204
+ instructions rather than blocking it — see the `AGENTS.md` this tool
205
+ generates for the exact wording.
206
+
207
+ ### Claude Code
208
+
209
+ Add a `PreToolUse` hook in `.claude/settings.json`:
210
+
211
+ ```json
212
+ {
213
+ "hooks": {
214
+ "PreToolUse": [
215
+ { "matcher": "Bash", "hooks": [{ "type": "command", "command": "python3 .claude/hooks/block-file-search.py" }] },
216
+ { "matcher": "Grep", "hooks": [{ "type": "command", "command": "python3 .claude/hooks/block-file-search.py" }] }
217
+ ]
218
+ }
219
+ }
220
+ ```
221
+
222
+ `.claude/hooks/block-file-search.py` reads the tool call from stdin, blocks
223
+ `Grep` and `cat`/`grep`/`rg` inside `Bash` (exit code `2`, with the reason
224
+ printed to stderr so Claude sees it and redirects to codecompass), and
225
+ allows everything else.
226
+
227
+ ### Pi
228
+
229
+ Two files:
230
+
231
+ - `.pi/APPEND_SYSTEM.md` — appended to the system prompt every session,
232
+ stating the codecompass-first rule plus the graph-vs-`ls` decision rule.
233
+ - `.pi/extensions/codecompass-guard.ts` — a `tool_call` handler that blocks
234
+ the `grep` tool and `cat`/`grep`/`rg` inside `bash`.
235
+
236
+ ### Activating
237
+
238
+ Neither of these hot-reload into an already-running session:
239
+
240
+ - **Claude Code** — start a new session in the repo; accept the trust prompt
241
+ (hooks execute shell commands, so Claude Code asks first).
242
+ - **Pi** — project-local `.pi/` resources only load after the project is
243
+ trusted. Accept the trust prompt on startup, or run `/trust` and restart
244
+ `pi` once.
245
+
246
+ After that one-time trust, both pick the files up automatically on every
247
+ future session in the repo — nothing to re-inject manually.
248
+
249
+ ---
250
+
162
251
  ## Queries
163
252
 
164
253
  | Command | When to use it |
@@ -219,6 +308,45 @@ All commands default to `.` (current directory) when path is omitted.
219
308
 
220
309
  ---
221
310
 
311
+ ## MCP server
312
+
313
+ CodeCompass also runs as an MCP server so compatible clients can call graph queries as tools instead of parsing CLI output.
314
+
315
+ ### Run the server
316
+
317
+ ```bash
318
+ # Serve the current directory's graph over stdio (default MCP transport)
319
+ codecompass-mcp
320
+
321
+ # Serve a specific repo
322
+ CODECOMPASS_REPO=/path/to/repo codecompass-mcp
323
+
324
+ # Or use the CLI subcommand
325
+ codecompass mcp /path/to/repo
326
+ ```
327
+
328
+ ### Available tools
329
+
330
+ | Tool | What it returns |
331
+ |---|---|
332
+ | `set_repo(repo_path)` | Select the project to query (defaults to cwd) |
333
+ | `get_repo()` | The currently selected project |
334
+ | `init()` | Create `.codecompass/` and write `AGENTS.md` |
335
+ | `ingest()` | Re-index the repo |
336
+ | `blast_radius(target, hops=3)` | Files reachable from a file or symbol |
337
+ | `batch_impact(targets, hops=3)` | Union of blast radii for multiple targets |
338
+ | `impact(symbol, hops=3)` | Callers and importers of a symbol |
339
+ | `deps(file_path, hops=3)` | What a file imports or depends on |
340
+ | `trace(symbol, hops=3)` | Forward call chain from a symbol |
341
+ | `styles(element)` | CSS selectors that style an element |
342
+ | `flow(entry_symbol, hops=3, format="json", include_external=False)` | Call/import flow trace (json, mermaid, or drawio) |
343
+ | `dead_code(include_entrypoints=False)` | Entities with no inbound caller |
344
+ | `tree()` | Full project hierarchy |
345
+
346
+ Configure your MCP client (Claude Desktop, Cline, etc.) to run `codecompass-mcp` in the repo you want to query.
347
+
348
+ ---
349
+
222
350
  ## Supported languages
223
351
 
224
352
  | Language | Entity types extracted |
@@ -2,6 +2,7 @@ LICENSE
2
2
  README.md
3
3
  config.py
4
4
  main.py
5
+ mcp_server.py
5
6
  pyproject.toml
6
7
  codecompass_mcp.egg-info/PKG-INFO
7
8
  codecompass_mcp.egg-info/SOURCES.txt
@@ -18,6 +19,7 @@ ingestion/__init__.py
18
19
  ingestion/chunker.py
19
20
  ingestion/code_normalizer.py
20
21
  ingestion/code_parser.py
22
+ ingestion/description_enricher.py
21
23
  ingestion/entity_resolver.py
22
24
  ingestion/file_watcher.py
23
25
  ingestion/graph_writer.py
@@ -30,8 +32,10 @@ models/types.py
30
32
  tests/test_batch_impact.py
31
33
  tests/test_blast_radius.py
32
34
  tests/test_code_parser.py
35
+ tests/test_description_enricher.py
33
36
  tests/test_ingestion.py
34
37
  tests/test_lit_css_parser.py
38
+ tests/test_mcp_server.py
35
39
  tests/test_php_parser.py
36
40
  utils/__init__.py
37
41
  utils/formatting.py
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
2
  codecompass = graph.cli:main
3
+ codecompass-mcp = mcp_server:main
@@ -1,4 +1,5 @@
1
1
  anthropic>=0.40.0
2
+ fastmcp>=2.0.0
2
3
  networkx>=3.0
3
4
  pypdf2>=3.0.0
4
5
  python-dotenv>=1.0.0
@@ -2,5 +2,6 @@ config
2
2
  graph
3
3
  ingestion
4
4
  main
5
+ mcp_server
5
6
  models
6
7
  utils