{"record":{"id":"3a3f8f56745e9a5b","repo":"abhigyanpatwari/GitNexus","slug":"32000-3a3f8f","errorCode":"-32000","errorMessage":"Internal MCP server error","messagePattern":"Internal MCP server error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"critical","filePath":"gitnexus/src/server/mcp-http.ts","lineNumber":28,"sourceCode":"\nimport type { Express, Request, Response } from 'express';\nimport { createStreamableHttpHandler } from '../mcp/http-transport.js';\nimport type { LocalBackend } from '../mcp/local/local-backend.js';\nimport { createMcpRepositoryPolicy } from '../mcp/repository-policy.js';\nimport { logger } from '../core/logger.js';\n\nexport async function mountMCPEndpoints(\n  app: Express,\n  backend: LocalBackend,\n): Promise<() => Promise<void>> {\n  const repositoryPolicy = await createMcpRepositoryPolicy(backend);\n  const { handler, cleanup } = createStreamableHttpHandler(backend, { repositoryPolicy });\n\n  app.all('/api/mcp', (req: Request, res: Response) => {\n    void handler(req, res).catch((err: unknown) => {\n      logger.error({ err }, 'MCP HTTP request failed:');\n      if (res.headersSent) return;\n      res.status(500).json({\n        jsonrpc: '2.0',\n        error: { code: -32000, message: 'Internal MCP server error' },\n        id: null,\n      });\n    });\n  });\n\n  logger.info('MCP HTTP endpoints mounted at /api/mcp');\n  return cleanup;\n}\n","sourceCodeStart":10,"sourceCodeEnd":39,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/server/mcp-http.ts#L10-L39","documentation":"JSON-RPC error response (code -32000, message 'Internal MCP server error', id null) returned by the /api/mcp streamable-HTTP endpoint when the MCP handler itself throws or rejects. It is the MCP surface's equivalent of an unhandled exception: the real failure is logged as 'MCP HTTP request failed:'; if headers were already sent (failure mid-stream) no error body can be written and the HTTP stream simply terminates.","triggerScenarios":"A backend crash while servicing tools/list or tools/call; corrupted or version-skewed index/storage touched during a tool call; a GitNexus bug in the streamable-HTTP handler; the server dying mid-request and leaving a half-written response.","commonSituations":"Editor/MCP clients attached to a serve instance with corrupted storage; concurrent MCP sessions racing index re-initialization; upgrades leaving the index in an incompatible state.","solutions":["Check the serve logs for 'MCP HTTP request failed:' — the -32000 body carries no detail by design","Let the client re-initialize the MCP session (most do automatically) and retry the tool call once","Re-run analyze to rebuild the index if storage corruption is suspected","Persistent -32000 with a reproducible request is a bug — update GitNexus and report with the stack"],"exampleFix":"// before\nconst result = await client.callTool({ name: 'impact', arguments: args }); // throws on -32000\n\n// after\nasync function callMcpSafe(client: any, name: string, args: object) {\n  try {\n    return await client.callTool({ name, arguments: args });\n  } catch (e: any) {\n    if (e?.code === -32000) {\n      await client.connect(); // re-initialize the session\n      return client.callTool({ name, arguments: args });\n    }\n    throw e;\n  }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"Catch JSON-RPC errors with code -32000, log context client-side, re-initialize the MCP session, and retry the call exactly once; escalate to the serve log if it persists.","preventionTips":["Keep serve logs visible when integrating MCP clients","Rebuild the index (analyze) after version upgrades","Treat -32000 as transient-first, bug-second"],"tags":["mcp","jsonrpc","streamable-http","internal-error","http-500"],"backgroundTag":"jsonrpc-internal-error","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}