You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5c03112
Browse filesBrowse the repository at this point in the historyBrowse files
Stop a non-MCP response from looking like a silent server
The report was that connecting GitHub's MCP server timed out after 60s with "it accepted the connection and then went quiet", while the gateway log showed the POST completing normally. Both were true: the POST completed because it returned the timeout, and the timeout was wrong about what had happened.
Two things were missing, and the first one hid the second.
Every MCP test ran over stdio. The HTTP branch of _open_transport — the one GitHub, DeepWiki, Context7, Sentry and Stripe all use — had never been executed by any test, so "does the platform connect to an HTTP MCP server" had no answer in the suite, and for some servers the answer was no. tests/test_mcp_http.py now runs against two real servers: FastMCP over streamable HTTP, and a hand-written one shaped like GitHub's, which refuses the optional server-to-client GET stream with 405. FastMCP always offers that stream, so it could never have caught this alone.
A response that is not MCP hung forever. Against a server answering 200 OK with text/html, the old code gave the same message and the same 15s as a genuinely silent server — and it was wrong, because that server replied instantly. The mechanism is in the client library: an unusable content type is reported by sending a ValueError into the read stream, and ClientSession's default message handler is a no-op checkpoint that drops it. The pending initialize() is never answered and never fails; it waits. A proxy's login page was therefore indistinguishable from silence. A message_handler that fails the connection turns it into an immediate, accurate error naming the content type.
Also split the handshake from the tool listing, each with its own share of one budget, because a stall in the second is a known upstream defect (modelcontextprotocol/python-sdk#1941: servers that decline the GET stream can stall the client on the next request) and a stall in the first is not. Those deserve opposite advice — "your URL is wrong" versus "your setup is fine, raise CWAP_MCP_TIMEOUT". We are on the latest SDK, 1.28.1, so there is no fixed release to take.
A phase error is raised inside anyio's task group and comes back boxed, so the old wrapper re-explained it and named the URL twice. _failure now unwraps what we already said rather than saying something vaguer on top of it.
Not run: the PostgreSQL parity suite — Postgres is not up in this container and process control is unavailable. This diff touches mcp_connect, tests and docs, and no SQL.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014wARiGvLpL9UaHJADdbAjF
Copy file name to clipboardExpand all lines: README.md
+22-6Lines changed: 22 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -347,12 +347,28 @@ node does and passes the same two-phase gate, so a redelivered step cannot open
347
347
two pull requests. Tools a server marks read-only are exempt — reading a
348
348
repository is not a side effect.
349
349
350
-
**When a connection fails, the error says which kind of failure it was.**
351
-
Reaching the host is bounded separately (`CWAP_MCP_CONNECT_TIMEOUT`, 10s) from
352
-
waiting for it to answer (`CWAP_MCP_TIMEOUT`, 60s), because those have different
353
-
remedies: an unreachable host means the URL is wrong or the deployment has no
354
-
egress, and waiting longer will never help; a server that accepted the
355
-
connection and went quiet is the one worth waiting for.
350
+
**When a connection fails, the error says which kind of failure it was.** One
351
+
timeout covering everything reported four different problems with one sentence,
352
+
and none of the four remedies is the same:
353
+
354
+
| What happened | What it says | What to do |
355
+
| --- | --- | --- |
356
+
| The host never answers a SYN |*could not reach the host* (10s) | Fix the URL, or the deployment's egress |
357
+
| It answers with a page, not MCP |*that URL answered, but not with MCP*| It is a login page, a proxy, or the wrong URL |
358
+
| The handshake stalls |*stopped responding while completing the MCP handshake*| Probably not an MCP endpoint; or raise `CWAP_MCP_TIMEOUT`|
359
+
| The handshake works, listing stalls |*stopped responding while listing its tools*| Your setup is fine — see below |
360
+
361
+
That last row is a known defect in the MCP client library rather than anything
362
+
about your server ([python-sdk#1941](https://github.com/modelcontextprotocol/python-sdk/issues/1941)):
363
+
a server that declines the *optional* server-to-client stream — GitHub's does,
364
+
with a `405` — can stall the client on the request after the handshake. Raising
365
+
`CWAP_MCP_TIMEOUT` is the workaround, and the error says so rather than leaving
366
+
someone re-checking a URL that was never wrong.
367
+
368
+
An endpoint that replies `200 OK` with an HTML page is worth calling out
369
+
separately: the client library reports that by posting an error into a stream
370
+
nobody reads, so the request waits forever without ever failing. That is why a
371
+
proxy's login page used to look exactly like a server that had gone silent.
0 commit comments