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

41 lines 1.29 kB
/** * Utility functions for pageContextId handling * * PageContextId format: "sessionId:page:pageId:timestamp" */ /** * Parse a pageContextId into its component parts */ export function parsePageContextId(pageContextId) { // format: "sessionId:page:pageId:timestamp" const [sessionId, pageTag, pageId, timestamp] = pageContextId.split(':'); if (!sessionId || pageTag !== 'page' || !pageId) { throw new Error(`Invalid pageContextId format: ${pageContextId}`); } return { sessionId, pageId, timestamp }; } /** * Build a pageContextId from components */ export function buildPageContextId(sessionId, pageId, timestamp = Date.now()) { return `${sessionId}:page:${String(pageId)}:${timestamp}`; } /** * Ensure we have the necessary page identifiers, extracting from pageContextId if needed */ export function ensurePageIdentifiers(args) { if (args.pageContextId) { const parts = parsePageContextId(args.pageContextId); return { pageContextId: args.pageContextId, pageId: parts.pageId, sessionId: parts.sessionId }; } return { pageContextId: undefined, pageId: args.pageId?.toString(), sessionId: args.sessionId, }; } //# sourceMappingURL=pageContext.js.map