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[].

It only supports content items of type text, joins multiple text fragments with newline characters, and stores the result in ToolExecutionResult.resultText().

  • 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 text is what the model sees.