@supermodeltools/mcp-server 0.9.1 → 0.9.2

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/dist/index.js CHANGED
@@ -214,6 +214,13 @@ async function handlePrecache(args) {
214
214
  console.error('');
215
215
  console.error('Done! To use this cache, set SUPERMODEL_CACHE_DIR=' + outputDir);
216
216
  }
217
+ // Graceful shutdown on signals (e.g., container stop, SSH drop)
218
+ for (const signal of ['SIGTERM', 'SIGINT']) {
219
+ process.on(signal, () => {
220
+ logger.debug(`Received ${signal}, shutting down`);
221
+ process.exit(0);
222
+ });
223
+ }
217
224
  main().catch((error) => {
218
225
  logger.error('Fatal error:', error);
219
226
  process.exit(1);
package/dist/server.js CHANGED
@@ -167,26 +167,27 @@ Supports partial matching and "ClassName.method" syntax.
167
167
  logger.warn('Failed to load cache directory:', err.message || err);
168
168
  }
169
169
  }
170
+ // Connect transport FIRST so the MCP handshake completes immediately.
171
+ // This prevents Claude Code from timing out the server (MCP_TIMEOUT=60s)
172
+ // when precaching requires a slow API call.
173
+ const transport = new stdio_js_1.StdioServerTransport();
174
+ await this.server.connect(transport);
175
+ logger.info('Supermodel MCP Server running on stdio');
170
176
  // Precache the workdir's repo if --precache flag is set.
171
- // Runs BEFORE noApiFallback is set so the API is available.
172
- // On first run for a repo this calls the Supermodel API (5-15 min).
173
- // The API has server-side idempotency caching, so repeated calls
174
- // with the same repo+commit return instantly. Results are saved to
175
- // cacheDir for cross-container persistence.
177
+ // Runs AFTER connect but BEFORE noApiFallback so the API is available.
178
+ // This is fire-and-forget from the MCP client's perspective tools
179
+ // that arrive before precaching finishes will use on-demand API calls.
176
180
  if (this.options?.precache && this.defaultWorkdir) {
177
181
  try {
178
182
  await (0, graph_cache_1.precacheForDirectory)(this.client, this.defaultWorkdir, cacheDir);
179
183
  }
180
184
  catch (err) {
181
- // Non-fatal: if precaching fails, tools fall back to no-cache error
185
+ // Non-fatal: if precaching fails, tools fall back to on-demand API
182
186
  logger.warn('Startup precache failed:', err.message || err);
183
187
  }
184
188
  }
185
189
  // NOW enable no-api-fallback (after precaching had its chance)
186
190
  (0, graph_cache_1.setNoApiFallback)(!!this.options?.noApiFallback);
187
- const transport = new stdio_js_1.StdioServerTransport();
188
- await this.server.connect(transport);
189
- logger.info('Supermodel MCP Server running on stdio');
190
191
  }
191
192
  }
192
193
  exports.Server = Server;
@@ -30,7 +30,8 @@ exports.tool = {
30
30
  },
31
31
  };
32
32
  const handler = async (client, args, defaultWorkdir) => {
33
- const directory = args?.directory ?? defaultWorkdir;
33
+ const rawDir = args?.directory;
34
+ const directory = (rawDir && rawDir.trim()) || defaultWorkdir || process.cwd();
34
35
  if (!directory || typeof directory !== 'string') {
35
36
  return (0, types_1.asErrorResult)({
36
37
  type: 'validation_error',
@@ -37,7 +37,8 @@ exports.tool = {
37
37
  };
38
38
  const handler = async (client, args, defaultWorkdir) => {
39
39
  const symbol = typeof args?.symbol === 'string' ? args.symbol.trim() : '';
40
- const directory = args?.directory ?? defaultWorkdir;
40
+ const rawDir = args?.directory;
41
+ const directory = (rawDir && rawDir.trim()) || defaultWorkdir || process.cwd();
41
42
  if (!symbol) {
42
43
  return (0, types_1.asErrorResult)({
43
44
  type: 'validation_error',
@@ -66,6 +66,16 @@ function classifyApiError(error) {
66
66
  details: { errorType: typeof error },
67
67
  };
68
68
  }
69
+ // Fast-fail: no pre-computed cache and API fallback disabled
70
+ if (error.code === 'NO_CACHE') {
71
+ return {
72
+ type: 'cache_error',
73
+ message: error.message || 'No pre-computed graph available for this repository.',
74
+ code: 'NO_CACHE',
75
+ recoverable: false,
76
+ suggestion: 'Use grep, find, and file reading to explore the codebase instead. Or run the precache command and set SUPERMODEL_CACHE_DIR.',
77
+ };
78
+ }
69
79
  if (error.response) {
70
80
  const status = error.response.status;
71
81
  switch (status) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supermodeltools/mcp-server",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "MCP server for Supermodel API - code graph generation for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@modelcontextprotocol/sdk": "^1.0.1",
41
- "@supermodeltools/sdk": "0.9.1",
41
+ "@supermodeltools/sdk": "0.9.2",
42
42
  "archiver": "^7.0.1",
43
43
  "ignore": "^7.0.5",
44
44
  "jq-web": "^0.6.2",