{"record":{"id":"2c43e420979732ce","repo":"koala73/worldmonitor","slug":"initialize-failed-http-initresp-status","errorCode":null,"errorMessage":"Initialize failed: HTTP ${initResp.status}","messagePattern":"Initialize failed: HTTP (.+?)","errorType":"exception","errorClass":null,"httpStatus":422,"severity":"error","filePath":"api/mcp-proxy.ts","lineNumber":315,"sourceCode":"  url.searchParams.set('name', hostname);\n  url.searchParams.set('type', recordType);\n  const dnsTimeout = AbortSignal.timeout(DNS_RESOLUTION_TIMEOUT_MS);\n  const response = await fetch(url.toString(), {\n    headers: {\n      Accept: 'application/dns-json',\n      'User-Agent': 'WorldMonitor-MCP-Proxy/1.0',\n    },\n    signal: signal ? AbortSignal.any([signal, dnsTimeout]) : dnsTimeout,\n  });\n  if (!response.ok) {\n    throw new Error(`DNS ${recordType} lookup failed: HTTP ${response.status}`);\n  }\n  const data = await response.json();\n  if (data?.Status !== 0) {\n    throw new Error(`DNS ${recordType} lookup failed: status ${data?.Status}`);\n  }\n  const expectedType = recordType === 'A' ? 1 : 28;\n  return (Array.isArray(data?.Answer) ? data.Answer : [])\n    .filter(answer => answer?.type === expectedType && typeof answer?.data === 'string')\n    .map(answer => answer.data);\n}\n\nasync function defaultResolveHostname(hostname, signal) {\n  const resolveHostnameForTest = getResolveHostnameForTest();\n  if (resolveHostnameForTest) return resolveHostnameForTest(hostname, signal);\n  const records = await Promise.all([\n    resolveDnsJson(hostname, 'A', signal),\n    resolveDnsJson(hostname, 'AAAA', signal),\n  ]);\n  return records.flat();\n}\n\nasync function assertServerUrlSafe(url, signal) {\n  signal?.throwIfAborted();\n  const hostname = url.hostname.toLowerCase();\n  if (BLOCKED_HOSTNAMES.has(hostname)) {","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/koala73/worldmonitor/blob/e586b8b4b80f595aa7ece295eec10d76f2921240/api/mcp-proxy.ts#L297-L333","documentation":"Thrown by mcpListTools/mcpCallTool when the JSON-RPC initialize request to the MCP server returned a non-2xx HTTP status. The endpoint was reached and answered, but rejected the initialize call (auth failure, wrong URL, gateway error), so no MCP session could be established for the tools/call or tools/list flow.","triggerScenarios":"Thrown at api/mcp-proxy.ts:312 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the HTTP status code in the message: 401/403 means missing or invalid credentials/headers, 404 a wrong endpoint URL","Verify custom headers and the serverUrl configuration for the MCP server","Retry transient 5xx responses once with backoff before reporting failure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e586b8b4b80f595aa7ece295eec10d76f2921240","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}