Update PING request handler, return empty map instead of empty string

Co-authored-by: NAME <NAME@EXAMPLE.COM>
Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
ryan xu 2025-03-15 23:27:00 +08:00 • committed by Christian Tzolov
commit 5bd950d668

View file

@ -6,6 +6,7 @@ package io.modelcontextprotocol.server;
import java.time.Duration;
import java.util.HashMap;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@ -403,7 +404,7 @@ public class McpAsyncServer {
// Initialize request handlers for standard MCP methods
// Ping MUST respond with an empty data, but not NULL response.
requestHandlers.put(McpSchema.METHOD_PING, (exchange, params) -> Mono.just(""));
requestHandlers.put(McpSchema.METHOD_PING, (exchange, params) -> Mono.just(Map.of()));
// Add tools API handlers if the tool capability is enabled
if (this.serverCapabilities.tools() != null) {
@ -926,7 +927,7 @@ public class McpAsyncServer {
requestHandlers.put(McpSchema.METHOD_INITIALIZE, asyncInitializeRequestHandler());
// Ping MUST respond with an empty data, but not NULL response.
requestHandlers.put(McpSchema.METHOD_PING, (params) -> Mono.just(""));
requestHandlers.put(McpSchema.METHOD_PING, (params) -> Mono.just(Map.of()));
// Add tools API handlers if the tool capability is enabled
if (this.serverCapabilities.tools() != null) {