import { type z, type ZodType } from '@frontmcp/lazy-zod'; import type { AuthInfo, McpServerOptions, Notification, Request, RequestHandlerExtra, Result } from '@frontmcp/protocol'; import type { Authorization } from '../../common'; import type { Scope } from '../../scope'; import type { LocalTransporter } from '../transport.local'; type Primitive = string | number | boolean | bigint | null | undefined; type Flatten = T extends Primitive ? T : T extends Array ? Array> : T extends Set ? Set> : T extends Map ? Map, Flatten> : T extends object ? { [K in keyof T]: Flatten; } : T; type Infer = Flatten>; export interface McpHandler = z.ZodObject, Out extends z.ZodObject = z.ZodObject, HandlerNotification extends Notification = Notification> { when?: (request: Infer) => boolean; requestSchema: In; responseSchema?: Out; handler: (request: HandlerRequest, ctx: McpRequestHandler) => Promise | HandlerResult; } export type McpHandlerOptions = { scope: Scope; serverOptions: McpServerOptions; /** * Lazily compose the `initialize` response's `instructions` field. * * When provided, the `initialize` handler invokes this on every request so * the catalog reflects skills registered AFTER server boot (e.g. dynamic * `registerSkillContent` calls). When omitted, the handler falls back to * the static `serverOptions.instructions` baked at construction time. * * Must remain synchronous — the MCP `initialize` request must respond * promptly without round-tripping to slow stores. */ composeInstructions?: () => string | undefined; }; export type McpRequestHandler = RequestHandlerExtra & { authInfo?: AuthInfo & { extra?: { [key: string]: unknown; transport: LocalTransporter; authSession: Authorization; }; }; }; export {}; //# sourceMappingURL=mcp-handlers.types.d.ts.map