defineTool and defineAction
Tool options, ToolContext, and Result types.
defineTool
defineTool({
name?: string;
description: string;
input?: Schema;
output?: Schema;
connect?: string[];
resources?: string[];
visibility?: ("model" | "app")[];
annotations?: {
readOnlyHint?: boolean;
destructiveHint?: boolean;
idempotentHint?: boolean;
openWorldHint?: boolean;
};
confirm?: (input, ctx) => ConfirmResult | string;
html?: string;
execute: (input, ctx) => Promise<TOutput | Result<TOutput>> | TOutput | Result<TOutput>;
});Happy-path fields: description, input, execute.
confirm sets destructiveHint: true unless you override annotations.
defineAction
Same config as defineTool, but:
kind: "action"visibility: ["app"]
result()
result(data, text): Result<T>
isResult(value): booleanResultOf
type ResultOf<T> =
T extends DefinedTool<unknown, infer TOutput> ? TOutput : never;ToolContext
| Field | Description |
|---|---|
ask(schema, message?) | MRTR continuation inside execute |
inputRequired(spec) | Raw MRTR escape hatch |
inputResponses | Answers from a prior ask |
handle() | Mint opaque handle id |
auth | Auth context when wired |
request | Incoming HTTP request or stdio envelope |
ConfirmResult
type ConfirmResult = {
message: string;
preview?: unknown;
};preview is included on the MRTR structuredContent so a View can render it. Text clients still see message.
Constants
Exported from bitmcp:
PROTOCOL_VERSION:2026-07-28RESOURCE_MIME_TYPE:text/html;profile=mcp-appEXTENSION_ID:io.modelcontextprotocol/ui