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
108 lines • 4.02 kB
TypeScript
/**
* Select and Drill Down Tool
*
* Selects a specific row in a BC list page and drills down to the detail page.
* Implements the SetCurrentRowAndRowsSelection + InvokeAction protocol discovered
* from WebSocket capture analysis.
*
* Based on BC_PROTOCOL_PATTERNS.md - Pattern 5: Row Selection and Drill-Down
*/
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';
import { PageMetadataParser } from '../parsers/page-metadata-parser.js';
/**
* Output from select_and_drill_down tool.
*/
export interface SelectAndDrillDownOutput {
readonly success: boolean;
readonly sourcePageContextId: string;
readonly targetPageContextId: string;
readonly sourcePageId: string;
readonly targetPageId: string;
readonly bookmark: string;
readonly action: string;
readonly message: string;
}
/**
* MCP Tool for selecting a row and drilling down to detail page.
* Implements the SetCurrentRowAndRowsSelection + InvokeAction protocol.
*/
export declare class SelectAndDrillDownTool extends BaseMCPTool {
private readonly connection;
private readonly bcConfig?;
private readonly metadataParser;
readonly name = "select_and_drill_down";
readonly description: string;
readonly inputSchema: {
type: string;
properties: {
pageContextId: {
type: string;
description: string;
};
bookmark: {
type: string;
description: string;
};
action: {
type: string;
enum: string[];
description: string;
default: string;
};
};
required: string[];
};
readonly requiresConsent = true;
readonly sensitivityLevel: "medium";
readonly consentPrompt = "Select a row and drill down to detail page in Business Central? This will navigate to a new page and may load sensitive data.";
constructor(connection: IBCConnection, bcConfig?: {
baseUrl: string;
username: string;
password: string;
tenantId: string;
} | undefined, auditLogger?: AuditLogger, metadataParser?: PageMetadataParser);
/**
* Executes the select and drill-down operation.
* Input is pre-validated by BaseMCPTool using Zod schema.
*/
protected executeInternal(input: unknown): Promise<Result<SelectAndDrillDownOutput, BCError>>;
/** Parse pageContextId and extract session/page info */
private parsePageContextId;
/** Validate session exists and get connection + pageContext */
private validateSession;
/** Create predicate for FormToShow events */
private createFormToShowPredicate;
/** Create predicate for record data events */
private createRecordDataPredicate;
/** Send SetCurrentRowAndRowsSelection interaction */
private sendRowSelection;
/** Find the action control path from metadata */
private findActionControlPath;
/** Send InvokeAction interaction */
private sendInvokeAction;
/** Wait for navigation FormToShow event */
private waitForNavigation;
/** Load child forms and collect async data */
private loadChildFormsAndData;
/** Create and store target page context */
private createTargetPageContext;
/**
* Finds the repeater control path in a LogicalForm.
* Returns the control path for the main list repeater.
*/
private findRepeaterControlPath;
/**
* Infers page type from handlers.
* Uses ViewMode/FormStyle if available, falls back to caption heuristics.
*/
private inferPageType;
/**
* Extracts the LogicalForm from handlers for caching.
*/
private extractLogicalFormFromHandlers;
}
//# sourceMappingURL=select-and-drill-down-tool.d.ts.map