@supermodeltools/mcp-server 0.8.1 → 0.9.1

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.
package/README.md CHANGED
@@ -4,14 +4,12 @@
4
4
  [![MCP](https://img.shields.io/badge/MCP-compatible-blue)](https://modelcontextprotocol.io)
5
5
  [![CI](https://github.com/supermodeltools/mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/supermodeltools/mcp/actions/workflows/ci.yml)
6
6
 
7
- MCP server that provides deep codebase analysis to AI agents via the [Supermodel API](https://docs.supermodeltools.com). Enables Claude to understand code structure, dependencies, and relationships by generating comprehensive graphs from any repository. Use this to help AI agents explore unfamiliar code, plan refactorings, assess change impact, and understand system architecture.
7
+ MCP server that gives AI agents instant codebase understanding via the [Supermodel API](https://docs.supermodeltools.com). Two tools `overview` and `symbol_context` backed by pre-computed code graphs for sub-second responses.
8
8
 
9
9
  ## Install
10
10
 
11
11
  ### Quick Setup (Recommended)
12
12
 
13
- Run the setup script to configure the recommended timeout settings:
14
-
15
13
  ```bash
16
14
  curl -sSL https://raw.githubusercontent.com/supermodeltools/mcp/main/setup.sh | bash
17
15
  ```
@@ -22,13 +20,8 @@ curl -sSL https://raw.githubusercontent.com/supermodeltools/mcp/main/setup.sh |
22
20
  Download, review, then execute:
23
21
 
24
22
  ```bash
25
- # Download the script
26
23
  curl -sSL https://raw.githubusercontent.com/supermodeltools/mcp/main/setup.sh -o setup.sh
27
-
28
- # Review the contents
29
24
  cat setup.sh
30
-
31
- # Make executable and run
32
25
  chmod +x setup.sh
33
26
  ./setup.sh
34
27
  ```
@@ -43,8 +36,6 @@ cd mcp
43
36
 
44
37
  </details>
45
38
 
46
- This will configure `MCP_TOOL_TIMEOUT=900000` for optimal performance with large codebases.
47
-
48
39
  ### Manual Install
49
40
 
50
41
  ```bash
@@ -57,45 +48,6 @@ Or run directly:
57
48
  npx @supermodeltools/mcp-server
58
49
  ```
59
50
 
60
- ## ⚠️ Important: Configure Timeout for Large Codebase Analysis
61
-
62
- The `explore_codebase` tool can take **5-15 minutes** to analyze large repositories. Most MCP clients have a default timeout of 60-120 seconds, which will cause the operation to fail prematurely.
63
-
64
- **Quick Setup:**
65
-
66
- Add this to your shell profile to set a 15-minute timeout:
67
-
68
- ```bash
69
- export MCP_TOOL_TIMEOUT=900000
70
- ```
71
-
72
- **Installation by Client:**
73
-
74
- <details>
75
- <summary><strong>Claude Code CLI</strong></summary>
76
-
77
- Add to your shell profile (`~/.zshrc` for macOS or `~/.bashrc` for Linux):
78
-
79
- ```bash
80
- export MCP_TOOL_TIMEOUT=900000
81
- ```
82
-
83
- Then reload your shell:
84
-
85
- ```bash
86
- source ~/.zshrc # or ~/.bashrc
87
- ```
88
-
89
- Verify it's set:
90
-
91
- ```bash
92
- echo $MCP_TOOL_TIMEOUT
93
- ```
94
-
95
- </details>
96
-
97
- **Note:** Timeout configuration via `MCP_TOOL_TIMEOUT` is only supported in Claude Code CLI. For more details, see the [official Claude Code documentation](https://code.claude.com/docs/en/settings.md).
98
-
99
51
  ## Configuration
100
52
 
101
53
  Get your API key from the [Supermodel Dashboard](https://dashboard.supermodeltools.com).
@@ -104,33 +56,19 @@ Get your API key from the [Supermodel Dashboard](https://dashboard.supermodeltoo
104
56
  |----------|-------------|
105
57
  | `SUPERMODEL_API_KEY` | Your Supermodel API key (required) |
106
58
  | `SUPERMODEL_BASE_URL` | Override API base URL (optional) |
59
+ | `SUPERMODEL_CACHE_DIR` | Directory for pre-computed graph cache files (optional) |
60
+ | `SUPERMODEL_TIMEOUT_MS` | API request timeout in ms (default: 900000 / 15 min) |
61
+ | `SUPERMODEL_NO_API_FALLBACK` | Set to disable on-demand API calls; cache-only mode (optional) |
107
62
 
108
63
  ### Global Setup (Recommended)
109
64
 
110
- Instead of adding your API key to each MCP config file, you can set it globally in your shell profile. This keeps your key in one place and automatically makes it available to all MCP clients.
111
-
112
- **For Zsh (macOS default):**
113
-
114
- Add to `~/.zshrc`:
115
-
116
- ```bash
117
- export SUPERMODEL_API_KEY="your-api-key"
118
- ```
119
-
120
- **For Bash:**
121
-
122
- Add to `~/.bashrc` or `~/.bash_profile`:
65
+ Set your API key globally in your shell profile so it's available to all MCP clients:
123
66
 
124
67
  ```bash
68
+ # Add to ~/.zshrc (macOS) or ~/.bashrc (Linux)
125
69
  export SUPERMODEL_API_KEY="your-api-key"
126
70
  ```
127
71
 
128
- Then reload your shell:
129
-
130
- ```bash
131
- source ~/.zshrc # or ~/.bashrc
132
- ```
133
-
134
72
  With the API key set globally, you can omit the `env` block from your MCP configs:
135
73
 
136
74
  ```json
@@ -144,36 +82,26 @@ With the API key set globally, you can omit the `env` block from your MCP config
144
82
  }
145
83
  ```
146
84
 
147
- ### Default Working Directory (Optional)
148
-
149
- For automated benchmarking tools (like mcpbr) or batch processing, you can specify a default working directory as a command-line argument. When provided, the `explore_codebase` tool will use this directory automatically if no explicit `directory` parameter is given.
85
+ ## Usage
150
86
 
151
- **Command-line usage:**
87
+ ### Claude Code CLI
152
88
 
153
89
  ```bash
154
- npx @supermodeltools/mcp-server /path/to/repository
90
+ claude mcp add supermodel --env SUPERMODEL_API_KEY=your-api-key -- npx -y @supermodeltools/mcp-server
155
91
  ```
156
92
 
157
- or with Node.js:
93
+ Or if `SUPERMODEL_API_KEY` is already set in your shell environment:
158
94
 
159
95
  ```bash
160
- node dist/index.js /path/to/repository
96
+ claude mcp add supermodel -- npx -y @supermodeltools/mcp-server
161
97
  ```
162
98
 
163
- **Example with benchmarking tools:**
99
+ Verify installation:
164
100
 
165
- ```yaml
166
- mcp_server:
167
- command: "npx"
168
- args: ["-y", "@supermodeltools/mcp-server", "{workdir}"]
169
- env:
170
- SUPERMODEL_API_KEY: "${SUPERMODEL_API_KEY}"
101
+ ```bash
102
+ claude mcp list
171
103
  ```
172
104
 
173
- This allows the agent to call `explore_codebase()` without specifying a directory parameter, automatically using the configured default workdir. You can still override it by explicitly passing a `directory` parameter in individual tool calls.
174
-
175
- ## Usage
176
-
177
105
  ### Cursor
178
106
 
179
107
  Add to `~/.cursor/mcp.json`:
@@ -192,472 +120,106 @@ Add to `~/.cursor/mcp.json`:
192
120
  }
193
121
  ```
194
122
 
195
- ### Claude Code CLI
196
-
197
- Add the MCP server with your API key:
198
-
199
- ```bash
200
- claude mcp add supermodel --env SUPERMODEL_API_KEY=your-api-key -- npx -y @supermodeltools/mcp-server
201
- ```
123
+ ### Default Working Directory
202
124
 
203
- Or if `SUPERMODEL_API_KEY` is already set in your shell environment:
125
+ For benchmarking tools or batch processing, pass a default working directory as a CLI argument:
204
126
 
205
127
  ```bash
206
- claude mcp add supermodel -- npx -y @supermodeltools/mcp-server
207
- ```
208
-
209
- Verify installation:
210
-
211
- ```bash
212
- claude mcp list
213
- ```
214
-
215
- ## Health Checks
216
-
217
- This MCP server implements the [MCP ping utility](https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/ping) for connection health monitoring. The ping mechanism allows clients to verify that the server is responsive and the connection remains alive.
218
-
219
- ### How It Works
220
-
221
- - **Request**: Client sends a `ping` JSON-RPC request with no parameters
222
- - **Response**: Server responds promptly with an empty result object `{}`
223
- - **Automatic**: Handled automatically by the MCP SDK - no additional configuration needed
224
-
225
- ### Use Cases
226
-
227
- - **Pre-flight checks**: Verify server is accessible before starting work
228
- - **Connection monitoring**: Detect stale connections during long-running sessions
229
- - **Periodic health checks**: Confirm server remains responsive
230
-
231
- ### Example
232
-
233
- ```json
234
- // Request
235
- {
236
- "jsonrpc": "2.0",
237
- "id": "123",
238
- "method": "ping"
239
- }
240
-
241
- // Response
242
- {
243
- "jsonrpc": "2.0",
244
- "id": "123",
245
- "result": {}
246
- }
128
+ npx @supermodeltools/mcp-server /path/to/repository
247
129
  ```
248
130
 
249
- If the server doesn't respond within a reasonable timeout (typically 5-10 seconds), the connection should be considered stale.
250
-
251
- For more details, see the [MCP specification for ping/health checks](https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/ping).
131
+ Tools will use this directory automatically if no explicit `directory` parameter is given.
252
132
 
253
133
  ## Tools
254
134
 
255
- ### `explore_codebase`
135
+ ### `overview`
256
136
 
257
- Analyzes code structure, dependencies, and relationships across a repository. Use this to understand unfamiliar codebases, plan refactorings, assess change impact, or map system architecture.
137
+ Returns a pre-computed architectural map of the codebase in sub-second time. Call this first on any new task.
258
138
 
259
- **When to use:**
260
- - Exploring new codebases
261
- - Planning refactors or architectural changes
262
- - Understanding dependencies between modules
263
- - Mapping call relationships and code flow
264
- - Assessing the impact of proposed changes
265
-
266
- **What you get:**
267
- - Dependency graphs (module/package relationships)
268
- - Call graphs (function-level call hierarchies)
269
- - Domain classifications (architectural patterns)
270
- - AST relationships (structural analysis)
271
- - Summary statistics (languages, complexity, file counts)
139
+ **Output includes:**
140
+ - Top architectural domains and their key files
141
+ - Most-called hub functions (call graph centrality)
142
+ - File, function, and class counts
143
+ - Primary language and graph statistics
272
144
 
273
145
  **Parameters:**
274
146
 
275
147
  | Argument | Type | Required | Description |
276
148
  |----------|------|----------|-------------|
277
- | `directory` | string | Yes* | Path to repository directory (automatic zipping) |
278
- | `file` | string | Yes* | Path to pre-zipped archive (deprecated) |
279
- | `query` | string | No | Query type (summary, search, list_nodes, etc.) |
280
- | `jq_filter` | string | No | jq filter for custom data extraction |
281
-
282
- \* Either `directory` (recommended) or `file` must be provided
149
+ | `directory` | string | No | Path to repository directory. Omit if server was started with a default workdir. |
283
150
 
284
151
  **Example prompts:**
285
- - "Analyze the codebase at . to understand its architecture"
286
- - "Before I refactor the authentication module, analyze this repo to show me what depends on it"
287
- - "What's the structure of the codebase in /Users/me/project?"
288
-
289
- **Automatic features:**
290
- - Respects `.gitignore` patterns automatically
291
- - Excludes sensitive files (`.env`, `*.pem`, credentials, etc.)
292
- - Skips dependencies (`node_modules`, `venv`, `vendor`)
293
- - Removes build outputs (`dist`, `build`, `out`)
294
- - Cleans up temporary files automatically
295
- - Cross-platform compatible
296
-
297
- ### Individual Graph Tools
298
-
299
- For targeted analysis, use these specialized tools instead of the comprehensive `explore_codebase`:
300
-
301
- #### `get_call_graph`
302
-
303
- Generate a function-level call graph showing caller/callee relationships.
304
-
305
- **Use this to:**
306
- - Find all functions that call a specific function
307
- - Find all functions called by a specific function
308
- - Trace call chains through the codebase
309
- - Understand function dependencies
310
-
311
- **Parameters:**
312
-
313
- | Argument | Type | Required | Description |
314
- |----------|------|----------|-------------|
315
- | `directory` | string | Yes | Path to repository directory |
316
- | `jq_filter` | string | No | jq filter for custom data extraction |
317
-
318
- #### `get_dependency_graph`
319
-
320
- Generate a module-level dependency graph showing import relationships.
321
-
322
- **Use this to:**
323
- - Understand module dependencies
324
- - Find circular dependencies
325
- - Identify tightly coupled modules
326
- - Plan module extraction or refactoring
327
-
328
- **Parameters:**
329
-
330
- | Argument | Type | Required | Description |
331
- |----------|------|----------|-------------|
332
- | `directory` | string | Yes | Path to repository directory |
333
- | `jq_filter` | string | No | jq filter for custom data extraction |
334
-
335
- #### `get_domain_graph`
336
-
337
- Generate a high-level domain classification graph.
338
-
339
- **Use this to:**
340
- - Understand the architectural domains in a codebase
341
- - See how code is organized into logical areas
342
- - Get a bird's-eye view of system structure
343
- - Identify domain boundaries
344
-
345
- **Parameters:**
346
-
347
- | Argument | Type | Required | Description |
348
- |----------|------|----------|-------------|
349
- | `directory` | string | Yes | Path to repository directory |
350
- | `jq_filter` | string | No | jq filter for custom data extraction |
351
-
352
- #### `get_parse_graph`
353
-
354
- Generate an AST-level parse graph with fine-grained code structure.
355
-
356
- **Use this to:**
357
- - Analyze detailed code structure
358
- - Find specific syntax patterns
359
- - Understand class/function definitions at AST level
360
- - Support precise refactoring operations
361
-
362
- **Parameters:**
363
-
364
- | Argument | Type | Required | Description |
365
- |----------|------|----------|-------------|
366
- | `directory` | string | Yes | Path to repository directory |
367
- | `jq_filter` | string | No | jq filter for custom data extraction |
368
-
369
- ### Task-Specific Query Tools
370
-
371
- After generating a graph with any of the tools above, use these lightweight tools for focused queries. They run against the cached graph and return small, targeted results (<10KB, <5s).
372
-
373
- #### `find_call_sites`
374
-
375
- Find all locations where a specific function is called.
376
-
377
- **Parameters:**
378
-
379
- | Argument | Type | Required | Description |
380
- |----------|------|----------|-------------|
381
- | `path` | string | Yes | Path that was previously analyzed |
382
- | `function_name` | string | Yes | Name of the function to find call sites for |
383
- | `include_context` | boolean | No | Include surrounding code context |
384
- | `max_results` | number | No | Maximum number of results to return |
152
+ - "Give me an overview of this codebase"
153
+ - "What's the architecture of this project?"
385
154
 
386
- #### `trace_call_chain`
155
+ ### `symbol_context`
387
156
 
388
- Find the shortest call path from function A to function B using BFS.
157
+ Deep dive on a specific function, class, or method. Given a symbol name, instantly returns its definition location, all callers, all callees, domain membership, and related symbols in the same file.
389
158
 
390
- **Parameters:**
391
-
392
- | Argument | Type | Required | Description |
393
- |----------|------|----------|-------------|
394
- | `path` | string | Yes | Path that was previously analyzed |
395
- | `from_function` | string | Yes | Starting function name |
396
- | `to_function` | string | Yes | Target function name |
397
- | `max_depth` | number | No | Maximum search depth |
398
-
399
- #### `find_definition`
400
-
401
- Locate where a symbol (function, class, variable, type) is defined.
159
+ **Output includes:**
160
+ - Definition location (file, line range)
161
+ - Callers (who calls this symbol)
162
+ - Callees (what this symbol calls)
163
+ - Architectural domain membership
164
+ - Related symbols in the same file
165
+ - File import statistics
402
166
 
403
167
  **Parameters:**
404
168
 
405
169
  | Argument | Type | Required | Description |
406
170
  |----------|------|----------|-------------|
407
- | `path` | string | Yes | Path that was previously analyzed |
408
- | `name` | string | Yes | Symbol name to find |
409
- | `type` | string | No | Symbol type: function, class, variable, or type |
410
-
411
- #### `trace_data_flow`
412
-
413
- Track how data flows through function parameters and variables.
414
-
415
- **Parameters:**
416
-
417
- | Argument | Type | Required | Description |
418
- |----------|------|----------|-------------|
419
- | `path` | string | Yes | Path that was previously analyzed |
420
- | `variable` | string | Yes | Variable or parameter name to trace |
421
- | `function_name` | string | No | Starting function for the trace |
422
- | `max_depth` | number | No | Maximum trace depth |
423
-
424
- ### Feedback Tools
425
-
426
- #### `request_feature`
427
-
428
- Open a feature request issue on the supermodeltools/mcp GitHub repository. Requires a `GITHUB_TOKEN` environment variable with `public_repo` scope.
429
-
430
- #### `report_bug`
431
-
432
- Report a bug or unexpected behavior by opening an issue on the supermodeltools/mcp GitHub repository. Requires a `GITHUB_TOKEN` environment variable with `public_repo` scope.
433
-
434
- ### Choosing the Right Tool
435
-
436
- | Tool | Best For | Output Size |
437
- |------|----------|-------------|
438
- | `explore_codebase` | Comprehensive analysis with built-in queries | Largest - all graph types |
439
- | `get_call_graph` | Function call tracing, debugging | Medium - functions only |
440
- | `get_dependency_graph` | Module refactoring, circular deps | Small - modules only |
441
- | `get_domain_graph` | Architecture overview | Smallest - domains only |
442
- | `get_parse_graph` | AST analysis, precise refactoring | Large - full AST |
443
- | `find_call_sites` | Where is function X called? | Small (<10KB) |
444
- | `trace_call_chain` | Path from function A to B | Small (<10KB) |
445
- | `find_definition` | Where is symbol X defined? | Small (<10KB) |
446
- | `trace_data_flow` | How does data flow through params? | Small (<10KB) |
447
-
448
- **Tip:** Start with `get_domain_graph` for a quick architecture overview, then use task-specific query tools (`find_call_sites`, `trace_call_chain`, etc.) for focused questions. Drill down with `get_call_graph` or `get_dependency_graph` for broader analysis.
449
-
450
- > **Note:** All graph tools accept a `directory` parameter and an optional `jq_filter`. Task-specific query tools use `path` instead. If you start the server with a default working directory (`node dist/index.js /path/to/repo`), directory arguments can be omitted from tool calls.
451
-
452
- ## Tool Performance & Timeout Requirements
453
-
454
- The `explore_codebase` tool analyzes your entire repository to build a comprehensive code graph. Analysis time scales with repository size and complexity.
455
-
456
- | Tool | Typical Duration | Recommended Timeout | Repository Size |
457
- |------|------------------|---------------------|--------------------|
458
- | `explore_codebase` | 2-5 min | 600000ms (10 min) | Small (<1k files) |
459
- | `explore_codebase` | 5-10 min | 900000ms (15 min) | Medium (1k-10k files) |
460
- | `explore_codebase` | 10-15 min | 1200000ms (20 min) | Large (10k+ files) |
461
-
462
- **Default recommendation**: The server uses a 15-minute timeout (`900000ms`) by default, which works well for most medium-sized repositories.
463
-
464
- **Caching behavior**: The first run analyzes your codebase and caches the results. Subsequent queries on the same repository are typically much faster (seconds instead of minutes) as they use the cached graph.
465
-
466
- **Setting custom timeouts**: If you need to adjust the timeout for larger repositories, you can set the `SUPERMODEL_TIMEOUT_MS` environment variable:
467
-
468
- ```json
469
- {
470
- "mcpServers": {
471
- "supermodel": {
472
- "command": "npx",
473
- "args": ["-y", "@supermodeltools/mcp-server"],
474
- "env": {
475
- "SUPERMODEL_API_KEY": "your-api-key",
476
- "SUPERMODEL_TIMEOUT_MS": "1200000"
477
- }
478
- }
479
- }
480
- }
481
- ```
482
-
483
- ## Troubleshooting
484
-
485
- ### Timeout Errors
486
-
487
- #### "Request timeout"
488
-
489
- **Cause:** The analysis is taking longer than your MCP client's timeout allows (varies by client—Claude Code CLI defaults to ~2 minutes, Claude Desktop enforces 5 minutes). Large repositories or complex codebases may require more time to analyze.
490
-
491
- **Solutions:**
492
-
493
- 1. **Analyze a subdirectory instead** - Target specific parts of your codebase:
494
- ```bash
495
- # Instead of analyzing the entire repo
496
- explore_codebase(directory="/path/to/repo")
497
-
498
- # Analyze just the core module
499
- explore_codebase(directory="/path/to/repo/src/core")
500
- ```
501
-
502
- 2. **Increase your MCP client timeout** - For Claude Code CLI, set the `MCP_TOOL_TIMEOUT` environment variable:
503
-
504
- ```bash
505
- # Set timeout to 15 minutes (900000ms) for large codebase analysis
506
- export MCP_TOOL_TIMEOUT=900000
507
- ```
508
-
509
- Then reload your shell or start a new terminal session. This timeout applies to all MCP tool executions.
510
-
511
- **Note:** Timeout configuration is currently only supported in Claude Code CLI.
512
-
513
- 3. **Verify `.gitignore` excludes build artifacts** - Ensure your repository excludes:
514
- - `node_modules/`, `vendor/`, `venv/`
515
- - `dist/`, `build/`, `out/`
516
- - `.next/`, `.nuxt/`, `.cache/`
517
-
518
- The MCP server automatically excludes these patterns when zipping, but `.gitignore` prevents them from being in your working directory in the first place—both improve performance and reduce analysis size.
519
-
520
- #### "Analysis interrupted mid-way"
521
-
522
- **Cause:** Network interruption or the MCP server process was terminated before completion.
523
-
524
- **Solutions:**
525
-
526
- 1. **Check MCP server logs** - Logs location varies by client:
527
-
528
- > **Note:** Log filenames match your MCP server name from the config. If you named it differently (e.g., `my-server`), look for `mcp-server-my-server.log` instead of `mcp-server-supermodel.log`.
529
-
530
- **Claude Desktop (macOS):**
531
- ```bash
532
- tail -f ~/Library/Logs/Claude/mcp-server-supermodel.log
533
- ```
534
-
535
- **Claude Desktop (Windows):**
536
- ```powershell
537
- Get-Content "$env:APPDATA\Claude\Logs\mcp-server-supermodel.log" -Wait
538
- ```
539
-
540
- **Claude Desktop (Linux):**
541
- ```bash
542
- tail -f ~/.config/Claude/logs/mcp-server-supermodel.log
543
- ```
544
-
545
- **Cursor:**
546
- ```bash
547
- # Check the Cursor logs directory
548
- tail -f ~/Library/Application\ Support/Cursor/logs/mcp-server-supermodel.log
549
- ```
171
+ | `symbol` | string | Yes | Name of the function, class, or method. Supports `ClassName.method` syntax and partial matching. |
172
+ | `directory` | string | No | Path to repository directory. Omit if server was started with a default workdir. |
550
173
 
551
- **Claude Code:**
552
- ```bash
553
- # Logs are shown in the terminal when running with verbose mode
554
- claude --verbose
555
- ```
556
-
557
- 2. **Retry the analysis** - Temporary network issues often resolve on retry
174
+ **Example prompts:**
175
+ - "Look up the symbol `filter_queryset` in this codebase"
176
+ - "What calls `QuerySet.filter` and what does it call?"
558
177
 
559
- 3. **Check your internet connection** - The analysis requires a stable connection to the Supermodel API
178
+ ### Recommended Workflow
560
179
 
561
- 4. **Verify the API is accessible:**
562
- ```bash
563
- curl -H "Authorization: Bearer YOUR_API_KEY" https://api.supermodeltools.com/health
564
- ```
180
+ 1. Call `overview` to understand the codebase architecture
181
+ 2. Read the issue/bug description and identify relevant domains and symbols
182
+ 3. Call `symbol_context` on key symbols to understand their structural context
183
+ 4. Use Read/Grep to examine the actual source code at the identified locations
184
+ 5. Make your fix and verify with tests
565
185
 
566
- #### "ERROR Request failed. Check the MCP server logs"
186
+ ## Pre-computed Graphs
567
187
 
568
- **Multiple possible causes:**
188
+ For fastest performance, pre-compute graphs ahead of time using the `precache` CLI subcommand. This calls the Supermodel API once and saves the result to disk, enabling sub-second tool responses with no API calls at runtime.
569
189
 
570
- ##### 1. Missing or invalid API key
190
+ ### Pre-compute a graph
571
191
 
572
- Check if your API key is set:
573
192
  ```bash
574
- echo $SUPERMODEL_API_KEY
193
+ npx @supermodeltools/mcp-server precache /path/to/repo --output-dir ./supermodel-cache
575
194
  ```
576
195
 
577
- Verify it's valid at [Supermodel Dashboard](https://dashboard.supermodeltools.com).
578
-
579
- **Solution:**
580
- ```bash
581
- # Set in your shell profile (~/.zshrc or ~/.bashrc)
582
- export SUPERMODEL_API_KEY="your-api-key"
583
- source ~/.zshrc
584
-
585
- # Or update your MCP client config with the correct key
586
- ```
587
-
588
- ##### 2. API service outage or rate limiting
589
-
590
- Check the error details in logs (see log locations above).
196
+ Options:
197
+ - `--output-dir <dir>` — Directory to save the cache file (default: `./supermodel-cache` or `SUPERMODEL_CACHE_DIR`)
198
+ - `--name <name>` — Repository name for the cache key (default: auto-detected from git remote + commit hash)
591
199
 
592
- **Solution:**
593
- - Visit [Supermodel Status](https://status.supermodeltools.com) for service status
594
- - If rate limited, wait a few minutes before retrying
595
- - Consider upgrading your API plan if hitting rate limits frequently
200
+ ### Use cached graphs at runtime
596
201
 
597
- ##### 3. Repository too large
598
-
599
- The API has size limits for analysis. Check the [Supermodel documentation](https://docs.supermodeltools.com) for current limits.
600
-
601
- **Solution:**
602
202
  ```bash
603
- # Check your repo size
604
- du -sh /path/to/repo
605
-
606
- # If too large, analyze subdirectories instead
607
- explore_codebase(directory="/path/to/repo/src")
203
+ SUPERMODEL_CACHE_DIR=./supermodel-cache npx @supermodeltools/mcp-server
608
204
  ```
609
205
 
610
- ##### 4. Network or firewall issues
611
-
612
- Corporate firewalls may block outbound requests to the Supermodel API.
613
-
614
- **Solution:**
615
- - Test connectivity: `curl https://api.supermodeltools.com/health`
616
- - Check firewall rules allow HTTPS to `api.supermodeltools.com`
617
- - Contact your IT department if behind a corporate proxy
618
-
619
- ### Debug Logging
620
-
621
- Debug logs go to stderr and include:
206
+ The server loads all cached graphs from `SUPERMODEL_CACHE_DIR` at startup. If no cache exists for a given repository, the server falls back to an on-demand API call (which takes 5-15 minutes for large repos).
622
207
 
623
- - `[DEBUG] Server configuration:` - Startup config
624
- - `[DEBUG] Auto-zipping directory:` - Starting zip creation
625
- - `[DEBUG] Auto-zip complete:` - Zip stats (file count, size)
626
- - `[DEBUG] Making API request` - Request details
627
- - `[ERROR] API call failed:` - Error details with HTTP status
208
+ ### Startup precaching
628
209
 
629
- To enable verbose logging, set the `DEBUG` environment variable:
210
+ Use the `--precache` flag to automatically generate and cache the graph for the default workdir on server startup:
630
211
 
631
212
  ```bash
632
- # In your MCP config
633
- {
634
- "mcpServers": {
635
- "supermodel": {
636
- "command": "npx",
637
- "args": ["-y", "@supermodeltools/mcp-server"],
638
- "env": {
639
- "SUPERMODEL_API_KEY": "your-api-key",
640
- "DEBUG": "supermodel:*"
641
- }
642
- }
643
- }
644
- }
213
+ npx @supermodeltools/mcp-server /path/to/repo --precache
645
214
  ```
646
215
 
647
- ### Common Issues
648
-
649
- - **401 Unauthorized:** Check `SUPERMODEL_API_KEY` is set correctly
650
- - **ZIP too large:** Directory contains too many files/dependencies. Ensure `.gitignore` is configured properly
651
- - **Permission denied:** Check read permissions on the directory
652
- - **Insufficient disk space:** Free up space in your system's temp directory
653
- - **Directory does not exist:** Verify the path is correct and absolute
654
- - **ENOTFOUND or connection errors:** Check your internet connection and firewall settings
216
+ This is useful in automated environments (e.g., Docker containers for benchmarking) where you want the graph ready before any tool calls.
655
217
 
656
218
  ## Benchmarking
657
219
 
658
- Benchmark this MCP server using [mcpbr](https://github.com/caspianmoon/mcpbr-benchmark-caching) with the provided [`mcpbr-config.yaml`](./mcpbr-config.yaml) configuration.
220
+ Benchmark this MCP server using [mcpbr](https://github.com/greynewell/mcpbr) with the provided [`mcpbr-config.yaml`](./mcpbr-config.yaml) configuration.
659
221
 
660
- ## Local Development & Testing
222
+ ## Local Development
661
223
 
662
224
  ### Building from Source
663
225
 
@@ -671,23 +233,17 @@ npm run build
671
233
  ### Running Locally
672
234
 
673
235
  ```bash
674
- # Start the MCP server
675
- node dist/index.js
676
-
677
- # Or with a default working directory
678
- node dist/index.js /path/to/repo
236
+ node dist/index.js # Start MCP server
237
+ node dist/index.js /path/to/repo # With default workdir
238
+ node dist/index.js precache /path/to/repo # Pre-compute graph
679
239
  ```
680
240
 
681
- ### Testing Tools Locally
682
-
683
- Run the integration tests to verify the server and tools:
241
+ ### Running Tests
684
242
 
685
243
  ```bash
686
- # Run all tests including integration tests
687
- npm test
688
-
689
- # Run only integration tests
690
- npm test -- src/server.integration.test.ts
244
+ npm test # Run all tests
245
+ npm run test:coverage # Run with coverage
246
+ npm run typecheck # Type checking
691
247
  ```
692
248
 
693
249
  ### Using MCP Inspector
@@ -695,29 +251,42 @@ npm test -- src/server.integration.test.ts
695
251
  For interactive testing, use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
696
252
 
697
253
  ```bash
698
- # Install the inspector
699
- npm install -g @modelcontextprotocol/inspector
700
-
701
- # Run with your server
702
254
  npx @modelcontextprotocol/inspector node dist/index.js
703
255
  ```
704
256
 
705
- This opens a web UI where you can:
706
- - See all available tools
707
- - Call tools with custom arguments
708
- - View responses in real-time
257
+ ## Troubleshooting
709
258
 
710
- ### Running Tests
259
+ ### Timeout Errors
711
260
 
712
- ```bash
713
- # Run all tests
714
- npm test
261
+ The first analysis of a repository requires an API call that can take 5-15 minutes. If your MCP client times out:
262
+
263
+ 1. **Pre-compute the graph** — Use `precache` to generate the graph ahead of time (see [Pre-computed Graphs](#pre-computed-graphs))
264
+ 2. **Increase your MCP client timeout** — For Claude Code CLI, set `MCP_TOOL_TIMEOUT=900000` in your shell profile
265
+ 3. **Analyze a subdirectory** — Target specific parts of your codebase to reduce analysis time
266
+
267
+ ### Common Issues
268
+
269
+ - **401 Unauthorized:** Check `SUPERMODEL_API_KEY` is set correctly
270
+ - **Permission denied:** Check read permissions on the directory
271
+ - **ENOTFOUND or connection errors:** Check your internet connection and firewall settings
272
+
273
+ ### Debug Logging
715
274
 
716
- # Run with coverage
717
- npm run test:coverage
275
+ Set the `DEBUG` environment variable for verbose logging:
718
276
 
719
- # Type checking
720
- npm run typecheck
277
+ ```json
278
+ {
279
+ "mcpServers": {
280
+ "supermodel": {
281
+ "command": "npx",
282
+ "args": ["-y", "@supermodeltools/mcp-server"],
283
+ "env": {
284
+ "SUPERMODEL_API_KEY": "your-api-key",
285
+ "DEBUG": "supermodel:*"
286
+ }
287
+ }
288
+ }
289
+ }
721
290
  ```
722
291
 
723
292
  ## Links