Class McpToolOutput
java.lang.Object
com.soklet.McpToolOutput
- All Implemented Interfaces:
McpCompletePayload
Immutable output of one completed MCP tool call.
For either 2025 protocol revision, structured content must be a JSON object and any declared output schema must have object type. The modern revision permits other JSON shapes. Raw/advanced handlers share one output type, so applications must select a representable shape before performing side effects. The legacy adapter does not silently wrap or discard a non-object structured value. June tool resource links omit optional icons; November and modern tool links retain them.
- Author:
- Mark Allen
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull McpToolOutput.Builderbuilder()booleanstatic @NonNull McpToolOutputfromErrorText(@NonNull String text) Creates error prose output.static @NonNull McpToolOutputfromStructuredContent(@NonNull McpJsonValue structuredContent) Creates successful structured output.static @NonNull McpToolOutputCreates successful prose output.inthashCode()isError()Returns a builder initialized with every field of this output.
-
Method Details
-
builder
- Returns:
- an empty tool-output builder
-
fromText
Creates successful prose output.- Parameters:
text- prose text- Returns:
- tool output containing one text block
-
fromStructuredContent
Creates successful structured output.- Parameters:
structuredContent- structured JSON value- Returns:
- tool output carrying structured content
-
fromErrorText
Creates error prose output.- Parameters:
text- safe client-visible error text- Returns:
- error tool output containing one text block
-
getContent
- Returns:
- immutable content blocks in insertion order
-
getStructuredContent
- Returns:
- structured JSON content, if supplied
-
isError
-
toBuilder
Returns a builder initialized with every field of this output.Content blocks retain their insertion order, structured content is copied when present, and the application-level error state is preserved. This is the preferred starting point for a sanitizer that changes only selected fields while retaining all other tool output.
- Returns:
- field-preserving builder initialized from this output
-
equals
-
hashCode
-