{"record":{"id":"6ff4cdd5d688713b","repo":"koala73/worldmonitor","slug":"tools-list-error-listdata-error-message","errorCode":null,"errorMessage":"tools/list error: ${listData.error.message}","messagePattern":"tools/list error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":422,"severity":"error","filePath":"api/mcp-proxy.ts","lineNumber":324,"sourceCode":"    if (error instanceof McpProxySsrfError) throw error;\n    /* non-fatal */\n  }\n}\n\nasync function mcpListTools(serverUrl, customHeaders) {\n  const headers = buildHeaders(customHeaders);\n  const initResp = await postJson(serverUrl, buildInitPayload(), headers, null);\n  if (!initResp.ok) throw new Error(`Initialize failed: HTTP ${initResp.status}`);\n  const sessionId = initResp.headers.get('Mcp-Session-Id') || initResp.headers.get('mcp-session-id');\n  const initData = await parseJsonRpcResponse(initResp);\n  if (initData.error) throw new Error(`Initialize error: ${initData.error.message}`);\n  await sendInitialized(serverUrl, headers, sessionId);\n  const listResp = await postJson(serverUrl, {\n    jsonrpc: '2.0', id: 2, method: 'tools/list', params: {},\n  }, headers, sessionId);\n  if (!listResp.ok) throw new Error(`tools/list failed: HTTP ${listResp.status}`);\n  const listData = await parseJsonRpcResponse(listResp);\n  if (listData.error) throw new Error(`tools/list error: ${listData.error.message}`);\n  return listData.result?.tools || [];\n}\n\nasync function mcpCallTool(serverUrl, toolName, toolArgs, customHeaders) {\n  const headers = buildHeaders(customHeaders);\n  const initResp = await postJson(serverUrl, buildInitPayload(), headers, null);\n  if (!initResp.ok) throw new Error(`Initialize failed: HTTP ${initResp.status}`);\n  const sessionId = initResp.headers.get('Mcp-Session-Id') || initResp.headers.get('mcp-session-id');\n  const initData = await parseJsonRpcResponse(initResp);\n  if (initData.error) throw new Error(`Initialize error: ${initData.error.message}`);\n  await sendInitialized(serverUrl, headers, sessionId);\n  const callResp = await postJson(serverUrl, {\n    jsonrpc: '2.0', id: 3, method: 'tools/call',\n    params: { name: toolName, arguments: toolArgs || {} },\n  }, headers, sessionId);\n  if (!callResp.ok) throw new Error(`tools/call failed: HTTP ${callResp.status}`);\n  const callData = await parseJsonRpcResponse(callResp);\n  if (callData.error) throw new Error(`tools/call error: ${callData.error.message}`);","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/koala73/worldmonitor/blob/9361220cc013571781071f0206e4d80fd14b2f7f/api/mcp-proxy.ts#L306-L342","documentation":"Thrown by mcpListTools when the tools/list JSON-RPC call returned HTTP 2xx but the response payload contained a JSON-RPC error object. The MCP server explicitly reported a protocol-level error while enumerating tools (e.g. unknown method, internal server error in the handler).","triggerScenarios":"Thrown at api/mcp-proxy.ts:322 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the embedded error.message — it is the upstream server's JSON-RPC error text","Verify the server supports the tools/list method in its advertised capabilities","Restart or reconfigure the MCP server if it reports an internal tool listing failure"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9361220cc013571781071f0206e4d80fd14b2f7f","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}