koala73/worldmonitor · error

No result found in SSE response

Error message

No result found in SSE response

What it means

Thrown by parseJsonRpcResponse when the upstream MCP server answered with Content-Type text/event-stream but none of the `data:` lines parsed as JSON containing a top-level `result` or `error` field. The Streamable HTTP transport (MCP 2025-03-26) expects the RPC response — initialize, tools/list, etc. — to be carried in an SSE data frame; if the stream only carries progress/keepalive events or is malformed, this fires.

Source

Thrown at api/mcp-proxy.ts:291

    signal: AbortSignal.timeout(TIMEOUT_MS),
  });
  return resp;
}

async function parseJsonRpcResponse(resp) {
  const ct = resp.headers.get('content-type') || '';
  if (ct.includes('text/event-stream')) {
    const text = await resp.text();
    const lines = text.split('\n');
    for (const line of lines) {
      if (line.startsWith('data: ')) {
        try {
          const parsed = JSON.parse(line.slice(6));
          if (parsed.result !== undefined || parsed.error !== undefined) return parsed;
        } catch { /* skip */ }
      }
    }
    throw new Error('No result found in SSE response');
  }
  return resp.json();
}

async function sendInitialized(serverUrl, headers, sessionId) {
  try {
    await postJson(serverUrl, {
      jsonrpc: '2.0',
      method: 'notifications/initialized',
      params: {},
    }, headers, sessionId);
  } catch (error) {
    if (error instanceof McpProxySsrfError) throw error;
    /* non-fatal */
  }
}

async function mcpListTools(serverUrl, customHeaders) {

View on GitHub (pinned to ffec79ac33)

Solutions

  1. Confirm the upstream MCP server implements the Streamable HTTP transport (MCP 2025-03-26) and emits the JSON-RPC response in a `data:` frame.
  2. Check the upstream server logs for an exception during the RPC that prevented it from writing the result frame.
  3. Verify MCP_PROTOCOL_VERSION matches what the upstream server expects.
  4. If the server only supports the older HTTP POST+JSON transport, point the proxy at the JSON endpoint rather than the SSE one (or upgrade the server).

Example fix

// before — upstream returns SSE with no result/error data line
//   -> parseJsonRpcResponse throws 'No result found in SSE response'
// after — upstream emits a proper JSON-RPC response in a data frame
//   data: {"jsonrpc":"2.0","id":1,"result":{...}}
//
// (server-side fix; no client-side change beyond confirming protocol compliance)
Defensive patterns

Strategy: validation

Validate before calling

function looksLikeSseJsonRpcResponse(text: string): boolean {
  for (const line of text.split('\n')) {
    if (!line.startsWith('data: ')) continue;
    try {
      const p = JSON.parse(line.slice(6));
      if (p && (p.result !== undefined || p.error !== undefined)) return true;
    } catch { /* skip */ }
  }
  return false;
}

Type guard

function isJsonRpcResultOrError(parsed: unknown): boolean {
  return typeof parsed === 'object' && parsed !== null
    && ('result' in parsed || 'error' in parsed);
}

Try / catch

try {
  const rpc = await parseJsonRpcResponse(resp);
  // proceed
} catch (err) {
  if (err.message === 'No result found in SSE response') {
    // Upstream did not emit a JSON-RPC frame; surface as a 502 with the
    // serverUrl so the operator can debug the upstream MCP server.
    return res.status(502).json({ error: 'Upstream MCP server returned no JSON-RPC result.' });
  }
  throw err;
}

Prevention

When it happens

Trigger: POST /api/mcp-proxy completes the initialize handshake, then issues an RPC; the upstream returns text/event-stream whose data lines are either non-JSON (skipped silently), JSON without `result`/`error`, or empty. Common with a misbehaving MCP server that streams comments/heartbeats but never delivers the actual response within the parsed buffer.

Common situations: Upstream MCP server uses a non-standard SSE framing; the response got truncated mid-stream; the server sent only `:keepalive` comments; a protocol-version mismatch (server speaks an older MCP transport); the upstream server errored but wrote the error outside a `data:` line.

Related errors


AI-assisted analysis of koala73/worldmonitor@ffec79ac33 (2026-08-12). Data as JSON: /api/errors/d7dd4c93591beddc. Report an issue: GitHub.