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
- Add to config:
"mcpServers": {
"web-search-prime": {
"url": "https://api.z.ai/api/mcp/web_search_prime/mcp",
"headers": { "Authorization": "Bearer <REDACTED>" }
}
}
- Start ECA, wait ~60s.
- 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
- 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>"
]
}
Describe the bug
Connecting to Z.AI's hosted MCP server (
https://api.z.ai/api/mcp/web_search_prime/mcp) configured viaurl+headersalways fails:initializenever resolves and the server ends upfailedafter the 60s timeout. The endpoint itself is fine — the same POST succeeds viacurl, and the server connects through themcp-remotestdio bridge.The failure comes from the bundled MCP HTTP client (plumcp) rejecting the gateway's SSE encoding. The server sends valid SSE:
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 pendinginitializefuture hangs until timeout.To Reproduce
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
Additional context
parse-sse-event-linesrequiresevent: messagewith a space as the first chunk line; SSE spec says the space is optional and field order is free). Happy to file details there too.parse-sse-event-linesrejects spec-compliant SSE events (no space afterevent:, arbitrary field order);nilresult then crashes the reader thread plumce/plumcp#12"command": "npx"fails withCreateProcess error=2,npx.cmdis required.