From 10753f48cd820e700130b7187a43964e333b265a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B5=E5=B9=BF=E8=B6=85?= <8617564+shao-guangchao@user.noreply.gitee.com> Date: Sun, 9 Aug 2026 09:18:50 +0800 Subject: [PATCH] fix: ignore SSE retry: field to prevent McpTransportException The SSE specification includes 'retry:' as a valid field for setting the reconnection interval. However, the SseLineSubscriber treats any unrecognized line as an error, causing McpTransportException when MCP servers (e.g., rmcp-based servers like SurrealDB) emit retry directives in SSE responses. This fix adds a handler that silently ignores 'retry:' lines, matching the existing behaviour for ':' comment lines. Related: servers using rmcp (Rust MCP SDK) send 'retry: 3000' by default, which triggers this error and breaks Streamable HTTP connections to SurrealDB and other rmcp-based MCP servers. --- .../client/transport/ResponseSubscribers.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/client/transport/ResponseSubscribers.java b/mcp-core/src/main/java/io/modelcontextprotocol/client/transport/ResponseSubscribers.java index 29dc23c35..234b8477a 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/client/transport/ResponseSubscribers.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/client/transport/ResponseSubscribers.java @@ -179,6 +179,11 @@ else if (line.startsWith(":")) { logger.debug("Ignoring comment line: {}", line); upstream().request(1); } + else if (line.startsWith("retry:")) { + // Ignore SSE retry directive — only the server controls reconnection + logger.debug("Ignoring retry directive: {}", line); + upstream().request(1); + } else { // If the response is not successful, emit an error this.sink.error(new McpTransportException(