/** * MCP SDK Compatibility Helpers * * Internal utilities for handling differences between MCP SDK versions. * These helpers abstract away SDK-internal details like: * - Tool callback/handler property names (changed in SDK 1.24) * - Zod schema internal structures (v3 vs v4) */ import type { RegisteredTool, ToolCallback } from '../types'; export type ToolFunctionKey = 'callback' | 'handler'; /** * Returns the tool function (callback/handler) from a RegisteredTool. * Supports both MCP SDK 1.23- (callback) and 1.24+ (handler). */ export declare function getToolFunction(tool: RegisteredTool): ToolCallback; /** * Returns the property key name used for the tool function ("callback" or "handler"). * This preserves the original property name when wrapping tools. */ export declare function getToolFunctionKey(tool: RegisteredTool): ToolFunctionKey; /** * Returns true if the tool has a callback or handler property. */ export declare function hasToolFunction(tool: unknown): tool is RegisteredTool; /** * Creates a new tool object with the wrapped function, preserving the original property name. * This ensures MCP SDK 1.24+ gets back a tool with "handler" and 1.23- gets "callback". */ export declare function createWrappedTool(originalTool: RegisteredTool, wrappedFunction: ToolCallback): RegisteredTool; export declare function isZ4Schema(schema: unknown): boolean; export declare function isZodRawShapeCompat(schema: unknown): schema is Record; export declare function getObjectShape(schema: unknown): Record | undefined; /** * Reads the method name a `setRequestHandler` registration is for. * * The two SDK majors disagree on what the first argument is: v1 passes the Zod * schema for the request and carries the method as a literal on its shape, v2 * passes the method string itself. A registration we cannot name is one we * cannot match against a patch — which is how a handler registered after * `instrument()` on v2 ends up replacing our wrapper instead of being wrapped. */ export declare function readRequestHandlerMethod(requestSchema: unknown): string | undefined; export declare function getLiteralValue(schema: unknown): unknown; //# sourceMappingURL=mcp-sdk-compat.d.ts.map