mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-08 07:37:48 +02:00
fix(hooks): treat HTTP 404 MCP probes as reachable
The mcp-health-check preflight probes HTTP MCP servers with a bare GET. Some Streamable HTTP servers route only POST /mcp and answer a bare GET with 404 (Paper Desktop 0.5.3 is one). The probe scored that as down and blocked every tool call for the server indefinitely, since the 30s backoff just re-probes and re-fails. A routed HTTP response of any status proves the endpoint is reachable, which is all this preflight claims to check -- 400/401/403/405/406 are already treated this way for the same reason. Add 404 to the set and let the real MCP client validate the endpoint. Adds a regression test that stands up a POST-only server (404 on GET, 200 on POST /mcp); it fails on the current code and passes with the fix.
This commit is contained in:
@@ -28,8 +28,11 @@ const MAX_BACKOFF_MS = 10 * 60 * 1000;
|
||||
// Claude Code's stored OAuth bearer token. Treat auth-gated responses as
|
||||
// reachable so the real MCP client can attempt the authenticated call. A
|
||||
// Streamable HTTP MCP server can also return 406 to a bare GET that omits
|
||||
// Accept: text/event-stream; that still proves the endpoint is alive.
|
||||
const HEALTHY_HTTP_CODES = new Set([200, 201, 202, 204, 301, 302, 303, 304, 307, 308, 400, 401, 403, 405, 406]);
|
||||
// Accept: text/event-stream; that still proves the endpoint is alive. Some
|
||||
// POST-only Streamable HTTP servers (e.g. Paper Desktop) answer a bare GET
|
||||
// with 404 instead; a routed HTTP response of any kind proves reachability,
|
||||
// so treat 404 as alive and let the real MCP client validate the endpoint.
|
||||
const HEALTHY_HTTP_CODES = new Set([200, 201, 202, 204, 301, 302, 303, 304, 307, 308, 400, 401, 403, 404, 405, 406]);
|
||||
const RECONNECT_STATUS_CODES = new Set([401, 403, 429, 503]);
|
||||
const FAILURE_PATTERNS = [
|
||||
{ code: 401, pattern: /\b401\b|unauthori[sz]ed|auth(?:entication)?\s+(?:failed|expired|invalid)/i },
|
||||
|
||||
Reference in New Issue
Block a user