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

117 lines 3.83 kB
/** * Get Page Metadata MCP Tool * * Opens a BC page and extracts complete metadata: * - Available fields with types * - Available actions with enabled states * - Page structure and capabilities * * This tool gives Claude "vision" into BC pages. */ import { BaseMCPTool } from './base-tool.js'; import type { Result } from '../core/result.js'; import type { BCError } from '../core/errors.js'; import type { IBCConnection, IPageMetadataParser } from '../core/interfaces.js'; import type { GetPageMetadataOutput } from '../types/mcp-types.js'; /** * MCP Tool: get_page_metadata * * Retrieves comprehensive metadata about a BC page including * all fields, actions, and their current states. */ export declare class GetPageMetadataTool extends BaseMCPTool { private readonly connection; private readonly bcConfig?; private readonly metadataParser; readonly name = "get_page_metadata"; readonly description: string; readonly inputSchema: { type: string; properties: { pageId: { type: string[]; description: string; }; pageContextId: { type: string; description: string; }; bookmark: { type: string; description: string; }; filters: { type: string; description: string; additionalProperties: { type: string[]; }; }; workflowId: { type: string; description: string; }; }; }; readonly requiresConsent = false; readonly sensitivityLevel: "low"; constructor(connection: IBCConnection, bcConfig?: { baseUrl: string; username: string; password: string; tenantId: string; } | undefined, metadataParser?: IPageMetadataParser); /** * Executes the tool to get page metadata. * Input is pre-validated by BaseMCPTool using Zod schema. */ protected executeInternal(input: unknown): Promise<Result<GetPageMetadataOutput, BCError>>; /** * Generates a natural language description of the page. */ private generateDescription; /** * Converts BC control type to user-friendly field type. */ private controlTypeToFieldType; /** * Extracts formId from CallbackResponseProperties in handlers. * Used to close forms after extracting metadata. */ private extractFormIdFromHandlers; /** * Infers page type from BC metadata. * * Uses ViewMode and FormStyle from LogicalForm (most accurate). * Falls back to caption heuristics if metadata unavailable. * * ViewMode values: * - 1 = List/Worksheet (multiple records) * - 2 = Card/Document (single record) * * FormStyle values (when ViewMode=2): * - 1 = Document * - undefined/absent = Card */ private inferPageType; /** * Extracts LogicalForm from handlers (finds FormToShow handler). */ private extractLogicalFormFromHandlers; /** * Extract ALL LogicalForms from handlers (main form + child forms). * * Each LogicalForm comes from a FormToShow event. * Returns array of {formId, logicalForm} for repeater extraction. */ private extractAllLogicalForms; /** * Extract column metadata from handlers and enrich cached repeaters. * Called after LoadForm responses to progressively discover column data. * * @param pageContextId - The page context to enrich * @param handlers - Handlers from BC response (may contain RCC messages) */ private enrichColumnsFromHandlers; } //# sourceMappingURL=get-page-metadata-tool.d.ts.map