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

58 lines 2.14 kB
/** * All Workflows Resource * * Provides introspection into all active and completed workflows. * This resource helps AI assistants discover workflows and understand workflow state. * * For accessing a specific workflow by ID, use the get_workflow_state tool instead. */ import { ok, err } from '../core/result.js'; import { InternalError } from '../core/errors.js'; import { WorkflowStateManager } from '../services/workflow-state-manager.js'; /** * BCWorkflowAllResource exposes all workflows in the system. */ export class BCWorkflowAllResource { logger; uri = 'bc://workflow/all'; name = 'All BC Workflows'; description = 'All active and completed workflows with their current state, operations, and errors.'; mimeType = 'application/json'; constructor(logger) { this.logger = logger; } /** * Reads all workflows. * @returns JSON snapshot of all workflows */ async read() { try { this.logger?.debug('Reading all BC workflows'); const manager = WorkflowStateManager.getInstance(this.logger); const snapshot = manager.getSnapshot(); // Add metadata const result = { timestamp: new Date().toISOString(), workflowCount: manager.getWorkflowCount(), activeWorkflows: manager.getActiveWorkflows().length, workflows: snapshot.workflows, }; const json = JSON.stringify(result, null, 2); this.logger?.debug('Returning all BC workflows', { workflowCount: result.workflowCount, activeWorkflows: result.activeWorkflows, }); return ok(json); } catch (error) { this.logger?.error('Failed to read BCWorkflowAllResource', { error: String(error), }); return err(new InternalError('Failed to read all workflows resource', { code: 'READ_WORKFLOWS_FAILED', error: String(error), })); } } } //# sourceMappingURL=workflow-all-resource.js.map