Package io.openliberty.mcp.tools
Record Class ToolResponse
java.lang.Object
java.lang.Record
io.openliberty.mcp.tools.ToolResponse
- Record Components:
isError-trueif the tool call ended in an errorcontent- the list of content items (must not benull)structuredContent- the optional structured result of the tool call_meta- the optional metadata
public record ToolResponse(boolean isError, List<? extends Content> content, Object structuredContent, Map<MetaKey,Object> _meta)
extends Record
Response to a
tools/call request from the client.-
Constructor Summary
ConstructorsConstructorDescriptionToolResponse(boolean isError, List<? extends Content> content) ToolResponse(boolean isError, List<? extends Content> content, Object structuredContent, Map<MetaKey, Object> _meta) Creates an instance of aToolResponserecord class. -
Method Summary
Modifier and TypeMethodDescription_meta()Returns the value of the_metarecord component.content()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.static ToolResponsefinal inthashCode()Returns a hash code value for this object.booleanisError()Returns the value of theisErrorrecord component.Returns the value of thestructuredContentrecord component.static ToolResponsestructuredError(Object structuredContent) static ToolResponsestructuredSuccess(String message, Object structuredContent) static <C extends Content>
ToolResponsesuccess(C... content) static ToolResponsestatic <C extends Content>
ToolResponsefinal StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ToolResponse
-
ToolResponse
-
ToolResponse
public ToolResponse(boolean isError, List<? extends Content> content, Object structuredContent, Map<MetaKey, Object> _meta) Creates an instance of aToolResponserecord class.- Parameters:
isError- the value for theisErrorrecord componentcontent- the value for thecontentrecord componentstructuredContent- the value for thestructuredContentrecord component_meta- the value for the_metarecord component
-
-
Method Details
-
success
- Type Parameters:
C- the content type- Parameters:
content- the content- Returns:
- a successful response with the specified content items
-
success
- Type Parameters:
C- the content type- Parameters:
content- the content- Returns:
- a successful response with the specified content items
-
error
- Parameters:
message- the error message- Returns:
- an unsuccessful response with single text content item
-
success
- Parameters:
message- the message to include as text content in the response- Returns:
- a successful response with single text content item
-
structuredError
- Parameters:
structuredContent- the structured content to include in the response- Returns:
- an unsuccessful response with structured content
-
structuredSuccess
- Parameters:
message- a message, returned as unstructured text contentstructuredContent- the structured content- Returns:
- a successful response with structured content
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
isError
public boolean isError()Returns the value of theisErrorrecord component.- Returns:
- the value of the
isErrorrecord component
-
content
Returns the value of thecontentrecord component.- Returns:
- the value of the
contentrecord component
-
structuredContent
Returns the value of thestructuredContentrecord component.- Returns:
- the value of the
structuredContentrecord component
-
_meta
Returns the value of the_metarecord component.- Returns:
- the value of the
_metarecord component
-