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

108 lines 4.04 kB
/** * Search Pages MCP Tool * * Searches for BC pages using the Tell Me search protocol. * Connects to BC WebSocket, sends search query, and parses results. * * Protocol: * 1. Open Tell Me dialog: InvokeSessionAction(systemAction: 220) * 2. Submit query: SaveValue with search text * 3. Parse results: Extract from LogicalForm repeater control * * See docs/tell-me-search-protocol.md for full protocol documentation. */ import { BaseMCPTool } from './base-tool.js'; import type { Result } from '../core/result.js'; import type { BCError } from '../core/errors.js'; import type { SearchPagesOutput } from '../types/mcp-types.js'; import type { BCConnectionPool } from '../services/connection-pool.js'; import type { CacheManager } from '../services/cache-manager.js'; /** * MCP Tool: search_pages * * Searches for BC pages by name, caption, or type. * * NOTE: Unlike other tools, this creates its own BCRawWebSocketClient per invocation * because it requires low-level Tell Me protocol access not available through BCPageConnection. * Each search creates a new session, performs the search, and closes. */ export declare class SearchPagesTool extends BaseMCPTool { private readonly config?; private readonly connectionPool?; private readonly cache?; readonly name = "search_pages"; readonly description: string; /** * Constructor. * SearchPagesTool can optionally use a connection pool and cache for improved performance. * If no pool is provided, falls back to creating a new connection per search. * If no cache is provided, skips caching (direct execution). */ constructor(config?: { readonly baseUrl?: string; readonly username?: string; readonly password?: string; readonly tenantId?: string; } | undefined, connectionPool?: BCConnectionPool | undefined, cache?: CacheManager | undefined); readonly inputSchema: { type: string; properties: { query: { type: string; description: string; }; limit: { type: string; description: string; minimum: number; maximum: number; }; type: { type: string; description: string; enum: string[]; }; workflowId: { type: string; description: string; }; }; required: string[]; }; readonly requiresConsent = false; readonly sensitivityLevel: "low"; /** * Executes the tool to search for pages using BC Tell Me protocol. * Input is pre-validated by BaseMCPTool using Zod schema. * * Uses the BC27+ Tell Me search via LogicalClientChangeHandler format. * Requires BC credentials from environment or config. */ protected executeInternal(input: unknown): Promise<Result<SearchPagesOutput, BCError>>; /** * Perform the actual Tell Me search (called by executeInternal) * @private */ private performSearch; /** Get BC credentials from config or defaults */ private getCredentials; /** Initialize connection from pool or create new */ private initializeConnection; /** Create predicate for Tell Me dialog detection */ private createTellMeDialogPredicate; /** Open Tell Me dialog and return form ID */ private openTellMeDialog; /** Initialize search field with empty value */ private initializeSearchField; /** Create predicate for search results detection */ private createSearchResultsPredicate; /** Submit search query and wait for results */ private submitSearchQuery; /** Filter by type and apply limit */ private filterAndLimitResults; /** Cleanup connection (release to pool or disconnect) */ private cleanupConnection; /** Record operation in workflow */ private recordWorkflowOperation; } //# sourceMappingURL=search-pages-tool.d.ts.map