Class DefaultMcpToolResultConverter

java.lang.Object
dev.langchain4j.mcp.client.DefaultMcpToolResultConverter
All Implemented Interfaces:
McpToolResultConverter

public class DefaultMcpToolResultConverter extends Object implements McpToolResultConverter
Default converter for MCP tool responses backed by content[].

Supports text, images and embedded text resources. Images are returned as native ImageContent, preserving mixed-content order. Text-only results are joined with newlines so ToolExecutionResult.resultText() remains available. Binary resources and other unsupported content types fail explicitly; applications can provide a custom converter for them.

  • Constructor Details

    • DefaultMcpToolResultConverter

      public DefaultMcpToolResultConverter()
  • Method Details

    • convert

      public ToolExecutionResult convert(List<Map<String,Object>> content, boolean isError)
      Specified by:
      convert in interface McpToolResultConverter
      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 contents are what the model sees.