Skip to content

@maxhealth.tech/prefab / mcp / toolResult

Function: toolResult()

ts
function toolResult<T>(payload, options?): McpDisplayResult<T>;

Defined in: mcp/result.ts:46

Wrap a JSON payload as an MCP tool result.

The payload is serialized into content[0].text (for hosts and models that read text) and passed through as structuredContent (for MCP Apps iframes, which receive it via ui/notifications/tool-result).

Type Parameters

Type Parameter
T

Parameters

ParameterType
payloadT
options?ToolResultOptions

Returns

McpDisplayResult<T>

Example

ts
import { toolResult } from '@maxhealth.tech/prefab/mcp'

// Returning pre-built wire JSON from your own tool handler:
return toolResult(wireJson)

Released under the MIT License.