Claudio.MCP.ResultMapper (Claudio v0.5.0)
View SourceMaps tool use blocks from Claudio responses back to MCP call format.
After Claude responds with tool_use or mcp_tool_use blocks, this module extracts them into a format suitable for calling back to MCP servers.
Example
response = Claudio.Messages.create(client, request)
calls = Claudio.MCP.ResultMapper.extract_mcp_calls(response)
results = Enum.map(calls, fn call ->
{:ok, result} = MyAdapter.call_tool(mcp_client, call.name, call.arguments)
Claudio.Tools.create_tool_result(call.id, result)
end)
Summary
Functions
Alias for extract_mcp_calls/1.
Extracts MCP tool calls from a response.
Extracts MCP tool calls for a specific server.
Types
Functions
@spec claudio_to_mcp(Claudio.Messages.Response.t()) :: [mcp_call()]
Alias for extract_mcp_calls/1.
@spec extract_mcp_calls(Claudio.Messages.Response.t()) :: [mcp_call()]
Extracts MCP tool calls from a response.
Handles both mcp_tool_use blocks (from server-side MCP connector) and
regular tool_use blocks with prefixed names (from client-side MCP tools).
Note: Regular tool_use blocks are identified as MCP calls when their name
contains __ (double underscore) as a separator — e.g., server_name__tool_name.
If you define non-MCP tools with __ in their names, they will be incorrectly
captured. Use mcp_tool_use blocks (from the server-side MCP connector) or avoid
__ in regular tool names to prevent ambiguity.
@spec extract_mcp_calls(Claudio.Messages.Response.t(), String.t()) :: [mcp_call()]
Extracts MCP tool calls for a specific server.