callgraph-mcp 1.4.1 → 1.4.3

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 (2) hide show
  1. package/README.md +37 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -8,6 +8,8 @@ Powered by [`@codeflow-map/core`](https://www.npmjs.com/package/@codeflow-map/co
8
8
 
9
9
  **Supports:** TypeScript · JavaScript · TSX · JSX · Python · Go
10
10
 
11
+ ![Cyclic call graph demo](https://raw.githubusercontent.com/devricky-codes/callgraph-mcp/refs/heads/main/assets/cyclic.gif)
12
+
11
13
  > **Bundled grammars:** TypeScript, JavaScript, TSX, JSX, Python, and Go grammars are included. After install, they are available in `callgraph-mcp/grammars`.
12
14
 
13
15
  ---
@@ -16,15 +18,15 @@ Powered by [`@codeflow-map/core`](https://www.npmjs.com/package/@codeflow-map/co
16
18
 
17
19
  Most AI coding tools answer structural questions about your codebase by reading source files as text and reasoning over them. This causes three compounding failure modes:
18
20
 
19
- **Hallucination.** When asked "what calls `processPayment`?", a model without structural grounding will guess based on naming patterns and training priors. It will confidently name callers that don't exist and miss ones that do. The larger the codebase, the worse this gets.
21
+ - **Hallucination.** When asked "what calls `processPayment`?", a model without structural grounding will guess based on naming patterns and training priors. It will confidently name callers that don't exist and miss ones that do.
22
+ - **Lost in the middle.** Research shows that LLMs systematically fail to recall information from the middle of long contexts. Paste a 200-file codebase into context and the model will answer based on whatever happened to land near the top or bottom.
23
+ - **Attention dilution.** Even when information is present, spreading the model's attention across tens of thousands of lines means each individual fact gets less weight. A critical edge in the call graph competed for attention with everything else.
20
24
 
21
- **Lost in the middle.** Research shows that LLMs systematically fail to recall information from the middle of long contexts. Paste a 200-file codebase into context and the model will answer based on whatever happened to land near the top or bottom. Functions buried in the middle of that context window are effectively invisible.
25
+ **callgraph-mcp eliminates all three.** It never reads your code as prose. It parses every file into an AST using Tree-sitter, builds an exact directed call graph, and answers structural queries against that graph. Every caller, every callee, every reachable function, every cycle - returned as a precise index. The answer is always the same regardless of how large your codebase is, which files happen to be in context, or how deeply buried a function is. **There is no probability involved. There is no attention to dilute.**
22
26
 
23
- **Attention dilution.** Even when information is present, spreading the model's attention across tens of thousands of lines means each individual fact gets less weight. A critical edge in the call graph mentioned once in one file competes for attention with everything else. The model's confidence in its answer has no relationship to whether the answer is correct.
27
+ ---
24
28
 
25
- **callgraph-mcp eliminates all three.** It never reads your code as prose. It parses every file into an AST using Tree-sitter, builds an exact directed call graph, and answers structural queries against that graph. Every caller, every callee, every reachable function, every cycle — returned as a precise index. The answer is always the same regardless of how large your codebase is, which files happen to be in context, or how deeply buried a function is. **There is no probability involved. There is no attention to dilute.**
26
29
 
27
- ---
28
30
 
29
31
 
30
32
  ## Setup
@@ -81,17 +83,21 @@ Then point your client at it:
81
83
 
82
84
  Optional parameters shown in `[brackets]`.
83
85
 
84
- | Tool | Parameters | Returns |
85
- |------|-----------|---------|
86
- | `flowmap_analyze_workspace` | `workspacePath`, [`exclude`], [`language`] | Full call graph: nodes, edges, flows, orphans |
87
- | `flowmap_analyze_file` | `filePath` | Functions and call sites in one file |
88
- | `flowmap_get_callers` | `functionName`, `workspacePath` | Direct callers of the function |
89
- | `flowmap_get_callees` | `functionName`, `workspacePath` | Functions the named function calls |
90
- | `flowmap_get_flow` | `functionName`, `workspacePath`, [`maxDepth`=10] | Full BFS subgraph reachable from a function |
91
- | `flowmap_list_entry_points` | `workspacePath` | Mains, route handlers, CLI commands, React roots |
92
- | `flowmap_find_orphans` | `workspacePath` | Functions unreachable from any entry point |
93
- | `flowmap_find_cycles` | `workspacePath`, [`minCycleLength`], [`exclude`] | All circular call chains with exact edges |
94
- | `flowmap_find_duplicates` *(experimental)* | `workspacePath`, [`similarityThreshold`=0.75], [`minCallees`=2], [`exclude`] | Function clusters with similar callee sets |
86
+ <table>
87
+ <colgroup><col width="22%"><col width="38%"><col width="40%"></colgroup>
88
+ <thead><tr><th>Tool</th><th>Parameters</th><th>Returns</th></tr></thead>
89
+ <tbody>
90
+ <tr><td><code>flowmap_analyze_workspace</code></td><td><code>workspacePath</code>, [<code>exclude</code>], [<code>language</code>]</td><td>Full call graph: nodes, edges, flows, orphans</td></tr>
91
+ <tr><td><code>flowmap_analyze_file</code></td><td><code>filePath</code></td><td>Functions and call sites in one file</td></tr>
92
+ <tr><td><code>flowmap_get_callers</code></td><td><code>functionName</code>, <code>workspacePath</code></td><td>Direct callers of the function</td></tr>
93
+ <tr><td><code>flowmap_get_callees</code></td><td><code>functionName</code>, <code>workspacePath</code></td><td>Functions the named function calls</td></tr>
94
+ <tr><td><code>flowmap_get_flow</code></td><td><code>functionName</code>, <code>workspacePath</code>, [<code>maxDepth</code>=10]</td><td>Full BFS subgraph reachable from a function</td></tr>
95
+ <tr><td><code>flowmap_list_entry_points</code></td><td><code>workspacePath</code></td><td>Mains, route handlers, CLI commands, React roots</td></tr>
96
+ <tr><td><code>flowmap_find_orphans</code></td><td><code>workspacePath</code></td><td>Functions unreachable from any entry point</td></tr>
97
+ <tr><td><code>flowmap_find_cycles</code></td><td><code>workspacePath</code>, [<code>minCycleLength</code>], [<code>exclude</code>]</td><td>All circular call chains with exact edges</td></tr>
98
+ <tr><td><code>flowmap_find_duplicates</code> <em>(experimental)</em></td><td><code>workspacePath</code>, [<code>similarityThreshold</code>=0.75], [<code>minCallees</code>=2], [<code>exclude</code>]</td><td>Function clusters with similar callee sets</td></tr>
99
+ </tbody>
100
+ </table>
95
101
 
96
102
  **`workspacePath`** — absolute path to the repo root (e.g. `/home/user/my-project` or `C:\projects\my-app`).
97
103
 
@@ -99,13 +105,17 @@ Optional parameters shown in `[brackets]`.
99
105
 
100
106
  ## Environment Variable Reference
101
107
 
102
- | Variable | Default | Description |
103
- |----------|---------|-------------|
104
- | `FLOWMAP_TRANSPORT` | `stdio` | `stdio` or `http` |
105
- | `FLOWMAP_PORT` | `3100` | HTTP port (http transport only) |
106
- | `FLOWMAP_GRAMMARS` | *(bundled)* | Override path to WASM grammar files |
107
- | `FLOWMAP_DUP_THRESHOLD` | `0.75` | Jaccard similarity threshold for `find_duplicates` (0–1) |
108
- | `FLOWMAP_DUP_MIN_CALLEES` | `2` | Min callee count for `find_duplicates` |
108
+ <table>
109
+ <colgroup><col width="22%"><col width="15%"><col width="63%"></colgroup>
110
+ <thead><tr><th>Variable</th><th>Default</th><th>Description</th></tr></thead>
111
+ <tbody>
112
+ <tr><td><code>FLOWMAP_TRANSPORT</code></td><td><code>stdio</code></td><td><code>stdio</code> or <code>http</code></td></tr>
113
+ <tr><td><code>FLOWMAP_PORT</code></td><td><code>3100</code></td><td>HTTP port (http transport only)</td></tr>
114
+ <tr><td><code>FLOWMAP_GRAMMARS</code></td><td><em>(bundled)</em></td><td>Override path to WASM grammar files</td></tr>
115
+ <tr><td><code>FLOWMAP_DUP_THRESHOLD</code></td><td><code>0.75</code></td><td>Jaccard similarity threshold for <code>find_duplicates</code> (0–1)</td></tr>
116
+ <tr><td><code>FLOWMAP_DUP_MIN_CALLEES</code></td><td><code>2</code></td><td>Min callee count for <code>find_duplicates</code></td></tr>
117
+ </tbody>
118
+ </table>
109
119
 
110
120
  ---
111
121
 
@@ -145,7 +155,7 @@ The agent calls `flowmap_find_cycles(workspacePath)`. Each cycle is returned as
145
155
 
146
156
  > *"I want to delete code safely. Give me every function that is provably unreachable — not called by anything, not an entry point. Include file and line number."*
147
157
 
148
- The agent calls `flowmap_find_orphans(workspacePath)`. This returns every function not reachable from any entry point in the call graph — with file path and line number for each one. These are not "probably unused" — they are graph-theoretically unreachable. Safe to delete. No cross-checking required.
158
+ The agent calls `flowmap_find_orphans(workspacePath)`. This returns every function not reachable from any entry point in the call graph — with file path and line number for each one.
149
159
 
150
160
  ---
151
161
 
@@ -173,14 +183,6 @@ The agent calls `flowmap_get_callers` for each modified function and `flowmap_ge
173
183
 
174
184
  ---
175
185
 
176
- ### Understand a single file before editing it
177
-
178
- > *"What does `src/auth/middleware.ts` export and what does it call?"*
179
-
180
- The agent calls `flowmap_analyze_file("/abs/path/to/src/auth/middleware.ts")` to get a precise list of every function, its parameters, return type, and all outgoing calls — without needing to read the file itself.
181
-
182
- ---
183
-
184
186
  ### Agentic code generation with structural guardrails
185
187
 
186
188
  When an agent is generating new code, it can call `flowmap_analyze_workspace` before and after to verify:
@@ -194,9 +196,9 @@ When an agent is generating new code, it can call `flowmap_analyze_workspace` be
194
196
 
195
197
  > *"We've been using an AI agent to build this codebase for 3 months. How much logic has it silently duplicated?"*
196
198
 
197
- Agents optimize for the current instruction, not long-term architecture. When a task requires shared logic, the agent rarely stops to ask "does this already exist?" — refactoring requires understanding dependencies and predicting side effects, which is harder than just writing new code that works. So it copies, tweaks slightly, and moves on. It satisfied the step. It made the problem worse.
199
+ Agents optimize for the current instruction, not long-term architecture. It copies, tweaks slightly, and moves on. It satisfied the local goal.
198
200
 
199
- The agent calls `flowmap_find_duplicates(workspacePath)`. Each cluster in the result is a group of functions with different names — often in different components — that call the same set of dependencies. That's the callee-set fingerprint of duplicated business logic. The output names exactly which functions to merge and which file to consolidate them into.
201
+ The agent calls `flowmap_find_duplicates(workspacePath)`. Each cluster in the result is a group of functions with different names — often in different components — that call the same set of dependencies.
200
202
 
201
203
  ---
202
204
 
@@ -204,9 +206,7 @@ The agent calls `flowmap_find_duplicates(workspacePath)`. Each cluster in the re
204
206
 
205
207
  > *"The agent has been adding features for weeks. Are there any circular call dependencies I should know about before this becomes a production problem?"*
206
208
 
207
- Agents don't track long-term call structure. When told to wire up a feature quickly, they take the fastest path: call whatever is needed, from wherever is convenient. Over time this creates circular dependencies — `A` calls `B` calls `C` calls `A` that are invisible until something breaks or hangs at runtime.
208
-
209
- The agent calls `flowmap_find_cycles(workspacePath)`. Every cycle is returned with the exact functions involved, their file locations, and the specific edges forming the loop. No guessing about which modules "seem" circular. The result tells you precisely where to break the chain.
209
+ The agent calls `flowmap_find_cycles(workspacePath)`. Every cycle is returned with the exact functions involved.
210
210
 
211
211
  ---
212
212
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "callgraph-mcp",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "MCP server for codebase call-flow analysis. Local, deterministic, language-agnostic. Powered by @codeflow-map/core.",
5
5
  "keywords": [
6
6
  "mcp",