Close response after sending error in McpStreamableServerSession#responseStream (#1041)
Closes #1040 Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
parent
f7d9a64b3c
commit
ff78191ebd
1 changed files with 55 additions and 3 deletions
|
|
@ -214,9 +214,13 @@ public class McpStreamableServerSession implements McpLoggableSession {
|
|||
// (sink)
|
||||
if (requestHandler == null) {
|
||||
MethodNotFoundError error = getMethodNotFoundError(jsonrpcRequest.method());
|
||||
return transport.sendMessage(
|
||||
McpSchema.JSONRPCResponse.error(jsonrpcRequest.id(), new McpSchema.JSONRPCResponse.JSONRPCError(
|
||||
McpSchema.ErrorCodes.METHOD_NOT_FOUND, error.message(), error.data())));
|
||||
return transport
|
||||
.sendMessage(
|
||||
McpSchema.JSONRPCResponse
|
||||
.error(jsonrpcRequest.id(),
|
||||
new McpSchema.JSONRPCResponse.JSONRPCError(
|
||||
McpSchema.ErrorCodes.METHOD_NOT_FOUND, error.message(), error.data())))
|
||||
.then(transport.closeGracefully());
|
||||
}
|
||||
return requestHandler
|
||||
.handle(new McpAsyncServerExchange(this.id, stream, clientCapabilities.get(), clientInfo.get(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue