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

234 lines 8.92 kB
/** * BC Page Schema Resource * * Provides a list of available Business Central pages with IDs, types, and capabilities. * This helps AI assistants discover and understand BC pages. * * NOTE: This version uses a static list of common BC pages. * Future versions could query BC metadata dynamically. */ import { ok, err } from '../core/result.js'; import { InternalError } from '../core/errors.js'; /** * BCSchemaPagesResource provides metadata about available BC pages. */ export class BCSchemaPagesResource { logger; uri = 'bc://schema/pages'; name = 'Business Central Page Schema'; description = 'List of available BC pages with IDs, types, and capabilities.'; mimeType = 'application/json'; constructor(logger) { this.logger = logger; } /** * Reads the BC page schema. * @returns JSON array of BC pages */ async read() { try { this.logger?.debug('Reading BC page schema'); const pages = [ // Customer pages { pageId: '21', name: 'Customer Card', type: 'Card', description: 'Customer master data including contact and posting details.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Sales', }, { pageId: '22', name: 'Customer List', type: 'List', description: 'List of all customers.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Sales', }, // Item pages { pageId: '30', name: 'Item Card', type: 'Card', description: 'Item master data including inventory and costing details.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Inventory', }, { pageId: '31', name: 'Item List', type: 'List', description: 'List of all items.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Inventory', }, // Vendor pages { pageId: '26', name: 'Vendor Card', type: 'Card', description: 'Vendor master data including contact and posting details.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Purchasing', }, { pageId: '27', name: 'Vendor List', type: 'List', description: 'List of all vendors.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Purchasing', }, // Sales documents { pageId: '42', name: 'Sales Order', type: 'Document', description: 'Sales order document with header and lines.', primaryKeyFields: ['Document Type', 'No.'], supportsCreate: true, supportsDelete: true, category: 'Sales', }, { pageId: '43', name: 'Sales Invoice', type: 'Document', description: 'Sales invoice document with header and lines.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Sales', }, { pageId: '9305', name: 'Sales Order List', type: 'List', description: 'List of sales orders.', primaryKeyFields: ['Document Type', 'No.'], supportsCreate: true, supportsDelete: true, category: 'Sales', }, // Purchase documents { pageId: '50', name: 'Purchase Order', type: 'Document', description: 'Purchase order document with header and lines.', primaryKeyFields: ['Document Type', 'No.'], supportsCreate: true, supportsDelete: true, category: 'Purchasing', }, { pageId: '51', name: 'Purchase Invoice', type: 'Document', description: 'Purchase invoice document with header and lines.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Purchasing', }, // General Ledger { pageId: '17', name: 'G/L Account Card', type: 'Card', description: 'General ledger account master data.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Financial Management', }, { pageId: '18', name: 'G/L Account List', type: 'List', description: 'List of general ledger accounts.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Financial Management', }, // Contact pages { pageId: '5050', name: 'Contact Card', type: 'Card', description: 'Contact master data for CRM.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Relationship Management', }, { pageId: '5052', name: 'Contact List', type: 'List', description: 'List of all contacts.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Relationship Management', }, // Resource pages { pageId: '76', name: 'Resource Card', type: 'Card', description: 'Resource master data for capacity and job planning.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Jobs', }, { pageId: '77', name: 'Resource List', type: 'List', description: 'List of all resources.', primaryKeyFields: ['No.'], supportsCreate: true, supportsDelete: true, category: 'Jobs', }, ]; const result = { timestamp: new Date().toISOString(), version: '1.0', pageCount: pages.length, pages, }; const json = JSON.stringify(result, null, 2); this.logger?.debug('Returning BC page schema', { pageCount: pages.length, }); return ok(json); } catch (error) { this.logger?.error('Failed to read BCSchemaPagesResource', { error: String(error), }); return err(new InternalError('Failed to read BC schema pages resource', { code: 'READ_SCHEMA_PAGES_FAILED', error: String(error), })); } } } //# sourceMappingURL=schema-pages-resource.js.map