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:
parent
0557b87603
commit
fd004989b9
1 changed files with 81 additions and 4 deletions
|
|
@ -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
|
||||
// ---------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue