import type { InputRequiredResult } from "@modelcontextprotocol/server"; import type { InferToolInput, InferToolOutput, ToolDefinition, ToolResult } from "../../tools.js"; /** View-tool definition — mirrors {@link ToolDefinition} plus `enabled`. */ export type ViewToolDefinition = Pick & { /** When `false`, the tool stays registered but is not listed or callable. */ enabled?: boolean; }; /** * Register an ephemeral tool the host/model can call while this component is mounted. * * Registration is synchronous against the runtime-owned App and independent * of connection completion. It is keyed by `name` only (`[runtime, name]`): * the tool registers once per mounted name and is removed on unmount. Changing * `inputSchema` / `outputSchema` without changing `name` does **not** * re-register — schemas are captured at registration time (ext-apps fixes * handler arity at registration); to change a tool's schema, register it under * a new name. `schema` is accepted as an alias for `inputSchema`. * * `title`, `description`, and `annotations` changes are applied in place via * the ext-apps handle's `update()`, passing explicit `undefined` so omitted * fields are cleared. Toggling `enabled` calls `enable()` / `disable()` * without re-registering. The handler is kept in a ref so calls always see * current React state. Registration goes through the document runtime rather * than the guest App directly, allowing the runtime to perform the * empty-handler handoff on first registration. * * Cleanup captures the registration handle inside the effect so an older * cleanup cannot remove a newer registration (e.g. after a rapid `name` * change). Registration failures are reported with `console.error` and do not * leave half-registered state. * * @example * ```tsx * useViewTool( * { name: "highlight-fruit", inputSchema: z.object({ id: z.string() }) }, * async ({ id }) => { * setSelected(id); * return { content: [{ type: "text", text: `Highlighted ${id}` }] }; * } * ); * ``` */ export declare function useViewTool, TOutput = InferToolOutput>(definition: TDef, handler: (args: TInput) => Exclude, InputRequiredResult> | Promise, InputRequiredResult>>): void;