Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions MIGRATION-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The changes fall into these areas:
- [JSON serialization behaviour](#json-serialization-behaviour) — wire-format changes.
- [Server-side validation](#server-side-validation) — runtime validation of tool arguments and embedded schemas.
- [Transport changes](#transport-changes) — removed methods and the SSE deprecation.
- [Server API changes](#server-api-changes) — sync server method signature corrections.
- [New features](#new-features) — additive, backward-compatible capabilities.

---
Expand Down Expand Up @@ -220,6 +221,18 @@ The HTTP+SSE client and server transports (and their supporting validator/except

---

## Server API changes

### `McpStatelessSyncServer#closeGracefully` returns `void`

In 1.x, `McpStatelessSyncServer.closeGracefully()` accidentally leaked the reactive signature from the underlying async server and returned `Mono<Void>`. 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.

---

## New features

These are additive and backward-compatible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Void> closeGracefully() {
return this.asyncServer.closeGracefully();
public void closeGracefully() {
this.asyncServer.closeGracefully().block();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -128,7 +126,7 @@ void testToolCallSuccess(String clientType) {
assertThat(response).isNotNull().isEqualTo(callResponse);
}
finally {
mcpServer.closeGracefully().block();
mcpServer.closeGracefully();
}
}

Expand Down
Loading