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