Class JsonRrpcResponseUtils

java.lang.Object
io.micronaut.mcp.server.exceptions.JsonRrpcResponseUtils

@Internal public final class JsonRrpcResponseUtils extends Object
Utility class to generate McpSchema.JSONRPCResponses allowing the gracious handling of MCP errors for primitive listings.
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 Error
      jsonrpcMessage - 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