Skip to content

MCP HTTP wrapper: arrayBuffer() hangs on GET SSE ReadableStream #437

@jknair

Description

@jknair

Bug

The MCP-over-HTTP wrapper hangs indefinitely when a client connects to the GET /sse endpoint.

Location

mcp.js:625 in the built bundle (the HTTP proxy/wrapper that fronts the MCP stdio server).

What happens

The handler does:

const response = await fetch(url);
const buf = await response.arrayBuffer();   // <-- hangs here

The GET /sse endpoint returns a Server-Sent Events ReadableStream — it never closes, so arrayBuffer() never resolves. The request hangs forever and the client never receives any data.

Expected behavior

The SSE stream should be piped through to the client response instead of being buffered. Something like:

if (response.headers.get('content-type')?.includes('text/event-stream')) {
  // Pipe the ReadableStream directly to the Node response
  Readable.fromWeb(response.body).pipe(nodeRes);
  return;
}

Workaround

Use the REST POST /query endpoint instead of connecting via MCP-over-HTTP SSE transport. This avoids the hanging arrayBuffer() call entirely.

Environment

  • QMD installed via npm install -g @tobilu/qmd
  • Running as a daemon on localhost:8181/mcp
  • Client: Node.js fetch / MCP SDK SSE transport

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions