Class JsonRrpcResponseUtils
java.lang.Object
io.micronaut.mcp.server.exceptions.JsonRrpcResponseUtils
Utility class to generate
McpSchema.JSONRPCResponse
s allowing the gracious handling of MCP errors for primitive listings.-
Method Summary
Modifier and TypeMethodDescriptionstatic io.modelcontextprotocol.spec.McpSchema.JSONRPCResponse
jsonrpcResponse
(@NonNull io.modelcontextprotocol.spec.McpError e, io.modelcontextprotocol.spec.McpSchema.JSONRPCMessage jsonrpcMessage) If the MCP error is related to a listing request to a primitive, it returns an empty response for that primitive instead of an error.static io.modelcontextprotocol.spec.McpSchema.JSONRPCMessage
map
(io.modelcontextprotocol.spec.McpSchema.JSONRPCResponse jsonrpcResponse) If the JSONRPCResponse signals an error and the error is related to a listing request to a primitive, it returns an empty response for that primitive instead of an error.
-
Method Details
-
jsonrpcResponse
@NonNull public static io.modelcontextprotocol.spec.McpSchema.JSONRPCResponse jsonrpcResponse(@NonNull @NonNull io.modelcontextprotocol.spec.McpError e, @NonNull io.modelcontextprotocol.spec.McpSchema.JSONRPCMessage jsonrpcMessage) If the MCP error is related to a listing request to a primitive, it returns an empty response for that primitive instead of an error.- Parameters:
e
- MCP ErrorjsonrpcMessage
- JSON RPC Message- Returns:
- a JSON RPC Response
-
map
@Nullable public static io.modelcontextprotocol.spec.McpSchema.JSONRPCMessage map(@Nullable io.modelcontextprotocol.spec.McpSchema.JSONRPCResponse jsonrpcResponse) If the JSONRPCResponse signals an error and the error is related to a listing request to a primitive, it returns an empty response for that primitive instead of an error.- Parameters:
jsonrpcResponse
- JSON RPC Response- Returns:
- a JSON RPC Response
-