Package dev.tachyonmcp.core.protocol
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 Summary
Modifier and TypeMethodDescriptioncallToolResult(ToolResult result) Maps a tool call result into protocol-specific shape.cancelTaskResult(TaskEntry entry) Maps a cancelled task entry into protocol-specific shape.completeResult(CompletionResult result) Maps a completion result into a protocol-specific shape.createTaskResult(TaskEntry entry) Maps a newly created task entry into a CreateTaskResult (for task-augmented requests).default ObjectdiscoverResult(List<String> supportedVersions, ServerCapabilities capabilities, ServerIdentity serverIdentity) Maps the server discovery response into a protocol-specific shape.Returns the protocol-specific empty result sent for methods that return no data.error(ServerError error) Maps a protocol-neutral server error to this protocol version's JSON-RPC error payload.getPromptResult(@Nullable String description, List<PromptMessage> messages, @Nullable Map<String, Object> meta) Maps prompt messages, metadata, and optional description into protocol-specific shape.getTaskPayloadResult(@Nullable TaskResult result, String taskId) Maps a task's terminal result into the tasks/result payload — aCallToolResult.getTaskResult(Task entry) Maps a single task entry (get result) into protocol-specific shape.initializeResult(InitializeResponse response) Maps the server's initialize response into protocol-specific shape.inputRequiredResult(Map<String, ? extends InputRequest> inputRequests, @Nullable String requestState, @Nullable Map<String, Object> meta) Maps input-required metadata into protocol-specific shape.listPromptsResult(List<PromptDescriptor> prompts, @Nullable String nextCursor) Maps a paginated list of prompt descriptors into protocol-specific shape.listResourcesResult(List<ResourceDescriptor> resources, @Nullable String nextCursor) Maps a paginated list of resource descriptors into protocol-specific shape.listResourceTemplatesResult(List<ResourceTemplateDescriptor> templates, @Nullable String nextCursor) Maps a paginated list of resource template entries into protocol-specific shape.listTasksResult(List<TaskEntry> entries, @Nullable String nextCursor) Maps a paginated list of task entries into protocol-specific shape.listToolsResult(List<ToolDescriptor> tools, @Nullable String nextCursor) Maps a paginated list of tool descriptors into protocol-specific shape.readResourceResult(List<ResourceContents> contents) Maps a resource contents list (from a read operation) into protocol-specific shape.booleanReturnstruewhen this mapper handles the given protocol family and version.Builds the params object for a tasks/status notification from a task entry.
-
Method Details
-
supports
Returnstruewhen 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
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
Maps a completion result into a protocol-specific shape. -
initializeResult
Maps the server's initialize response into protocol-specific shape. -
listToolsResult
Maps a paginated list of tool descriptors into protocol-specific shape. -
callToolResult
Maps a tool call result into protocol-specific shape. -
listResourcesResult
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
Maps a resource contents list (from a read operation) into protocol-specific shape. -
listPromptsResult
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
Maps a paginated list of task entries into protocol-specific shape. -
getTaskResult
Maps a single task entry (get result) into protocol-specific shape. -
createTaskResult
Maps a newly created task entry into a CreateTaskResult (for task-augmented requests). -
cancelTaskResult
Maps a cancelled task entry into protocol-specific shape. -
getTaskPayloadResult
Maps a task's terminal result into the tasks/result payload — aCallToolResult. -
taskStatusNotificationParams
Builds the params object for a tasks/status notification from a task entry.
-