koala73/worldmonitor · error

tools/call failed: HTTP ${callResp.status}

Error message

tools/call failed: HTTP ${callResp.status}

What it means

Thrown by mcpCallTool when any request in the tools/call flow — initialize, the call itself, or session setup — received a non-2xx HTTP status from the MCP server. The remote endpoint answered but refused the request at the HTTP layer, so the tool call could not complete.

Source

Thrown at api/mcp-proxy.ts:340

  if (!listResp.ok) throw new Error(`tools/list failed: HTTP ${listResp.status}`);
  const listData = await parseJsonRpcResponse(listResp);
  if (listData.error) throw new Error(`tools/list error: ${listData.error.message}`);
  return listData.result?.tools || [];
}

async function mcpCallTool(serverUrl, toolName, toolArgs, customHeaders) {
  const headers = buildHeaders(customHeaders);
  const initResp = await postJson(serverUrl, buildInitPayload(), headers, null);
  if (!initResp.ok) throw new Error(`Initialize failed: HTTP ${initResp.status}`);
  const sessionId = initResp.headers.get('Mcp-Session-Id') || initResp.headers.get('mcp-session-id');
  const initData = await parseJsonRpcResponse(initResp);
  if (initData.error) throw new Error(`Initialize error: ${initData.error.message}`);
  await sendInitialized(serverUrl, headers, sessionId);
  const callResp = await postJson(serverUrl, {
    jsonrpc: '2.0', id: 3, method: 'tools/call',
    params: { name: toolName, arguments: toolArgs || {} },
  }, headers, sessionId);
  if (!callResp.ok) throw new Error(`tools/call failed: HTTP ${callResp.status}`);
  const callData = await parseJsonRpcResponse(callResp);
  if (callData.error) throw new Error(`tools/call error: ${callData.error.message}`);
  return callData.result;
}

// --- SSE transport (HTTP+SSE, older MCP spec) ---
// Servers whose URL path ends with /sse use this protocol:
//   1. Client GETs the SSE URL — server opens a stream and emits an `endpoint` event
//      containing the URL where the client should POST JSON-RPC messages.
//   2. Client POSTs JSON-RPC to that endpoint URL.
//   3. Server sends responses on the same SSE stream as `data:` lines.

function isSseTransport(url) {
  const p = url.pathname;
  return p === '/sse' || p.endsWith('/sse');
}

function makeDeferred() {

View on GitHub (pinned to 9361220cc0)

Solutions

  1. Inspect the HTTP status in the message to distinguish auth (401/403), routing (404), and upstream (5xx) causes
  2. Verify serverUrl and any required custom headers for the MCP server
  3. Retry transient 5xx statuses once; restart the session for 404 caused by an expired session id
Defensive patterns

Strategy: retry

When it happens

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

Common situations: See trigger scenarios.


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