feat: implement ping request handler in MCP async client (#203)

- Add ping request handler that responds with empty Map instead of null
- Ensure compliance with MCP protocol requirement for ping responses
- Add test for ping message request handling

Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
or-givati 2025-03-24 14:41:07 +02:00 • committed by Christian Tzolov
commit ebb9764c1b

View file

@ -187,6 +187,9 @@ public class McpAsyncClient {
// Request Handlers
Map<String, RequestHandler<?>> requestHandlers = new HashMap<>();
// Ping MUST respond with an empty data, but not NULL response.
requestHandlers.put(McpSchema.METHOD_PING, params -> Mono.just(Map.of()));
// Roots List Request Handler
if (this.clientCapabilities.roots() != null) {
requestHandlers.put(McpSchema.METHOD_ROOTS_LIST, rootsListRequestHandler());