-
Notifications
You must be signed in to change notification settings - Fork 563
Open
Description
I've noticed that the current InitializeRequestHandler doesn't have any access points, which means it's difficult for the server to perform exclusive initialization operations for different clients. My modification suggestions are as follows:
io.modelcontextprotocol.spec.McpServerSession#handleIncomingNotification
private Mono<Void> handleIncomingNotification(McpSchema.JSONRPCNotification notification) {
return Mono.defer(() -> {
if (McpSchema.METHOD_NOTIFICATION_INITIALIZED.equals(notification.method())) {
this.state.lazySet(STATE_INITIALIZED);
exchangeSink.tryEmitValue(new McpAsyncServerExchange(this, clientCapabilities.get(), clientInfo.get()));
// modify method signature ,and expose the initNotify Handler for user settings
return this.exchangeSink.asMono().flatMap(exchange -> this.initNotificationHandler.handle(exchange, notification.params()));
}
var handler = notificationHandlers.get(notification.method());
if (handler == null) {
logger.error("No handler registered for notification method: {}", notification.method());
return Mono.empty();
}
return this.exchangeSink.asMono().flatMap(exchange -> handler.handle(exchange, notification.params()));
});
}
Metadata
Metadata
Assignees
Labels
No labels