import type { CallToolResult } from "@modelcontextprotocol/server"; /** * Typed {@link CallToolResult} that constrains `structuredContent` to `T`. * * @deprecated Prefer returning a raw {@link CallToolResult} from tool * callbacks. Example: `{ content: [{ type: "text", text: JSON.stringify(data) }], structuredContent: data }`. * * @typeParam T - Structured payload type (typically an object). */ export interface TypedCallToolResult = Record> { [x: string]: unknown; /** Model-visible content blocks. */ content: CallToolResult["content"]; /** Whether the result represents a tool-domain error. */ isError?: CallToolResult["isError"]; /** Protocol extension metadata. */ _meta?: CallToolResult["_meta"]; /** Typed structured payload. */ structuredContent?: T; } /** * Content-only tool result (`structuredContent` pinned to `never`). * * @deprecated Prefer returning a raw {@link CallToolResult}: * `{ content: [{ type: "text", text }] }`. */ export interface ToolContentResult { [x: string]: unknown; /** Model-visible content blocks. */ content: CallToolResult["content"]; /** Whether the result represents a tool-domain error. */ isError?: CallToolResult["isError"]; /** Protocol extension metadata. */ _meta?: CallToolResult["_meta"]; /** Content-only helpers never provide structured content. */ structuredContent?: never; } /** * Create a plain-text tool result. * * @deprecated Prefer `{ content: [{ type: "text", text: content }] }`. * * @param content - Text to return. * @returns Tool result with a single text content block. * * @example * ```ts * // Preferred: * return { content: [{ type: "text", text: `Hello, ${name}!` }] }; * // Deprecated: * return text(`Hello, ${name}!`); * ``` */ export declare function text(content: string): ToolContentResult; /** * Create a Markdown text tool result. * * @deprecated Prefer `{ content: [{ type: "text", text: content }] }`. * * @param content - Markdown text. * @returns Tool result with `text/markdown` MIME metadata. */ export declare function markdown(content: string): ToolContentResult; /** * Create an HTML text tool result. * * @deprecated Prefer `{ content: [{ type: "text", text: content }] }`. * * @param content - HTML text. * @returns Tool result with `text/html` MIME metadata. */ export declare function html(content: string): ToolContentResult; /** * Create an XML text tool result. * * @deprecated Prefer `{ content: [{ type: "text", text: content }] }`. * * @param content - XML text. * @returns Tool result with `text/xml` MIME metadata. */ export declare function xml(content: string): ToolContentResult; /** * Create a CSS text tool result. * * @deprecated Prefer `{ content: [{ type: "text", text: content }] }`. * * @param content - CSS text. * @returns Tool result with `text/css` MIME metadata. */ export declare function css(content: string): ToolContentResult; /** * Create a JavaScript text tool result. * * @deprecated Prefer `{ content: [{ type: "text", text: content }] }`. * * @param content - JavaScript source text. * @returns Tool result with `text/javascript` MIME metadata. */ export declare function javascript(content: string): ToolContentResult; /** * Create an image content tool result. * * @deprecated Prefer * `{ content: [{ type: "image", data, mimeType }] }`. * * @param data - Base64 image data (or data URL payload). * @param mimeType - Image MIME type. * @returns Tool result with an image content block. * * @defaultValue mimeType - `"image/png"` */ export declare function image(data: string, mimeType?: string): ToolContentResult; /** * Create an audio content tool result from base64 data. * * @deprecated Prefer * `{ content: [{ type: "audio", data, mimeType }] }`. * * @param data - Base64-encoded audio. * @param mimeType - Audio MIME type. * @returns Tool result with an audio content block. * * @defaultValue mimeType - `"audio/wav"` */ export declare function audio(data: string, mimeType?: string): ToolContentResult; /** * Create a binary payload carried as base64 text. * * @deprecated Prefer a raw {@link CallToolResult} with an appropriate content * block, or a resource `{ contents: [{ uri, mimeType, blob }] }`. * * @param base64Data - Base64-encoded bytes. * @param mimeType - MIME type of the binary payload. * @returns Tool result with base64 text and binary MIME metadata. */ export declare function binary(base64Data: string, mimeType: string): ToolContentResult; /** * Create an embedded-resource content block for a tool result. * * Supports `resource(uri, mimeType, text?)` or `resource(uri, callToolResult)`. * * @deprecated Prefer * `{ content: [{ type: "resource", resource: { uri, mimeType, text } }] }`. * * @param uri - Resource URI. * @param mimeTypeOrContent - MIME type string, or a helper/`CallToolResult` to extract from. * @param text - Optional text body (3-arg form). * @returns Tool result with an embedded resource content block. */ export declare function resource(uri: string, mimeTypeOrContent: string | CallToolResult | TypedCallToolResult, text?: string): ToolContentResult; /** * Create a failed tool result. * * @deprecated Prefer * `{ isError: true, content: [{ type: "text", text: message }] }`. * * @param message - Error message shown to the model. * @returns Tool result with `isError: true`. */ export declare function error(message: string): TypedCallToolResult; /** * Create a structured JSON object tool result. * * @deprecated Prefer * `{ content: [{ type: "text", text: JSON.stringify(data) }], structuredContent: data }`. * * @typeParam T - Object payload type. * @param data - Object (or array — forwarded to {@link array}) to return. * @returns Tool result with JSON text and `structuredContent`. */ export declare function object>(data: T): TypedCallToolResult; /** * Create a structured array tool result (2026 any-JSON root — no `{ data }` wrap). * * @deprecated Prefer * `{ content: [{ type: "text", text: JSON.stringify(data) }], structuredContent: data }` * or `{ content: [], structuredContent: data }` (SDK may auto-append JSON text for * non-object roots). * * @typeParam T - Array payload type. * @param data - Array to return as `structuredContent`. * @returns Tool result with JSON text and the array as `structuredContent`. */ export declare function array(data: T): CallToolResult; /** * Runtime data for a view-bound tool result (legacy widget helper). * * @deprecated Prefer returning a plain {@link CallToolResult} from a tool * registered with `view: { name }`. Put view props in `structuredContent` and * model-facing text in `content`. * * @typeParam TProps - Props object placed in `structuredContent`. */ export interface WidgetResponseConfig = Record> { /** View-facing data sent as `structuredContent`. */ props?: TProps; /** * Legacy alias for {@link WidgetResponseConfig.props}. * * @deprecated Use `props` instead. */ data?: TProps; /** Model-facing helper/`CallToolResult` whose `content` is forwarded. */ output?: CallToolResult | TypedCallToolResult; /** Extra result `_meta` for the view. */ metadata?: Record; /** Override text when `output` is omitted or should be replaced. */ message?: string; } /** * Create a view/widget tool result (`props` → `structuredContent`). * * @deprecated Prefer a plain {@link CallToolResult} with `view:` on the tool * definition: * `{ content: [{ type: "text", text }], structuredContent: props }`. * * @typeParam TProps - Props object type. * @param config - Runtime view data. * @returns Tool result with props in `structuredContent`. */ export declare function widget = Record>(config: WidgetResponseConfig): TypedCallToolResult; /** * Merge several tool results into one (`content` concatenated; objects shallow-merged). * * @deprecated Prefer building a single raw {@link CallToolResult} with the * desired `content` array. * * @param results - Results to merge. * @returns Combined tool result. */ export declare function mix(...results: CallToolResult[]): CallToolResult;