modelcontextprotocol / modelcontextprotocol/java-sdk

SDK rejects valid SSE comments, causing initialization timeout with Tavily MCP remote server

オープン
#685 コメント 1 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P2
主要言語
Java
スター
3.7k
フォーク
1.1k
平均マージ
1日 15時間
マージ済み PR(30日)
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)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ResponseSubscribers.java の SseLineSubscriber.hookOnNext から始め、次に、Tavily MCP server と示されているトランスポート設定を使って初期化を再現します。':' で始まる有効な SSE コメント行によって invalid-response エラーが発生しなくなり、client.initialize() が正常に完了すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。