Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

HttpServletStreamableServerTransportProvider: GET stream sends no status or headers until the first event

オープン 初心者向け
#1,155 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@karthiksenv がすでに取り組んでいます。

2026年10月3日 から。

  • #1159 @karthiksenv による — オープン
  • #1163 @zh-hanlabs による — オープン

評価

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

調査の方向性

HttpServletStreamableServerTransportProvider#doGet から開始し、提供されている StreamableGetStreamHeadersTest.java の再現テストを servlet transport に対して実行します。イベントまたは keep-alive ping が送信される前に、GET リクエストがステータス 200 と text/event-stream Content-Type で完了すれば完了です。

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

説明

area/server area/transport P3

Bug description
After initialize, a GET to the MCP endpoint with Accept: text/event-stream gets no status line and no headers. doGet sets the SSE headers and starts async but doesn't flush, so nothing is sent until the server writes its first event to the stream. If the server has nothing to send, the client never gets a response.

Clients that wait for headers time out. Node's fetch (undici) gives up after its default headersTimeout of 300 s with UND_ERR_HEADERS_TIMEOUT. mcp-remote then retries twice and stops ("Maximum reconnection attempts (2) exceeded"). After that the server has no stream to the client, and server-initiated requests fail with Stream unavailable for session ... (see also #1061).

With keepAliveInterval set, the first ping sends the headers, but only after one interval.

The spec says the server must either return Content-Type: text/event-stream for this GET or return 405 (Streamable HTTP, 2025-11-25).

Environment

  • Where it was seen: mcp-core 1.1.1, Spring Boot 4.0.5 (embedded Tomcat), Java 25.0.3, macOS 27.0.1. Client: Claude Desktop through mcp-remote 0.14.3, protocol 2025-11-25.
  • Reproduced with the test below: mcp-core 1.1.1 and 2.0.1, tomcat-embed-core 11.0.22, JDK 26.0.1, macOS 14.7.4. The doGet code is the same on main (1cf7903).
  • No keep-alive configured.

Steps to reproduce

  1. POST initialize and note the Mcp-Session-Id.
  2. POST notifications/initialized. You get 202.
  3. GET the endpoint with Accept: text/event-stream and the session ID.
curl -sN --max-time 20 -D - http://127.0.0.1:8080/mcp -H 'Accept: text/event-stream' -H "Mcp-Session-Id: $SID"

Actual: 0 bytes received in 20 s.

Expected behavior
200 with Content-Type: text/event-stream sent as soon as the GET stream opens, before any event is ready.

Minimal Complete Reproducible example
Dependencies: io.modelcontextprotocol.sdk:mcp, org.apache.tomcat.embed:tomcat-embed-core:11.0.22, org.junit.jupiter:junit-jupiter. The test fails with java.util.concurrent.TimeoutException on 1.1.1 and 2.0.1. If .keepAliveInterval(Duration.ofSeconds(1)) is added to the builder, it passes: the headers arrive with the first ping.

StreamableGetStreamHeadersTest.java
package repro;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.InputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.util.concurrent.TimeUnit;

import org.apache.catalina.Context;
import org.apache.catalina.startup.Tomcat;
import org.junit.jupiter.api.Test;

import io.modelcontextprotocol.server.McpAsyncServer;
import io.modelcontextprotocol.server.McpServer;
import io.modelcontextprotocol.server.transport.HttpServletStreamableServerTransportProvider;

class StreamableGetStreamHeadersTest {

	@Test
	void getStreamSendsHeadersBeforeFirstEvent() throws Exception {
		HttpServletStreamableServerTransportProvider transport = HttpServletStreamableServerTransportProvider.builder()
			.build();
		McpAsyncServer server = McpServer.async(transport).serverInfo("repro", "1").build();

		Tomcat tomcat = new Tomcat();
		tomcat.setBaseDir(Files.createTempDirectory("tomcat").toString());
		tomcat.setPort(0);
		Context context = tomcat.addContext("", null);
		Tomcat.addServlet(context, "mcp", transport).setAsyncSupported(true);
		context.addServletMappingDecoded("/*", "mcp");
		tomcat.start();

		try {
			URI endpoint = URI.create("http://127.0.0.1:" + tomcat.getConnector().getLocalPort() + "/mcp");
			HttpClient client = HttpClient.newHttpClient();

			String sessionId = client.send(post(endpoint, null, """
					{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25",\
					"capabilities":{},"clientInfo":{"name":"repro","version":"1"}}}"""),
					HttpResponse.BodyHandlers.discarding())
				.headers()
				.firstValue("Mcp-Session-Id")
				.orElseThrow();
			assertEquals(202, client.send(post(endpoint, sessionId, """
					{"jsonrpc":"2.0","method":"notifications/initialized"}"""),
					HttpResponse.BodyHandlers.discarding())
				.statusCode());

			HttpRequest get = HttpRequest.newBuilder(endpoint)
				.header("Accept", "text/event-stream")
				.header("Mcp-Session-Id", sessionId)
				.GET()
				.build();

			// Completes once the status line and headers arrive. Fails with TimeoutException.
			HttpResponse<InputStream> response = client.sendAsync(get, HttpResponse.BodyHandlers.ofInputStream())
				.get(5, TimeUnit.SECONDS);

			assertEquals(200, response.statusCode());
			assertTrue(response.headers().firstValue("Content-Type").orElse("").startsWith("text/event-stream"));
			response.body().close();
		}
		finally {
			server.closeGracefully().block();
			tomcat.stop();
			tomcat.destroy();
		}
	}

	private static HttpRequest post(URI endpoint, String sessionId, String body) {
		HttpRequest.Builder builder = HttpRequest.newBuilder(endpoint)
			.header("Accept", "application/json, text/event-stream")
			.header("Content-Type", "application/json")
			.POST(HttpRequest.BodyPublishers.ofString(body));
		if (sessionId != null) {
			builder.header("Mcp-Session-Id", sessionId);
		}
		return builder.build();
	}

}
主要言語
Java
スター
3.7k
フォーク
1.2k
平均マージ
2日 22時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

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

modelcontextprotocol/java-sdk のほかの issue

modelcontextprotocol/java-sdk の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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