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

98 lines 3.42 kB
/** * Execute Action Tool * * Executes an action (button click) on a Business Central page. * Uses the InvokeAction interaction to trigger actions like Edit, New, Delete, etc. * * Based on BC_INTERACTION_CAPTURE_PLAN.md - InvokeAction protocol. */ import type { Result } from '../core/result.js'; import type { BCError } from '../core/errors.js'; import type { IBCConnection } from '../core/interfaces.js'; import { BaseMCPTool } from './base-tool.js'; import type { AuditLogger } from '../services/audit-logger.js'; /** * Output from execute_action tool. */ export interface ExecuteActionOutput { readonly success: boolean; readonly actionName: string; readonly pageId: string; readonly formId: string; readonly message: string; readonly handlers?: readonly unknown[]; } /** * MCP Tool for executing actions on BC pages. * Implements the InvokeAction interaction protocol. */ export declare class ExecuteActionTool extends BaseMCPTool { private readonly connection; private readonly bcConfig?; readonly name = "execute_action"; readonly description: string; readonly inputSchema: { type: string; properties: { pageContextId: { type: string; description: string; }; actionName: { type: string; description: string; }; controlPath: { type: string; description: string; }; systemAction: { type: string; description: string; }; workflowId: { type: string; description: string; }; }; required: string[]; }; readonly requiresConsent = true; readonly sensitivityLevel: "high"; readonly consentPrompt = "Execute an action in Business Central? WARNING: Some actions like Post or Delete may be irreversible and cannot be undone."; constructor(connection: IBCConnection, bcConfig?: { baseUrl: string; username: string; password: string; tenantId: string; } | undefined, auditLogger?: AuditLogger); /** * Executes the action on the BC page. * Input is pre-validated by BaseMCPTool using Zod schema. */ protected executeInternal(input: unknown): Promise<Result<ExecuteActionOutput, BCError>>; /** Parse pageContextId and extract session/page info */ private parsePageContextId; /** Validate session exists and get connection + pageContext */ private validateSession; /** Build InvokeAction interaction object */ private buildInvokeActionInteraction; /** Accumulate async handlers from BC response */ private accumulateAsyncHandlers; /** Auto-track dialogs from handlers */ private autoTrackDialogs; /** Check for error handlers in response */ private checkForErrors; /** Mark pageContext as stale and clear cache */ private markPageContextStale; /** Record operation in workflow */ private recordWorkflowOperation; /** * Look up action from cached page metadata. * Searches for action by name (DesignName) or caption. * Returns controlPath and systemAction if found. */ private lookupActionFromCache; private searchActionsInLogicalForm; } //# sourceMappingURL=execute-action-tool.d.ts.map