modelcontextprotocol / modelcontextprotocol/java-sdk

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

Đang mở
#685 1 bình luận 3 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug P2
Ngôn ngữ chính
Java
Star
3.7k
Fork
1.1k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
9

Mô tả

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)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong ResponseSubscribers.java tại SseLineSubscriber.hookOnNext, sau đó tái hiện quá trình khởi tạo với Tavily MCP server và thiết lập transport được示示. Hoàn tất khi các dòng chú thích SSE hợp lệ bắt đầu bằng ':' không còn gây ra lỗi phản hồi không hợp lệ và client.initialize() hoàn tất bình thường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.