From 656b6e321fbaf7b9a3fd75c56f78ef6cc18a27e9 Mon Sep 17 00:00:00 2001 From: Christian Tzolov Date: Wed, 10 Jun 2026 22:26:12 +0200 Subject: [PATCH 1/2] Return void from McpStatelessSyncServer#closeGracefully instead of Mono Signed-off-by: Christian Tzolov --- .../modelcontextprotocol/server/McpStatelessSyncServer.java | 6 +++--- .../AbstractStatelessIntegrationTests.java | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpStatelessSyncServer.java b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpStatelessSyncServer.java index 6849eb8ed..475f88df8 100644 --- a/mcp-core/src/main/java/io/modelcontextprotocol/server/McpStatelessSyncServer.java +++ b/mcp-core/src/main/java/io/modelcontextprotocol/server/McpStatelessSyncServer.java @@ -50,10 +50,10 @@ public McpSchema.Implementation getServerInfo() { /** * Gracefully closes the server, allowing any in-progress operations to complete. - * @return A Mono that completes when the server has been closed + * */ - public Mono closeGracefully() { - return this.asyncServer.closeGracefully(); + public void closeGracefully() { + this.asyncServer.closeGracefully().block(); } /** diff --git a/mcp-test/src/main/java/io/modelcontextprotocol/AbstractStatelessIntegrationTests.java b/mcp-test/src/main/java/io/modelcontextprotocol/AbstractStatelessIntegrationTests.java index 16e3e916b..04387bd12 100644 --- a/mcp-test/src/main/java/io/modelcontextprotocol/AbstractStatelessIntegrationTests.java +++ b/mcp-test/src/main/java/io/modelcontextprotocol/AbstractStatelessIntegrationTests.java @@ -4,8 +4,6 @@ package io.modelcontextprotocol; -import static io.modelcontextprotocol.util.ToolsUtils.EMPTY_JSON_SCHEMA; - import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; @@ -31,9 +29,9 @@ import net.javacrumbs.jsonunit.core.Option; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.junit.jupiter.params.provider.ValueSource; import reactor.core.publisher.Mono; +import static io.modelcontextprotocol.util.ToolsUtils.EMPTY_JSON_SCHEMA; import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; import static net.javacrumbs.jsonunit.assertj.JsonAssertions.json; import static org.assertj.core.api.Assertions.assertThat; @@ -128,7 +126,7 @@ void testToolCallSuccess(String clientType) { assertThat(response).isNotNull().isEqualTo(callResponse); } finally { - mcpServer.closeGracefully().block(); + mcpServer.closeGracefully(); } } From e8d9c7bf9f973dd2accc681de515005619909d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20J=C4=99drzejczyk?= <2554306+chemicL@users.noreply.github.com> Date: Thu, 11 Jun 2026 11:49:27 +0200 Subject: [PATCH 2/2] Include change in the migration doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dariusz Jędrzejczyk <2554306+chemicL@users.noreply.github.com> --- MIGRATION-2.0.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MIGRATION-2.0.md b/MIGRATION-2.0.md index 2119f71f5..bc700f14e 100644 --- a/MIGRATION-2.0.md +++ b/MIGRATION-2.0.md @@ -168,6 +168,16 @@ JSONRPCResponse.error(id, new JSONRPCError(code, message)); // 2-arg error The 1.x canonical 4-arg constructors continue to compile. +### `McpStatelessSyncServer#closeGracefully` returns `void` + +In 1.x, `McpStatelessSyncServer.closeGracefully()` accidentally leaked the reactive signature from the underlying async server and returned `Mono`. The sync API is intentionally blocking, so returning a `Mono` was an oversight — callers had to call `.block()` themselves to get any actual shutdown behaviour. + +In 2.0 the return type is corrected to `void`; the blocking call is performed internally. + +**Action:** Remove any `.block()` (or `.subscribe()`) call you had appended to `closeGracefully()`. The method now blocks until the server has shut down and returns normally. + +--- + ### Optional JSON Schema validation on `tools/call` (server) When a `JsonSchemaValidator` is available (including the default from `McpJsonDefaults.getSchemaValidator()` when you do not configure one explicitly) and `validateToolInputs` is left at its default of `true`, the server validates incoming tool arguments against `tool.inputSchema()` before invoking the tool. Failed validation produces a `CallToolResult` with `isError` set and a textual error in the content.