Class McpToolOutcome

java.lang.Object
org.apache.juneau.rest.server.mcp.McpToolOutcome

public class McpToolOutcome extends Object
Revision-neutral result of a tools/call invocation.

Supersedes the wire-level CallToolResult bean. structuredContent is cross-revision. Deliberately absent: cachePolicy, which remains specific to later MCP revisions.

Note the field is named error, while the 2025-06-18 wire property is isError; the rename happens at the adapter boundary and is intentional. Do not "fix" this field name to match the wire.

  • Constructor Details

  • Method Details

    • text

      public static McpToolOutcome text(String value)
      Creates an outcome carrying a single text block.
      Parameters:
      value - The text. Can be null.
      Returns:
      A new outcome. Never null.
    • of

      public static McpToolOutcome of(McpContentBlock... values)
      Creates an outcome carrying the supplied blocks.
      Parameters:
      values - The content blocks. Must not be null.
      Returns:
      A new outcome. Never null.
    • getContent

      The content blocks returned by the tool.
      Returns:
      The blocks, or null if not set. A null value is distinct from an empty list: it means the wire property is omitted entirely.
    • setContent

      Sets the content blocks.
      Parameters:
      value - The new value. Can be null to unset the property.
      Returns:
      This object.
    • getError

      public Boolean getError()
      Whether the tool call represents an error result.
      Returns:
      The flag, or null if not set.
    • setError

      Sets the error flag.
      Parameters:
      value - The new value. Can be null to unset the property.
      Returns:
      This object.
    • getStructuredContent

      The structured JSON result returned by the tool.
      Returns:
      The JSON value, or null if absent.
    • setStructuredContent

      Sets the structured JSON result.
      Parameters:
      value - Any JSON-compatible value. Can be null.
      Returns:
      This object.