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 (13) 🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 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

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/workflows/:workflowId/start, body{ recordId },forest-rendering-idheader). No private-api internals imported.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 intrigger-workflow.tsthat starts a workflow asynchronously on a given record and returns therunIdandrunStateas JSON.workflowIdandrecordId(zod-validated), authenticates viagetAuthContext, and delegates toForestServerClientImpl.triggerWorkflow→WorkflowsService.triggerMcpWorkflow→ a POST to/api/workflow-orchestrator/workflows/{workflowId}/start.writeoperations.Macroscope summarized 165c96f.