Typed MCP result constructors and explicit client-visible business failures.
tool/2 and resource/2 emit canonical string-key maps and validate their
complete aggregate against the same bounds used for raw handler output.
They use the secure 2,000,000-byte default; pass
max_json_bytes: server_budget when the supervised server explicitly uses a
larger finite JSON budget.
Protocol-owned resultType, cache, and server-identity fields are added by
the server after a handler returns.
Arbitrary handler errors and exceptions remain private. Use error/2 only
for bounded text and a machine-readable code that are safe to disclose to
the calling client.
Summary
Functions
Builds one explicitly client-visible business error.
Builds a complete resource result from one resource-content entry or a list.
Builds a complete tool result from one content block or a list of blocks.
Types
@type resource_option() :: {:meta, map()} | {:max_json_bytes, pos_integer()}
@type tool_option() :: {:structured_content, term()} | {:is_error, boolean()} | {:meta, map()} | {:max_json_bytes, pos_integer()}
Functions
@spec error(String.t(), String.t() | nil) :: AttestoMCP.Server.Result.ClientError.t()
Builds one explicitly client-visible business error.
@spec resource( AttestoMCP.Server.Content.resource_content() | [AttestoMCP.Server.Content.resource_content()], [resource_option()] ) :: resource_result()
Builds a complete resource result from one resource-content entry or a list.
The server owns modern cache and result-discrimination fields. Unknown and duplicate options are rejected.
@spec tool(AttestoMCP.Server.Content.t() | [AttestoMCP.Server.Content.t()], [ tool_option() ]) :: tool_result()
Builds a complete tool result from one content block or a list of blocks.
:structured_content, when present, must be a bounded JSON value. :meta
must be a bounded JSON object. Unknown and duplicate options are rejected.