Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,12 @@ private Mono<McpSchema.JSONRPCResponse> handleIncomingRequest(McpSchema.JSONRPCR
resultMono = this.initRequestHandler.handle(initializeRequest);
}
else {
// TODO handle errors for communication to this session without
// initialization happening first
if (this.state.get() != STATE_INITIALIZED) {
logger.warn("Rejecting uninitialized request method: {}", request.method());
return Mono.just(McpSchema.JSONRPCResponse.error(request.id(),
new McpSchema.JSONRPCResponse.JSONRPCError(McpSchema.ErrorCodes.INVALID_REQUEST,
"Session is not initialized. Cannot process method: " + request.method(), null)));
}
var handler = this.requestHandlers.get(request.method());
if (handler == null) {
MethodNotFoundError error = getMethodNotFoundError(request.method());
Expand Down Expand Up @@ -327,6 +331,12 @@ private Mono<Void> handleIncomingNotification(McpSchema.JSONRPCNotification noti
exchangeSink.tryEmitValue(new McpAsyncServerExchange(this.id, this, clientCapabilities.get(),
clientInfo.get(), transportContext, this.jsonSchemaValidator));
}
else if (this.state.get() != STATE_INITIALIZED) {
logger.warn("Rejecting uninitialized notification method: {}", notification.method());
return Mono
.error(new McpError(new McpSchema.JSONRPCResponse.JSONRPCError(McpSchema.ErrorCodes.INVALID_REQUEST,
"Session is not initialized. Cannot process method: " + notification.method(), null)));
}

var handler = notificationHandlers.get(notification.method());
if (handler == null) {
Expand Down