Skip to content

Commit 5bd950d

Browse files
fengbaicanheNAME
authored andcommitted
Update PING request handler, return empty map instead of empty string
Co-authored-by: NAME <[email protected]> Signed-off-by: Christian Tzolov <[email protected]>
1 parent 64f424d commit 5bd950d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mcp/src/main/java/io/modelcontextprotocol/server/McpAsyncServer.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.time.Duration;
88
import java.util.HashMap;
9+
import java.util.Collections;
910
import java.util.List;
1011
import java.util.Map;
1112
import java.util.Optional;
@@ -403,7 +404,7 @@ private static class AsyncServerImpl extends McpAsyncServer {
403404
// Initialize request handlers for standard MCP methods
404405

405406
// Ping MUST respond with an empty data, but not NULL response.
406-
requestHandlers.put(McpSchema.METHOD_PING, (exchange, params) -> Mono.just(""));
407+
requestHandlers.put(McpSchema.METHOD_PING, (exchange, params) -> Mono.just(Map.of()));
407408

408409
// Add tools API handlers if the tool capability is enabled
409410
if (this.serverCapabilities.tools() != null) {
@@ -926,7 +927,7 @@ private static final class LegacyAsyncServer extends McpAsyncServer {
926927
requestHandlers.put(McpSchema.METHOD_INITIALIZE, asyncInitializeRequestHandler());
927928

928929
// Ping MUST respond with an empty data, but not NULL response.
929-
requestHandlers.put(McpSchema.METHOD_PING, (params) -> Mono.just(""));
930+
requestHandlers.put(McpSchema.METHOD_PING, (params) -> Mono.just(Map.of()));
930931

931932
// Add tools API handlers if the tool capability is enabled
932933
if (this.serverCapabilities.tools() != null) {

0 commit comments

Comments
 (0)