Interface CallToolResultMapper
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A converter from the
McpSchema.CallToolResult of an MCP tool call to the response of the ADK tool.
By default, MCP tools return only the text content of a result, under text_output. Set
a mapper on McpToolset.Builder or McpAsyncToolset.Builder to return other parts
of the result, such as structuredContent or images.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CallToolResultMapperReturns a mapper that returns the whole result in the MCP wire format:content, plusstructuredContent,isErrorand_metawhen set.map(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.spec.McpSchema.CallToolResult callToolResult) Returns the response ofmcpToolforcallToolResult, including results withisErrorset.static CallToolResultMappertextOutput(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Returns the default mapper, which keeps only the text content undertext_output, or returns anerror.
-
Method Details
-
map
Map<String,Object> map(io.modelcontextprotocol.spec.McpSchema.Tool mcpTool, io.modelcontextprotocol.spec.McpSchema.CallToolResult callToolResult) Returns the response ofmcpToolforcallToolResult, including results withisErrorset.The response becomes the function response sent to the model, so it must not be null and its values must serialize to JSON. If the mapper throws, the tool call fails and is not retried.
-
textOutput
Returns the default mapper, which keeps only the text content undertext_output, or returns anerror. It parses each text item as JSON withobjectMapper, or keeps it undertext. Its responses are immutable, so a custom mapper copies one before adding other parts of the result. -
fullResult
Returns a mapper that returns the whole result in the MCP wire format:content, plusstructuredContent,isErrorand_metawhen set. AnafterToolCallbackcan then reshape it, as theexamples/mcpfullresultsample does. Servers that repeatstructuredContentas text send it to the model twice, and images reach the model as base64 text, which it cannot read.
-