From 549def3a2125594772e060c35b7f64653020dc1e Mon Sep 17 00:00:00 2001 From: kaishi00 Date: Mon, 29 Jun 2026 17:30:55 -0400 Subject: [PATCH] fix(mcp): add skip_preflight config option for servers serving HTML on GET MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some MCP servers (e.g. Spring Boot apps with a React SPA) serve their frontend on any unmatched GET route. The MCP endpoint works perfectly via POST (JSON-RPC), but a GET to /mcp falls through to the SPA controller and returns text/html. Hermes's preflight content-type probe sees HTML instead of application/json or text/event-stream and refuses to connect. This adds a per-server config option that bypasses the content-type probe, letting the SDK connect directly via POST where it works fine. ```yaml mcp_servers: stirling-pdf: url: http://localhost:8090/mcp headers: X-API-KEY: skip_preflight: true ``` Related: #52460 (OAuth redirect preflight), #51600 (skip probe on mcp add), #40366 (skip probe on reconnect — already merged). --- tools/mcp_tool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mcp_tool.py b/tools/mcp_tool.py index 8d1021ca1cf..b6279f70215 100644 --- a/tools/mcp_tool.py +++ b/tools/mcp_tool.py @@ -2489,7 +2489,7 @@ class MCPServerTask: # re-probing is a redundant round-trip. Also skip for OAuth servers: # without a cached token the endpoint returns HTML or 401, which # would incorrectly block the OAuth flow before it can run. - if config.get("transport") != "sse" and not self._ready.is_set() and self._auth_type != "oauth": + if config.get("transport") != "sse" and not config.get("skip_preflight") and not self._ready.is_set() and self._auth_type != "oauth": try: _probe_headers = dict(config.get("headers") or {}) await self._preflight_content_type(