import type { BaseContext, RequestId } from "@modelcontextprotocol/client"; import type { ZodLiteral, ZodObject, ZodType } from "zod/v4"; /** * A whole-message Zod schema (`method` literal plus `params`), as accepted by * the 1.x `setRequestHandler(Schema, handler)` forms. */ export type LegacyMethodSchema = ZodObject<{ method: ZodLiteral; params: ZodType; }>; /** * The `extra` argument 1.x request handlers received. * * @deprecated Use the 2.x `BaseContext` (`extra.mcpReq.signal`, `extra.mcpReq.id`). */ export type LegacyRequestHandlerExtra = { signal: AbortSignal; requestId: RequestId; sessionId?: string; _meta?: BaseContext["mcpReq"]["_meta"]; sendRequest: BaseContext["mcpReq"]["send"]; sendNotification: BaseContext["mcpReq"]["notify"]; authInfo?: NonNullable["authInfo"]; }; /** @deprecated Use `setRequestHandler("method", { params, result }, (params, ctx) => …)`. */ export type LegacyRequestHandler = (request: S["_output"], extra: LegacyRequestHandlerExtra) => unknown; /** @deprecated Use `setNotificationHandler("method", { params }, (params) => …)`. */ export type LegacyNotificationHandler = (notification: S["_output"]) => void | Promise; /** * `setRequestHandler` with the 1.x `(Schema, handler)` form kept as a * deprecated overload next to the 2.x forms in `Modern`. */ export type LegacyRequestHandlerSetter = Modern & { /** * @deprecated 1.x form. Pass the method name and `{ params }` instead; * removed in 3.0. */ (schema: S, handler: LegacyRequestHandler): void; }; /** `setNotificationHandler` counterpart of {@link LegacyRequestHandlerSetter}. */ export type LegacyNotificationHandlerSetter = Modern & { /** * @deprecated 1.x form. Pass the method name and `{ params }` instead; * removed in 3.0. */ (schema: S, handler: LegacyNotificationHandler): void; }; /** * Arguments for the 2.x three-argument `setRequestHandler` / * `setNotificationHandler` form. */ type ModernArgs = [ method: string, schemas: { params: ZodType; }, handler: (params: unknown, ctx: BaseContext) => unknown ]; /** * Translate a 1.x `(Schema, handler)` registration into the 2.x * `(method, { params }, handler)` form, or return `undefined` when the call * is already in the 2.x form. The 1.x handler receives the reassembled * `{ method, params }` message and, for requests, a 1.x-shaped `extra`. */ export declare function toModernArgs(kind: "request" | "notification", args: unknown[]): ModernArgs | undefined; export {};