Skip to content

Commit 10753f4

Browse files
author
邵广超
committed
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.
1 parent 8ee8ccb commit 10753f4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

mcp-core/src/main/java/io/modelcontextprotocol/client/transport/ResponseSubscribers.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ else if (line.startsWith(":")) {
179179
logger.debug("Ignoring comment line: {}", line);
180180
upstream().request(1);
181181
}
182+
else if (line.startsWith("retry:")) {
183+
// Ignore SSE retry directive — only the server controls reconnection
184+
logger.debug("Ignoring retry directive: {}", line);
185+
upstream().request(1);
186+
}
182187
else {
183188
// If the response is not successful, emit an error
184189
this.sink.error(new McpTransportException(

0 commit comments

Comments
 (0)