Skip to main content

Module error_result

Module error_result 

Source
Expand description

Reusable protocol-level tool-error result shaping.

Bridges a structured JSON error payload into an MCP CallToolResult with isError: true, and builds the generic “unknown tool” protocol error every action-dispatch or router-style MCP server eventually needs.

Functions§

tool_error_result
Wrap a structured tool-error JSON payload into an MCP CallToolResult, truncating down to a small overflow envelope when the serialized payload would exceed max_response_bytes so callers never emit invalid, mid-value-truncated JSON.
unknown_tool_error
Build a generic “unknown tool” protocol error for call_tool/list_tools dispatch, naming the offending tool and (when non-empty) the tools the server does expose.