Fix error behavior on unregistered handlers in stateless server handler (#800)
Instead of throwing an McpError, it now returns with a JSON-RPC method not found error (-32601), aligned with the stateful implementation. Closes #784
This commit is contained in:
parent
dea53fd14c
commit
5d3decebd6
1 changed files with 89 additions and 4 deletions
|
|
@ -32,9 +32,9 @@ class DefaultMcpStatelessServerHandler implements McpStatelessServerHandler {
|
|||
McpSchema.JSONRPCRequest request) {
|
||||
McpStatelessRequestHandler<?> requestHandler = this.requestHandlers.get(request.method());
|
||||
if (requestHandler == null) {
|
||||
return Mono.error(McpError.builder(McpSchema.ErrorCodes.METHOD_NOT_FOUND)
|
||||
.message("Missing handler for request type: " + request.method())
|
||||
.build());
|
||||
return Mono.just(new McpSchema.JSONRPCResponse(McpSchema.JSONRPC_VERSION, request.id(), null,
|
||||
new McpSchema.JSONRPCResponse.JSONRPCError(McpSchema.ErrorCodes.METHOD_NOT_FOUND,
|
||||
"Method not found: " + request.method(), null)));
|
||||
}
|
||||
return requestHandler.handle(transportContext, request.params())
|
||||
.map(result -> McpSchema.JSONRPCResponse.result(request.id(), result))
|
||||
|
|
|
|||
Loading…
Reference in a new issue