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

119 lines 4.26 kB
/** * Handle Dialog MCP Tool * * Interacts with Business Central dialog windows (prompts, confirmations, template selection). * Detects dialogs via DialogToShow events, optionally selects rows, and clicks buttons. * * Protocol (based on captured customer template selection workflow): * 1. Wait for DialogToShow event or assume dialog already open * 2. Optionally select row using SetCurrentRowAndRowsSelection * 3. Click button (OK/Cancel) using InvokeAction with systemAction * 4. Return result * * See DIALOG_HANDLING_DESIGN.md for implementation details. */ import { BaseMCPTool } from './base-tool.js'; import type { Result } from '../core/result.js'; import type { BCError } from '../core/errors.js'; import type { IBCConnection } from '../core/interfaces.js'; import type { HandleDialogInput, HandleDialogOutput } from '../types/mcp-types.js'; import type { AuditLogger } from '../services/audit-logger.js'; /** * MCP Tool: handle_dialog * * Handles BC dialog interactions including row selection and button clicks. */ export declare class HandleDialogTool extends BaseMCPTool { private readonly connection; private readonly bcConfig?; readonly name = "handle_dialog"; readonly description: string; readonly inputSchema: { type: string; properties: { pageContextId: { type: string; description: string; }; action: { type: string; description: string; enum: string[]; default: string; }; selection: { type: string; description: string; properties: { bookmark: { type: string; description: string; }; rowNumber: { type: string; description: string; }; rowFilter: { type: string; description: string; additionalProperties: boolean; }; }; }; wait: { type: string; description: string; enum: string[]; default: string; }; timeoutMs: { type: string; description: string; default: number; }; workflowId: { type: string; description: string; }; }; required: string[]; }; readonly requiresConsent = true; readonly sensitivityLevel: "medium"; readonly consentPrompt = "Interact with a Business Central dialog window? This may select options or confirm operations."; constructor(connection: IBCConnection, bcConfig?: { baseUrl: string; username: string; password: string; tenantId: string; } | undefined, auditLogger?: AuditLogger); /** * Validates and extracts input. */ protected validateInput(input: unknown): Result<HandleDialogInput, BCError>; /** * Executes the tool to handle a dialog. */ protected executeInternal(input: unknown): Promise<Result<HandleDialogOutput, BCError>>; /** Get session context from pageContextId */ private getSessionContext; /** Get or wait for dialog depending on wait mode */ private getOrWaitForDialog; /** Wait for a new dialog to appear */ private waitForDialogToAppear; /** Create predicate for DialogToShow detection */ private createDialogPredicate; /** Get existing dialog from SessionStateManager */ private getExistingDialog; /** Handle row selection if provided */ private handleRowSelection; /** Resolve selection to a bookmark */ private resolveSelectionBookmark; /** Click OK or Cancel button on dialog */ private clickDialogButton; /** Close dialog state in SessionStateManager (non-fatal) */ private closeDialogState; /** Record operation in workflow */ private recordWorkflowOperation; } //# sourceMappingURL=handle-dialog-tool.d.ts.map