Package io.modelcontextprotocol.spec
Class McpSchema.CallToolResult.Builder
java.lang.Object
io.modelcontextprotocol.spec.McpSchema.CallToolResult.Builder
- Enclosing class:
- McpSchema.CallToolResult
Builder for
McpSchema.CallToolResult.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddContent(McpSchema.Content contentItem) Adds a content item to the tool result.addTextContent(String text) Adds a text content item to the tool result.build()Builds a newMcpSchema.CallToolResultinstance.content(List<McpSchema.Content> content) Sets the content list for the tool result.Sets whether the tool execution resulted in an error.Sets the metadata for the tool result.structuredContent(String structuredContent) structuredContent(Map<String, Object> structuredContent) textContent(List<String> textContent) Sets the text content for the tool result.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
content
Sets the content list for the tool result.- Parameters:
content- the content list- Returns:
- this builder
-
structuredContent
-
structuredContent
-
textContent
Sets the text content for the tool result.- Parameters:
textContent- the text content- Returns:
- this builder
-
addContent
Adds a content item to the tool result.- Parameters:
contentItem- the content item to add- Returns:
- this builder
-
addTextContent
Adds a text content item to the tool result.- Parameters:
text- the text content- Returns:
- this builder
-
isError
Sets whether the tool execution resulted in an error.- Parameters:
isError- true if the tool execution failed, false otherwise- Returns:
- this builder
-
meta
Sets the metadata for the tool result.- Parameters:
meta- metadata- Returns:
- this builder
-
build
Builds a newMcpSchema.CallToolResultinstance.- Returns:
- a new CallToolResult instance
-