AttestoMCP.Server.Result (attesto_mcp_server v0.14.0)

Copy Markdown View Source

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

resource_option()

@type resource_option() :: {:meta, map()} | {:max_json_bytes, pos_integer()}

resource_result()

@type resource_result() :: %{required(String.t()) => term()}

tool_option()

@type tool_option() ::
  {:structured_content, term()}
  | {:is_error, boolean()}
  | {:meta, map()}
  | {:max_json_bytes, pos_integer()}

tool_result()

@type tool_result() :: %{required(String.t()) => term()}

Functions

error(message, code \\ nil)

Builds one explicitly client-visible business error.

resource(contents, opts \\ [])

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.

tool(content, opts \\ [])

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.