feat(mcp-server): add triggerWorkflow tool (PRD-738) - #1777
Conversation
1 new issue
|
There was a problem hiding this comment.
🟡 Medium src/forest-admin-client-with-cache.ts:36
Adding workflowsService in the middle of the ForestAdminClientWithCache constructor's positional argument list breaks existing JavaScript consumers that instantiate this class directly. Existing calls using the previous argument order still run, but each argument after the insertion point shifts by one: authService receives the model-customization service, and eventsHandler becomes undefined, causing runtime failures. Consider appending the new dependency at the end of the parameter list instead of inserting it in the middle.
public readonly activityLogsService: ActivityLogsService,
- public readonly workflowsService: WorkflowsService,
public readonly authService: ForestAdminAuthServiceInterface,
public readonly modelCustomizationService: ModelCustomizationService,
public readonly mcpServerConfigService: McpServerConfigService,
protected readonly eventsSubscription: BaseEventsSubscriptionService,
protected readonly eventsHandler: RefreshEventsHandlerService,
+ public readonly workflowsService: WorkflowsService,
) {}🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/forestadmin-client/src/forest-admin-client-with-cache.ts around lines 36-42:
Adding `workflowsService` in the middle of the `ForestAdminClientWithCache` constructor's positional argument list breaks existing JavaScript consumers that instantiate this class directly. Existing calls using the previous argument order still run, but each argument after the insertion point shifts by one: `authService` receives the model-customization service, and `eventsHandler` becomes `undefined`, causing runtime failures. Consider appending the new dependency at the end of the parameter list instead of inserting it in the middle.
|
Coverage Impact Unable to calculate total coverage change because base branch coverage was not found. Modified Files with Diff Coverage (6)
🛟 Help
|
Expose the triggerWorkflow MCP tool so an LLM can start a run on a
specific record and get a runId back. Non-blocking by design: the run
continues server-side and status is observed via getWorkflowRun (MS8).
- tool args { workflowId, recordId }; identity from the OAuth auth
context (forestServerToken + renderingId), wrapped in withActivityLog
so MCP-triggered runs are audited locally under the caller.
- forestadmin-client: WorkflowsService.triggerMcpWorkflow calls the
MCP-dedicated start endpoint over HTTP
(POST /api/workflow-orchestrator/workflows/:workflowId/start), no
private-api internals imported.
- collectionId is derived server-side from the workflow (MS5), so the
tool contract stays { workflowId, recordId } — consistent with the
webhook trigger.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
259931d to
165c96f
Compare
…ore trigger (PRD-738) - Point listMcpEnabledWorkflows and triggerMcpWorkflow at the /api/workflow-orchestrator/mcp-workflows route (aligned with the MS5 server contract). - triggerWorkflow pre-checks the workflow via listMcpWorkflows so an unknown or non-MCP-enabled id fails with an actionable error, and the activity-log entry carries the workflow name and collection instead of the raw id. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ument trigger audit (PRD-738) - WorkflowsService throws an explicit error when the transport does not implement triggerMcpWorkflow / listMcpEnabledWorkflows instead of a cryptic runtime TypeError - document why a pre-trigger rejection is not audited (no resource to attach, server drops resource-less MCP activity logs) and reference PRD-831 for the by-id lookup optimization Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Mock (PRD-738) triggerMcpWorkflow became a required member of WorkflowsServiceInterface; the test mock only implemented listMcpEnabledWorkflows, breaking the build (TS2741). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…y (PRD-738) Same required-interface break as the agent-testing mock: the agent test factory's workflowsService only implemented listMcpEnabledWorkflows, failing every suite that imports it (TS2741). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…bs (PRD-738) The triggerMcpWorkflow mock stub was the only uncovered diff line, dropping qlty diff coverage below the 98% threshold. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ad7777a
into
feature/prd-49-expose-workflow-tools-in-forest-mcp-server

MS6 —
triggerWorkflowMCP toolExposes the
triggerWorkflowtool so an LLM can start a run on a specific record and get arunIdback. Non-blocking by design — the run continues server-side and status is observed viagetWorkflowRun(MS8).fixes PRD-738
What's in it
packages/mcp-server/src/tools/trigger-workflow.ts: args{ workflowId, recordId }, identity from the OAuth auth context (forestServerToken+renderingId), wrapped inwithActivityLog(actiontriggerWorkflow) so MCP-triggered runs get a local MCP audit entry under the caller.WorkflowsService.triggerMcpWorkflow+ForestHttpApicall the MS5 endpoint over HTTP (POST /api/workflow-orchestrator/mcp-workflows/:workflowId/start, body{ recordId },forest-rendering-idheader). No private-api internals imported.isError: true) with the server's message passed through — 404 (not MCP-enabled / unknown workflow), 409 (run already ongoing, no resume), 403 (unauthorized). No status-specific remapping is done client-side.recordIdnot validated at trigger time.collectionIdis derived server-side (MS5, aligned on the webhook), so the tool contract stays{ workflowId, recordId }.Tests
mcp-server 631/631, forestadmin-client 292/292, lint clean.
Stacking & dependencies
listWorkflows) — this branch was cut from PRD-736 since itsWorkflowsService/http-client plumbing isn't in the integration branch yet. Until feat(mcp-server): add listWorkflows tool (PRD-736) #1771 merges intofeature/prd-49-…, this PR's diff also shows the MS4 commit; it narrows to MS6-only afterwards. Review/merge feat(mcp-server): add listWorkflows tool (PRD-736) #1771 first.forestadmin-server; needed for end-to-end. Unit tests here are mocked against the HTTP contract.🤖 Generated with Claude Code
Note
Add
triggerWorkflowtool to the MCP servertriggerWorkflowMCP tool in server.ts that lets agents trigger Forest Admin workflow runs, implemented in trigger-workflow.ts.workflowIdagainst the list of MCP-enabled workflows, then POSTs to/api/workflow-orchestrator/mcp-workflows/{workflowId}/startvia a newtriggerMcpWorkflowmethod onWorkflowsService.writeoperations.listMcpEnabledWorkflowsis updated from/workflowsto/mcp-workflows.WorkflowsService.listMcpEnabledWorkflowsnow throws if the configured transport does not implement the method, instead of calling undefined.Macroscope summarized 5b0499c.