feat(mcp-server): expose workflow tools in Forest MCP server (PRD-49) - #1792
Open
christophebrun-forest wants to merge 4 commits into
Open
feat(mcp-server): expose workflow tools in Forest MCP server (PRD-49)#1792christophebrun-forest wants to merge 4 commits into
christophebrun-forest wants to merge 4 commits into
Conversation
Expose MCP-enabled workflows to LLM clients via a new listWorkflows tool, calling the Forest server MS3 endpoint (GET /api/workflow-orchestrator/workflows) over the HTTP contract with the caller's forestServerToken + renderingId. - forestadmin-client: WorkflowsService + ForestHttpApi.listMcpEnabledWorkflows - mcp-server: listWorkflows tool, http-client wiring, shared getAuthContext util Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* feat(mcp-server): add triggerWorkflow tool (PRD-738)
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>
…32) (#1786) MCP-triggered runs carry triggerType='mcp', but the executor only recognized manual|webhook, so AvailableStepExecutionSchema.parse rejected every MCP run at step 0 with a DomainValidationError before executing. triggerType is informational only (logged in runner.ts, no logic branches on it), so a run was aborted purely over an unrecognized logged value. Add 'mcp' to TriggerType and ServerWorkflowTriggerType so MCP runs map to a valid AvailableStepExecution and execute. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(mcp-server): add getWorkflowRun tool (PRD-740) Expose the getWorkflowRun polling tool so the LLM can observe a run's status, closing the discover -> trigger -> poll loop. Report-only in v1: human-gated runs report waitingForHumanInput but cannot be resumed via MCP (tracked in PRD-441). Threads a getMcpWorkflowRun call through forestadmin-client (types, HTTP api, workflows service) to the MS7 read endpoint, and registers a read-only getWorkflowRun MCP tool scoped to the caller. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3 new issues
|
| * The outcome of starting a workflow run: the run continues asynchronously server-side. | ||
| */ | ||
| export interface WorkflowRunTriggerResult { | ||
| runId: number; |
There was a problem hiding this comment.
🟠 High src/types.ts:312
WorkflowRunTriggerResult.runId is typed as number, but GetMcpWorkflowRunParams.runId requires a string, so the result of triggerMcpWorkflow cannot be passed directly into getMcpWorkflowRun without a manual conversion. The mismatch also means MCP tool input validation (string-only) rejects the numeric ID. Use one consistent type for runId across both interfaces.
Suggested change
| runId: number; | |
| runId: string; |
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @packages/forestadmin-client/src/types.ts around line 312:
`WorkflowRunTriggerResult.runId` is typed as `number`, but `GetMcpWorkflowRunParams.runId` requires a `string`, so the result of `triggerMcpWorkflow` cannot be passed directly into `getMcpWorkflowRun` without a manual conversion. The mismatch also means MCP tool input validation (string-only) rejects the numeric ID. Use one consistent type for `runId` across both interfaces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Integration branch for the PRD-49 epic — expose Forest workflow triggering to MCP clients. Adds a report-only (v1) toolset so an LLM can list, trigger, and observe Forest workflows through the MCP server.
The MCP tools call into
@forestadmin/forestadmin-client(WorkflowsService→ForestHttpApi), which hits the Forest orchestrator (/api/workflow-orchestrator/mcp-workflows/*) under the MCP session identity (forestServerToken,Forest-Application-Source: MCP).Included work
listWorkflowstool (feat(mcp-server): add listWorkflows tool (PRD-736) #1771)triggerWorkflowtool (feat(mcp-server): add triggerWorkflow tool (PRD-738) #1777)getWorkflowRuntool (feat(mcp-server): add getWorkflowRun tool (PRD-740) #1785)triggerType='mcp'in the run mapper (fix(workflow-executor): accept triggerType='mcp' in run mapper (PRD-832) #1786)Behavior (v1, report-only)
listWorkflows→ available MCP-enabled workflowstriggerWorkflow→{ runId, runState }getWorkflowRun→ pollrunState,currentStep,waitingForHumanInput, terminal result/errorA run parked on a human-gated step reports
waitingForHumanInput: true; resuming it via MCP is out of scope here and handled in the follow-up PRD-441 (submitWorkflowInput).Tests
New/updated unit tests across
mcp-server,forestadmin-client,workflow-executor, plus cross-package mocks inagent-testingandagent.fixes PRD-49
🤖 Generated with Claude Code
Note
Add workflow tools (listWorkflows, triggerWorkflow, getWorkflowRun) to the Forest MCP server
listWorkflowslists MCP-enabled workflows (optionally filtered by collection),triggerWorkflowstarts a workflow run on a record and logs the action via activity logs, andgetWorkflowRunfetches the current status of a workflow run.WorkflowsServiceinpackages/forestadmin-client/src/workflows/index.tsthat delegates to three new HTTP endpoints onForestHttpApi: GET/api/workflow-orchestrator/mcp-workflows, POST.../mcp-workflows/{workflowId}/start, and GET.../mcp-workflows/runs/{runId}.WorkflowsServicethroughForestAdminClientWithCache,createForestAdminClient, andForestServerClientImplso the MCP server can use it.getAuthContextinto a sharedauth-context.tsutility used across the new tools.mcpto theTriggerTypeandServerWorkflowTriggerTypeenums inworkflow-executorto represent MCP-triggered runs.triggerWorkflowpre-validates the target workflow by callinglistMcpWorkflowsbefore triggering — this adds an extra HTTP round-trip per trigger call.📊 Macroscope summarized e87448d. 18 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.