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

84 lines 2.79 kB
/** * Column Enrichment Service * * Clean abstraction for progressive column metadata enrichment. * Tools call this service after receiving BC responses that may contain column metadata. * * Architecture: * - Protocol layer: Parses BC messages, detects RCC structures * - This service: Bridges protocol detection → PageContext caching * - Tools: Know pageContextId, call this service * * Future: Can be refactored to subscribe to protocol-level events without changing tools. * * @see COLUMN_METADATA_DISCOVERY.md for background * @see COLUMN_ENRICHMENT_IMPLEMENTATION.md for implementation strategy */ /** * Enrichment result for observability */ export interface EnrichmentResult { enriched: boolean; repeaterCount: number; totalColumns: number; repeaters: Array<{ formId: string; caption: string; columnCount: number; }>; } /** * Column Enrichment Service * * Provides a clean, testable abstraction for enriching page contexts with column metadata. * * Usage in tools: * ```typescript * const service = ColumnEnrichmentService.getInstance(); * const result = await service.enrichFromResponse(pageContextId, response); * if (result.enriched) { * logger.info(`Enriched ${result.repeaterCount} repeaters with columns`); * } * ``` */ export declare class ColumnEnrichmentService { private static instance; private readonly cache; private constructor(); /** * Get singleton instance */ static getInstance(): ColumnEnrichmentService; /** * Enrich page context with columns discovered in a BC response. * * This method: * 1. Extracts RCC (Repeater Column Control) messages from response * 2. Updates PageContext cache with discovered columns * 3. Returns enrichment results for observability * * Safe to call on every response - no-op if no columns found. * * @param pageContextId - Page context to enrich * @param response - BC WebSocket response (from invoke/LoadForm/etc.) * @returns Enrichment result * * @example * ```typescript * const response = await connection.invoke('LoadForm', params); * const result = await service.enrichFromResponse(pageContextId, response); * // result.enriched === true if columns were discovered * ``` */ enrichFromResponse(pageContextId: string, response: unknown): Promise<EnrichmentResult>; /** * Check if a response contains column metadata (without enriching). * * Useful for testing or conditional logic. * * @param response - BC WebSocket response * @returns true if response contains RCC messages */ hasColumns(response: unknown): boolean; } //# sourceMappingURL=column-enrichment-service.d.ts.map