koala73/worldmonitor · error

Initialize failed: HTTP

Error message

Initialize failed: HTTP ${initResp.status}

What it means

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.

Solutions

  1. Check the HTTP status code in the message: 401/403 means missing or invalid credentials/headers, 404 a wrong endpoint URL
  2. Verify custom headers and the serverUrl configuration for the MCP server
  3. Retry transient 5xx responses once with backoff before reporting failure
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at api/mcp-proxy.ts:312 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@e586b8b4b8 (2026-08-21). Data as JSON: /api/errors/2c43e420979732ce. Report an issue: GitHub.

Appendix: source

Thrown at api/mcp-proxy.ts:315

  url.searchParams.set('name', hostname);
  url.searchParams.set('type', recordType);
  const dnsTimeout = AbortSignal.timeout(DNS_RESOLUTION_TIMEOUT_MS);
  const response = await fetch(url.toString(), {
    headers: {
      Accept: 'application/dns-json',
      'User-Agent': 'WorldMonitor-MCP-Proxy/1.0',
    },
    signal: signal ? AbortSignal.any([signal, dnsTimeout]) : dnsTimeout,
  });
  if (!response.ok) {
    throw new Error(`DNS ${recordType} lookup failed: HTTP ${response.status}`);
  }
  const data = await response.json();
  if (data?.Status !== 0) {
    throw new Error(`DNS ${recordType} lookup failed: status ${data?.Status}`);
  }
  const expectedType = recordType === 'A' ? 1 : 28;
  return (Array.isArray(data?.Answer) ? data.Answer : [])
    .filter(answer => answer?.type === expectedType && typeof answer?.data === 'string')
    .map(answer => answer.data);
}

async function defaultResolveHostname(hostname, signal) {
  const resolveHostnameForTest = getResolveHostnameForTest();
  if (resolveHostnameForTest) return resolveHostnameForTest(hostname, signal);
  const records = await Promise.all([
    resolveDnsJson(hostname, 'A', signal),
    resolveDnsJson(hostname, 'AAAA', signal),
  ]);
  return records.flat();
}

async function assertServerUrlSafe(url, signal) {
  signal?.throwIfAborted();
  const hostname = url.hostname.toLowerCase();
  if (BLOCKED_HOSTNAMES.has(hostname)) {

View on GitHub (pinned to e586b8b4b8)