Interface ProtocolResponseMapper

All Known Implementing Classes:
McpResponseMapper, McpResponseMapper

public interface ProtocolResponseMapper
Maps domain objects to protocol-specific response shapes.

Each protocol version (e.g. MCP 2025-11-25) provides its own implementation registered via ServiceLoader.

  • Method Details

    • supports

      boolean supports(String protocolName, String protocolVersion)
      Returns true when this mapper handles the given protocol family and version.
    • emptyResult

      Object emptyResult()
      Returns the protocol-specific empty result sent for methods that return no data.
    • error

      JsonRpcError error(ServerError error)
      Maps a protocol-neutral server error to this protocol version's JSON-RPC error payload.
    • discoverResult

      default Object discoverResult(List<String> supportedVersions, ServerCapabilities capabilities, ServerIdentity serverIdentity)
      Maps the server discovery response into a protocol-specific shape.
    • completeResult

      Object completeResult(CompletionResult result)
      Maps a completion result into a protocol-specific shape.
    • initializeResult

      Object initializeResult(InitializeResponse response)
      Maps the server's initialize response into protocol-specific shape.
    • listToolsResult

      Object listToolsResult(List<ToolDescriptor> tools, @Nullable String nextCursor)
      Maps a paginated list of tool descriptors into protocol-specific shape.
    • callToolResult

      Object callToolResult(ToolResult result)
      Maps a tool call result into protocol-specific shape.
    • listResourcesResult

      Object listResourcesResult(List<ResourceDescriptor> resources, @Nullable String nextCursor)
      Maps a paginated list of resource descriptors into protocol-specific shape.
    • listResourceTemplatesResult

      Object listResourceTemplatesResult(List<ResourceTemplateDescriptor> templates, @Nullable String nextCursor)
      Maps a paginated list of resource template entries into protocol-specific shape.
    • readResourceResult

      Object readResourceResult(List<ResourceContents> contents)
      Maps a resource contents list (from a read operation) into protocol-specific shape.
    • listPromptsResult

      Object listPromptsResult(List<PromptDescriptor> prompts, @Nullable String nextCursor)
      Maps a paginated list of prompt descriptors into protocol-specific shape.
    • getPromptResult

      Object getPromptResult(@Nullable String description, List<PromptMessage> messages, @Nullable Map<String,Object> meta)
      Maps prompt messages, metadata, and optional description into protocol-specific shape.
    • inputRequiredResult

      Object inputRequiredResult(Map<String,? extends InputRequest> inputRequests, @Nullable String requestState, @Nullable Map<String,Object> meta)
      Maps input-required metadata into protocol-specific shape.
    • listTasksResult

      Object listTasksResult(List<TaskEntry> entries, @Nullable String nextCursor)
      Maps a paginated list of task entries into protocol-specific shape.
    • getTaskResult

      Object getTaskResult(Task entry)
      Maps a single task entry (get result) into protocol-specific shape.
    • createTaskResult

      Object createTaskResult(TaskEntry entry)
      Maps a newly created task entry into a CreateTaskResult (for task-augmented requests).
    • cancelTaskResult

      Object cancelTaskResult(TaskEntry entry)
      Maps a cancelled task entry into protocol-specific shape.
    • getTaskPayloadResult

      Object getTaskPayloadResult(@Nullable TaskResult result, String taskId)
      Maps a task's terminal result into the tasks/result payload — a CallToolResult.
    • taskStatusNotificationParams

      Object taskStatusNotificationParams(TaskEntry entry)
      Builds the params object for a tasks/status notification from a task entry.