UNPKG

bc-webclient-mcp

Version:

Model Context Protocol (MCP) server for Microsoft Dynamics 365 Business Central via WebUI protocol. Enables AI assistants to interact with BC through the web client protocol, supporting Card, List, and Document pages with full line item support and server

265 lines 11.2 kB
/** * Validation Schemas * * Zod schemas for MCP tool input validation with type coercion. * * IMPORTANT: MCP can deliver parameters as both typed values AND strings. * For example, pageId can be either "21" (string) or 21 (number). * These schemas use z.union() + transform() or z.coerce to handle both. */ import { z } from 'zod'; /** * Schema for pageId that accepts string or number. * Normalizes to trimmed string representation. * * Examples: * - "21" → "21" * - 21 → "21" * - " 42 " → "42" */ export declare const PageIdSchema: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>; /** * Schema for numeric ID that accepts string or number. * Coerces to number and validates range. * * Examples: * - "21" → 21 * - 21 → 21 * - " 42 " → 42 */ export declare const NumericIdSchema: z.ZodNumber; /** * Schema for optional limit parameter. * Accepts string or number, coerces to number. */ export declare const LimitSchema: z.ZodOptional<z.ZodNumber>; /** * Schema for optional timeout parameter (milliseconds). * Accepts string or number, coerces to number. */ export declare const TimeoutSchema: z.ZodOptional<z.ZodNumber>; /** * Schema for boolean that accepts string, boolean, or number. * Coerces "true", "1", 1, true → true * Coerces "false", "0", 0, false → false */ export declare const BooleanSchema: z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">, z.ZodEffects<z.ZodNumber, boolean, number>]>; /** * Schema for pageContextId (opaque string). * Format: "connectionId:page:pageId:formId" */ export declare const PageContextIdSchema: z.ZodEffects<z.ZodString, string, string>; /** * Schema for field name (string, non-empty). */ export declare const FieldNameSchema: z.ZodString; /** * Schema for action name (string, non-empty). */ export declare const ActionNameSchema: z.ZodString; /** * Schema for page type (enum). */ export declare const PageTypeSchema: z.ZodEnum<["Card", "List", "Document", "Worksheet", "Report"]>; /** * Schema for field value (can be any JSON-compatible type). */ export declare const FieldValueSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>; /** * Schema for field updates map. * Keys are field names, values are field values. */ export declare const FieldUpdatesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>; /** * Schema for search_pages tool input. */ export declare const SearchPagesInputSchema: z.ZodObject<{ query: z.ZodString; limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; type: z.ZodOptional<z.ZodEnum<["Card", "List", "Document", "Worksheet", "Report"]>>; }, "strip", z.ZodTypeAny, { query: string; limit: number; type?: "Card" | "List" | "Document" | "Worksheet" | "Report" | undefined; }, { query: string; type?: "Card" | "List" | "Document" | "Worksheet" | "Report" | undefined; limit?: number | undefined; }>; export type SearchPagesInput = z.infer<typeof SearchPagesInputSchema>; /** * Schema for get_page_metadata tool input. * Accepts either pageId OR pageContextId (or both). */ export declare const GetPageMetadataInputSchema: z.ZodEffects<z.ZodObject<{ pageId: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>>; pageContextId: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>; }, "strip", z.ZodTypeAny, { pageContextId?: string | undefined; pageId?: string | undefined; }, { pageContextId?: string | undefined; pageId?: string | number | undefined; }>, { pageContextId?: string | undefined; pageId?: string | undefined; }, { pageContextId?: string | undefined; pageId?: string | number | undefined; }>; export type GetPageMetadataInput = z.infer<typeof GetPageMetadataInputSchema>; /** * Schema for read_page_data tool input. */ export declare const ReadPageDataInputSchema: z.ZodObject<{ pageContextId: z.ZodEffects<z.ZodString, string, string>; filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; setCurrent: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">, z.ZodEffects<z.ZodNumber, boolean, number>]>>>; limit: z.ZodOptional<z.ZodOptional<z.ZodNumber>>; offset: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { pageContextId: string; setCurrent: boolean; limit?: number | undefined; filters?: Record<string, unknown> | undefined; offset?: number | undefined; }, { pageContextId: string; limit?: number | undefined; filters?: Record<string, unknown> | undefined; setCurrent?: number | boolean | "true" | "false" | undefined; offset?: number | undefined; }>; export type ReadPageDataInput = z.infer<typeof ReadPageDataInputSchema>; /** * Schema for write_page_data tool input. */ export declare const WritePageDataInputSchema: z.ZodObject<{ pageContextId: z.ZodEffects<z.ZodString, string, string>; fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>; stopOnError: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">, z.ZodEffects<z.ZodNumber, boolean, number>]>>>; immediateValidation: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">, z.ZodEffects<z.ZodNumber, boolean, number>]>>>; subpage: z.ZodOptional<z.ZodString>; lineBookmark: z.ZodOptional<z.ZodString>; lineNo: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { pageContextId: string; fields: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null>; stopOnError: boolean; immediateValidation: boolean; subpage?: string | undefined; lineBookmark?: string | undefined; lineNo?: number | undefined; }, { pageContextId: string; fields: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null>; stopOnError?: number | boolean | "true" | "false" | undefined; immediateValidation?: number | boolean | "true" | "false" | undefined; subpage?: string | undefined; lineBookmark?: string | undefined; lineNo?: number | undefined; }>; export type WritePageDataInput = z.infer<typeof WritePageDataInputSchema>; /** * Schema for execute_action tool input. */ export declare const ExecuteActionInputSchema: z.ZodObject<{ pageContextId: z.ZodEffects<z.ZodString, string, string>; actionName: z.ZodString; controlPath: z.ZodOptional<z.ZodString>; systemAction: z.ZodOptional<z.ZodNumber>; key: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { pageContextId: string; actionName: string; controlPath?: string | undefined; systemAction?: number | undefined; key?: string | undefined; }, { pageContextId: string; actionName: string; controlPath?: string | undefined; systemAction?: number | undefined; key?: string | undefined; }>; export type ExecuteActionInput = z.infer<typeof ExecuteActionInputSchema>; /** * Schema for update_field tool input. */ export declare const UpdateFieldInputSchema: z.ZodObject<{ pageContextId: z.ZodEffects<z.ZodString, string, string>; fieldName: z.ZodString; value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>; }, "strip", z.ZodTypeAny, { pageContextId: string; fieldName: string; value: string | number | boolean | unknown[] | Record<string, unknown> | null; }, { pageContextId: string; fieldName: string; value: string | number | boolean | unknown[] | Record<string, unknown> | null; }>; export type UpdateFieldInput = z.infer<typeof UpdateFieldInputSchema>; /** * Schema for filter_list tool input. */ export declare const FilterListInputSchema: z.ZodObject<{ pageContextId: z.ZodEffects<z.ZodString, string, string>; filters: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>; }, "strip", z.ZodTypeAny, { pageContextId: string; filters: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null>; }, { pageContextId: string; filters: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null>; }>; export type FilterListInput = z.infer<typeof FilterListInputSchema>; /** * Schema for handle_dialog tool input. */ export declare const HandleDialogInputSchema: z.ZodObject<{ pageContextId: z.ZodEffects<z.ZodString, string, string>; fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>; action: z.ZodString; }, "strip", z.ZodTypeAny, { pageContextId: string; action: string; fields?: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null> | undefined; }, { pageContextId: string; action: string; fields?: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null> | undefined; }>; export type HandleDialogInput = z.infer<typeof HandleDialogInputSchema>; /** * Schema for convenience tools that work with records. */ export declare const RecordToolInputSchema: z.ZodObject<{ pageId: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string, string | number>, string, string | number>; fields: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>; }, "strip", z.ZodTypeAny, { pageId: string; fields: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null>; }, { pageId: string | number; fields: Record<string, string | number | boolean | unknown[] | Record<string, unknown> | null>; }>; export type RecordToolInput = z.infer<typeof RecordToolInputSchema>; /** * Schema for select_and_drill_down tool input. */ export declare const SelectAndDrillDownInputSchema: z.ZodObject<{ pageContextId: z.ZodEffects<z.ZodString, string, string>; bookmark: z.ZodString; action: z.ZodDefault<z.ZodOptional<z.ZodEnum<["Edit", "View"]>>>; }, "strip", z.ZodTypeAny, { pageContextId: string; action: "View" | "Edit"; bookmark: string; }, { pageContextId: string; bookmark: string; action?: "View" | "Edit" | undefined; }>; export type SelectAndDrillDownInput = z.infer<typeof SelectAndDrillDownInputSchema>; //# sourceMappingURL=schemas.d.ts.map