import type { McpUiResourceMeta } from '@modelcontextprotocol/ext-apps'; import type { RequestHandlerExtra, RequestOptions } from '@modelcontextprotocol/sdk/shared/protocol.js'; import type { ElicitRequest, ElicitResult, Prompt, PromptMessage, Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js'; /** * Callback function to retrieve content for a specific resource. * * @param params - Parameters for resource content retrieval * @param params.uri - URI of the resource to retrieve * @param params.extra - Additional request handler context * @returns Promise resolving to resource content (single or array) */ export type MCPServerResourceContentCallback = ({ uri, extra, }: { uri: string; extra: MCPRequestHandlerExtra; }) => Promise; /** * Content for an MCP resource, either text or binary (base64-encoded). */ export type MCPServerResourceContent = { text?: string; } | { blob?: string; }; /** * Configuration for MCP server resource handling. * * Defines callbacks for listing resources, retrieving content, and optionally listing templates. */ export type MCPServerResources = { /** Function to list all available resources */ listResources: ({ extra }: { extra: MCPRequestHandlerExtra; }) => Promise; /** Function to get content for a specific resource */ getResourceContent: MCPServerResourceContentCallback; /** Optional function to list resource templates */ resourceTemplates?: ({ extra }: { extra: MCPRequestHandlerExtra; }) => Promise; }; /** * Extends the MCP SDK Prompt type with an optional version field. * * The MCP protocol does not include `version` on prompts, so this field is * only used server-side for internal prompt lookup and is not sent over the wire. * * @deprecated The `version` field is not part of the MCP protocol and will be removed in a future release. * Use distinct prompt names instead (e.g., `explain-code-v1`, `explain-code-v2`). */ export type MastraPrompt = Prompt & { /** * @deprecated The `version` field is not part of the MCP protocol and will be removed in a future release. * Use distinct prompt names instead (e.g., `explain-code-v1`, `explain-code-v2`). */ version?: string; }; /** * Callback function to retrieve messages for a specific prompt. * * @param params - Parameters for prompt message retrieval * @param params.name - Name of the prompt * @param params.version - Optional version of the prompt * @param params.args - Optional arguments for the prompt * @param params.extra - Additional request handler context * @returns Promise resolving to array of prompt messages */ export type MCPServerPromptMessagesCallback = ({ name, version, args, extra, }: { name: string; /** * @deprecated The `version` field is not part of the MCP protocol and will be removed in a future release. * Use distinct prompt names instead (e.g., `explain-code-v1`, `explain-code-v2`). */ version?: string; args?: any; extra: MCPRequestHandlerExtra; }) => Promise; /** * Configuration for MCP server prompt handling. * * Defines callbacks for listing prompts and retrieving prompt messages. */ export type MCPServerPrompts = { /** Function to list all available prompts */ listPrompts: ({ extra }: { extra: MCPRequestHandlerExtra; }) => Promise; /** Optional function to get messages for a specific prompt */ getPromptMessages?: MCPServerPromptMessagesCallback; }; /** * Actions for handling elicitation requests (interactive user input collection). */ export type ElicitationActions = { /** * Function to send an elicitation request to the client. * * @param request - The elicitation request parameters * @param options - Optional request options (timeout, signal, etc.) * @returns Promise resolving to the client's elicitation response */ sendRequest: (request: ElicitRequest['params'], options?: RequestOptions) => Promise; }; /** * Extra context passed to MCP request handlers. */ export type MCPRequestHandlerExtra = RequestHandlerExtra; /** * Re-exported MCP SDK types for resource handling. * * - `Resource`: Represents a data resource exposed by the server * - `ResourceTemplate`: URI template for dynamic resource generation * - `RequestOptions`: Options for MCP requests (timeout, signal, etc.) */ export type { Resource, ResourceTemplate, RequestOptions }; /** * Configuration for a single MCP App resource. * * App resources serve interactive HTML UIs via the `ui://` URI scheme * as defined by the MCP Apps extension (SEP-1865). */ export interface AppResource { /** Display name for the UI resource */ name: string; /** Optional description of the UI resource */ description?: string; /** Inline HTML content for the UI */ html?: string; /** Path to an HTML file (resolved at startup) */ htmlPath?: string; /** UI resource metadata (CSP, permissions, rendering preferences) from the official ext-apps SDK */ meta?: McpUiResourceMeta; } /** * Map of `ui://` URIs to their app resource configurations. * * Used as a convenience config on MCPServer to auto-register UI resources * that are served via the MCP Apps extension. * * @example * ```typescript * const appResources: AppResources = { * 'ui://weather/dashboard': { * name: 'Weather Dashboard', * html: '...', * meta: { csp: { connectDomains: ['https://api.weather.com'] } }, * }, * }; * ``` */ export type AppResources = Record; //# sourceMappingURL=types.d.ts.map