modelcontextprotocol / modelcontextprotocol/java-sdk
SDK rejects valid SSE comments, causing initialization timeout with Tavily MCP remote server
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 3.7k
- 派生
- 1.1k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 9
描述
The Java MCP SDK throws an McpError: Invalid SSE response when receiving SSE comment lines (lines starting with :), which are valid per the SSE specification. This causes initialization failures with MCP servers that send keep-alive or ping comments.
Environment
SDK Version: Java SDK (latest)
Protocol Version: 2025-03-26
Java Version: 17+
Affected Server: Tavily MCP Server (https://mcp.tavily.com/mcp/)
Steps to Reproduce:
String url = "https://mcp.tavily.com/mcp/";
McpClientTransport transport = HttpClientStreamableHttpTransport.builder(url).build();
SyncSpec clientBuilder = McpClient.sync(transport);
McpSyncClient client = clientBuilder.build();
// This will fail during initialization
client.initialize();
Symptoms
Initial Symptom (with default/short timeout)
The initialization hangs and eventually times out:
_INFO io.modelcontextprotocol.client.LifecycleInitializer -- Server response with Protocol: 2025-03-26, Capabilities: ServerCapabilities[...], Info: Implementation[name=tavily-mcp, title=null, version=1.17.0] and Instructions null
WARN io.modelcontextprotocol.client.LifecycleInitializer -- Failed to initialize
java.util.concurrent.TimeoutException: Did not observe any item or terminal signal within 3000ms in 'map' (and no fallback has been configured)_
This timeout occurs because the SSE parsing is failing silently in the background, preventing the initialization from completing.
Root Cause Revealed (with increased timeout ~300 seconds)
When the timeout is increased significantly, the actual error becomes visible:
WARN io.modelcontextprotocol.client.LifecycleInitializer -- Handling exception
io.modelcontextprotocol.spec.McpError: Invalid SSE response. Status code: 200 Line: : ping - 2025-11-20 17:27:30.586492+00:00
at io.modelcontextprotocol.client.transport.ResponseSubscribers$SseLineSubscriber.hookOnNext(ResponseSubscribers.java:173)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 ResponseSubscribers.java 中的 SseLineSubscriber.hookOnNext 开始,然后使用 Tavily MCP server 和所示的传输设置复现初始化过程。当以 ':' 开头的有效 SSE 注释行不再导致无效响应失败,并且 client.initialize() 正常完成时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100