//#region packages/elicitation/src/types.d.ts /** * MCP elicitation types. * * Elicitation allows tools to request structured input from the user via * the MCP client. The schema follows JSON Schema constraints: * only flat primitives and string arrays are supported. */ /** User action on the elicitation dialog. */ type ElicitAction = 'accept' | 'decline' | 'cancel'; /** Flat content map — MCP only supports primitives + string arrays. */ type ElicitContent = Record; /** Normalized elicitation response. */ interface ElicitResponse { action: ElicitAction; content?: T; } interface TextFieldSchema { type: 'string'; title: string; description?: string; minLength?: number; maxLength?: number; default?: string; } interface EnumFieldSchema { type: 'string'; title: string; description?: string; enum: string[]; enumNames?: string[]; default?: string; } interface ArrayFieldSchema { type: 'array'; title: string; description?: string; items: { type: 'string'; enum: string[]; }; uniqueItems: true; } interface BooleanFieldSchema { type: 'boolean'; title: string; description?: string; default?: boolean; } interface NumberFieldSchema { type: 'number' | 'integer'; title: string; description?: string; minimum?: number; maximum?: number; default?: number; } type FieldSchema = TextFieldSchema | EnumFieldSchema | ArrayFieldSchema | BooleanFieldSchema | NumberFieldSchema; /** JSON Schema object for the elicitation form. */ interface ElicitFormSchema { type: 'object'; properties: Record; required?: string[]; } interface ElicitOptions { message: string; schema: ElicitFormSchema; } /** * High-level elicitation interface exposed to tools. * Wraps `server.createElicitation()` with convenience methods. */ interface Elicitor { /** Whether the connected client supports elicitation. */ readonly available: boolean; /** Ask a structured form question. */ ask(opts: ElicitOptions): Promise>; /** Yes/no confirmation. */ confirm(message: string): Promise; /** Pick one from a list. Returns null if declined/cancelled. */ selectOne(message: string, options: string[]): Promise; /** Pick many from a list. Returns empty array if declined/cancelled. */ selectMany(message: string, options: string[]): Promise; /** Free text prompt. Returns null if declined/cancelled. */ promptText(message: string, description?: string): Promise; } //#endregion //#region packages/elicitation/src/build.d.ts /** Build a form schema from a record of named fields. */ declare function buildFormSchema(fields: Record, required?: string[]): ElicitFormSchema; /** * Build the full elicitation request options. * `message` — prompt text shown above the form. * `fields` — record of field-id → FieldSchema. * `required` — field ids that must be filled. */ declare function buildElicitRequest(message: string, fields: Record, required?: string[]): ElicitOptions; //#endregion //#region packages/elicitation/src/fields.d.ts declare const field: { /** Free text input. */readonly text: (title: string, opts?: { description?: string; minLength?: number; maxLength?: number; default?: string; }) => TextFieldSchema; /** Single-select dropdown/radio. */ readonly select: (title: string, options: string[], opts?: { description?: string; enumNames?: string[]; default?: string; }) => EnumFieldSchema; /** Multi-select checkboxes. */ readonly multi: (title: string, options: string[], opts?: { description?: string; }) => ArrayFieldSchema; /** Boolean checkbox / confirmation. */ readonly confirm: (title: string, opts?: { description?: string; default?: boolean; }) => BooleanFieldSchema; /** Numeric input. */ readonly number: (title: string, opts?: { description?: string; minimum?: number; maximum?: number; integer?: boolean; default?: number; }) => NumberFieldSchema; }; //#endregion //#region packages/elicitation/src/normalize.d.ts /** Raw elicitation result from the MCP SDK. */ interface RawElicitResult { action: string; content?: Record; } /** * Normalize a raw MCP elicitation result into a typed response. * Handles missing fields, unknown actions, and type coercion. */ declare function normalizeResponse(raw: RawElicitResult | undefined | null): ElicitResponse; //#endregion export { type ArrayFieldSchema, type BooleanFieldSchema, type ElicitAction, type ElicitContent, type ElicitFormSchema, type ElicitOptions, type ElicitResponse, type Elicitor, type EnumFieldSchema, type FieldSchema, type NumberFieldSchema, type TextFieldSchema, buildElicitRequest, buildFormSchema, field, normalizeResponse };