Files
SnowLuma/.pnpm-store/v11/files/20/93c1e00222ee93dd5ed9883605f7b25fb2f1e8af42565761e425642b31c4c2053f1b6e39c90048bde850661a489ca83d436f35003df966144a390140a37174
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Skipped
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

67 lines
2.7 KiB
Plaintext

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<string>;
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<BaseContext["http"]>["authInfo"];
};
/** @deprecated Use `setRequestHandler("method", { params, result }, (params, ctx) => …)`. */
export type LegacyRequestHandler<S extends LegacyMethodSchema> = (request: S["_output"], extra: LegacyRequestHandlerExtra) => unknown;
/** @deprecated Use `setNotificationHandler("method", { params }, (params) => …)`. */
export type LegacyNotificationHandler<S extends LegacyMethodSchema> = (notification: S["_output"]) => void | Promise<void>;
/**
* `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> = Modern & {
/**
* @deprecated 1.x form. Pass the method name and `{ params }` instead;
* removed in 3.0.
*/
<S extends LegacyMethodSchema>(schema: S, handler: LegacyRequestHandler<S>): void;
};
/** `setNotificationHandler` counterpart of {@link LegacyRequestHandlerSetter}. */
export type LegacyNotificationHandlerSetter<Modern> = Modern & {
/**
* @deprecated 1.x form. Pass the method name and `{ params }` instead;
* removed in 3.0.
*/
<S extends LegacyMethodSchema>(schema: S, handler: LegacyNotificationHandler<S>): 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 {};