Skip to content

MCP Streamable HTTP client fails against Z.AI web_search_prime gateway: initialize times out (SSE parsing) #586

Description

@qwota

Describe the bug

Connecting to Z.AI's hosted MCP server (https://api.z.ai/api/mcp/web_search_prime/mcp) configured via url + headers always fails: initialize never resolves and the server ends up failed after the 60s timeout. The endpoint itself is fine — the same POST succeeds via curl, and the server connects through the mcp-remote stdio bridge.

The failure comes from the bundled MCP HTTP client (plumcp) rejecting the gateway's SSE encoding. The server sends valid SSE:

id:1
event:message
data:{"jsonrpc":"2.0","id":1,"result":{...}}

but plumcp only accepts chunks whose first line is exactly event: message. The unparseable event then surfaces as a non-JSON-RPC "message" {:mcp-session-id "..."} ((assoc nil :mcp-session-id ...)), the reader thread dies, and the pending initialize future hangs until timeout.

To Reproduce

  1. Add to config:
"mcpServers": {
  "web-search-prime": {
    "url": "https://api.z.ai/api/mcp/web_search_prime/mcp",
    "headers": { "Authorization": "Bearer <REDACTED>" }
  }
}
  1. Start ECA, wait ~60s.
  2. Log shows:
INFO  [MCP] Creating HTTP transport for server 'web-search-prime' at https://api.z.ai/api/mcp/web_search_prime/mcp
Exception in thread "" clojure.lang.ExceptionInfo: Expected JSON-RPC message to be a request, notification or response {:found {:mcp-session-id "..."}}
    at plumcp.core.client.http_client_transport$make_streamable_http_transport$receive_msg.invoke(http_client_transport.cljc:86)
    at plumcp.core.support.http_client_java$make_ring_response$on_sse.invoke(http_client_java.clj:208)
ERROR [MCP] Could not initialize MCP server web-search-prime: MCP initialize returned no result
  1. Sanity checks (both succeed, so the server is healthy):
    • curl -i -X POST <url> -H "Authorization: Bearer <key>" -H "Accept: text/event-stream, application/json" -H "Content-Type: application/json" -d '{...initialize...}' → 200 + valid JSON-RPC result.
    • npx -y mcp-remote <url> --header "Authorization: Bearer <key>" → connects, tools work.

Expected behavior

Server starts and its tools are listed.

Doctor

ECA server: 0.158.1, OS: Windows 11, Java: 24.0.2, client: emacs
MCP: web-search-prime — failed, 0 tools

Additional context

"web-search-prime": {
  "command": "npx.cmd",
  "args": [
    "-y", "mcp-remote",
    "https://api.z.ai/api/mcp/web_search_prime/mcp",
    "--header", "Authorization: Bearer <REDACTED>"
  ]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstream

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions