refactor: add notification handler to stateless servers. (#835)

Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
Co-authored-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
Minsung Son 2026-07-11 00:51:38 +09:00 • committed by GitHub
commit fd004989b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -133,10 +133,26 @@ public class McpStatelessAsyncServer {
this.protocolVersions = new ArrayList<>(mcpTransport.protocolVersions());
McpStatelessServerHandler handler = new DefaultMcpStatelessServerHandler(requestHandlers, Map.of());
Map<String, McpStatelessNotificationHandler> notificationHandlers = prepareNotificationHandlers();
McpStatelessServerHandler handler = new DefaultMcpStatelessServerHandler(requestHandlers, notificationHandlers);
mcpTransport.setMcpHandler(handler);
}
private Map<String, McpStatelessNotificationHandler> prepareNotificationHandlers() {
Map<String, McpStatelessNotificationHandler> notificationHandlers = new HashMap<>();
notificationHandlers.put(McpSchema.METHOD_NOTIFICATION_INITIALIZED, (exchange, params) -> {
logger.debug("Received {}", McpSchema.METHOD_NOTIFICATION_INITIALIZED);
return Mono.empty();
});
notificationHandlers.put(McpSchema.METHOD_NOTIFICATION_ROOTS_LIST_CHANGED, (exchange, params) -> {
logger.debug("Received {}", McpSchema.METHOD_NOTIFICATION_ROOTS_LIST_CHANGED);
return Mono.empty();
});
return notificationHandlers;
}
// ---------------------------------------
// Lifecycle Management
// ---------------------------------------