modelcontextprotocol / modelcontextprotocol/java-sdk

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

Ouverte
#685 1 commentaire 3 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug P2
Langage dominant
Java
Étoiles
3.7k
Forks
1.1k
Merge moyen
1 j 15 h
PR mergées (30 j)
9

Description

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)

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez dans ResponseSubscribers.java, au niveau de SseLineSubscriber.hookOnNext, puis reproduisez l’initialisation avec le Tavily MCP server et la configuration de transport présentée. C’est terminé lorsque des lignes de commentaire SSE valides commençant par ':' ne provoquent plus d’échec dû à une réponse invalide et que client.initialize() s’achève normalement.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
api
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.