Skip to main content

Module helpers

Module helpers 

Source
Expand description

MCP helper functions — error and result formatting.

Functions§

json_result
Wrap a JSON value into a successful MCP call result.
mcp_err
Convert a crate Error into an MCP protocol error with structured data.
run_json
Run a permission check (or .and(...)-chained checks), then a future, and wrap the JSON result. Errors are surfaced as a CallToolResult with is_error: true (per MCP spec) rather than as a transport-level McpError, so an AI agent client can recover without aborting its loop.
run_text
Like run_json but wraps a plain text result.
text_result
Wrap a plain text string into a successful MCP call result.