Interface McpToolResultConverter

All Known Implementing Classes:
DefaultMcpToolResultConverter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface McpToolResultConverter
Converts the content blocks of an MCP CallToolResult into the ToolExecutionResult the model sees. It is not invoked when the MCP server returns structuredContent, which is handled separately.

Content items are presented as plain maps, so implementations do not need a JSON library. A text item, for example, looks like {"type": "text", "text": "..."}.

The default client only supports structuredContent and text content out of the box. More specialized conversion strategies can be provided through DefaultMcpClient.Builder.toolResultConverter(McpToolResultConverter).

  • Method Details

    • convert

      ToolExecutionResult convert(List<Map<String,Object>> content, boolean isError)
      Parameters:
      content - the content blocks of CallToolResult.
      isError - whether the tool response is marked as an application-level error.
      Returns:
      the result to hand back to the caller, whose text is what the model sees.