Skip to content

feat(mcp-server): add getWorkflowRun tool (PRD-740) - #1785

Merged
christophebrun-forest merged 4 commits into
feature/prd-49-expose-workflow-tools-in-forest-mcp-serverfrom
feature/prd-740-mcp-ms8-getworkflowrun-tool
Jul 29, 2026
Merged

feat(mcp-server): add getWorkflowRun tool (PRD-740)#1785
christophebrun-forest merged 4 commits into
feature/prd-49-expose-workflow-tools-in-forest-mcp-serverfrom
feature/prd-740-mcp-ms8-getworkflowrun-tool

Conversation

@christophebrun-forest

@christophebrun-forestchristophebrun-forest commented Jul 28, 2026

Copy link
Copy Markdown
Member

Description

Story MS8 of PRD-49 · Iteration 4 (observation).

Exposes the getWorkflowRun polling tool so the LLM can observe a run's status, closing the discover (listWorkflows) → trigger (triggerWorkflow) → poll (getWorkflowRun) loop.

Report-only in v1: a run parked on a human-gated step reports waitingForHumanInput: true but is not resumable via MCP — such runs are finished from the Forest UI (resume tracked in PRD-441).

Changes

@forestadmin/forestadmin-client

  • New types WorkflowRunStep, WorkflowRunStatus, GetMcpWorkflowRunParams; getMcpWorkflowRun added to WorkflowsServiceInterface and ForestAdminServerInterface
  • ForestHttpApi.getMcpWorkflowRun()GET /api/workflow-orchestrator/mcp-workflows/runs/:runId (rendering-id header, url-encoded runId)
  • WorkflowsService.getMcpWorkflowRun() delegation + public exports

@forestadmin/mcp-server

  • New getWorkflowRun tool (readOnlyHint: true, zod arg runId: string; no activity log since read-only)
  • getWorkflowRun on the ForestServerClient http-client
  • Registration wiring in server.ts (ToolName union, allTools, allToolNames, SAFE_ARGUMENTS_FOR_LOGGING)

Acceptance criteria

  • Returns runState, currentStep, waitingForHumanInput, terminal result/error, scoped to the caller
  • Human-gated runs report waitingForHumanInput: true, not resumable via MCP (v1)
  • Unknown/forbidden runId → tool error 404/403

Tests

forestadmin-client (299) + mcp-server (667) green; lint + build clean on both packages. Added coverage for the HTTP path/headers/url-encode, service delegation, http-client delegation, and the tool (registration, identity+args forwarding, human-gated reporting, missing auth, 404, 403).

Notes

  • Depends on the MS7 server endpoint (PRD-739, forestadmin-server PR #8407).
  • ⚠️ Assumes a top-level (non JSON:API-wrapped) response payload, consistent with the existing workflow endpoints — to confirm against the live MS7 response.

fixes PRD-740

🤖 Generated with Claude Code

Note

Add getWorkflowRun MCP tool to fetch workflow run status

  • Adds a new getWorkflowRun tool in packages/mcp-server/src/tools/get-workflow-run.ts that accepts a runId, extracts auth context, and returns the workflow run status as JSON.
  • Adds getMcpWorkflowRun to WorkflowsService and ForestHttpApi, performing a GET to /api/workflow-orchestrator/mcp-workflows/runs/{runId} with bearer token and rendering ID header.
  • Extends WorkflowsServiceInterface, ForestAdminServerInterface, and ForestServerClient with the new method signature, and exports the new WorkflowRunStatus, WorkflowRunStep, and GetMcpWorkflowRunParams types from forestadmin-client.

Macroscope summarized e02cf17.

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>
@linear-code

Copy link
Copy Markdown

PRD-740

christophebrun-forestand others added 3 commits July 28, 2026 11:38
…ools-in-forest-mcp-server' into feature/prd-740-mcp-ms8-getworkflowrun-tool
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@qltysh

qltyshBot commented Jul 29, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

Unable to calculate total coverage change because base branch coverage was not found.

Modified Files with Diff Coverage (6)

RatingFile% DiffUncovered Line #s
NewCoverage rating: A
packages/mcp-server/src/tools/get-workflow-run.ts100.0%
NewCoverage rating: D
packages/agent-testing/src/forest-admin-client-mock.ts100.0%
NewCoverage rating: A
packages/forestadmin-client/src/workflows/index.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/http-client/mcp-http-client.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/server.ts100.0%
NewCoverage rating: A
packages/forestadmin-client/src/permissions/forest-http-api.ts100.0%
Total100.0%
🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@christophebrun-forest
christophebrun-forest merged commit e87448d into feature/prd-49-expose-workflow-tools-in-forest-mcp-serverJul 29, 2026
32 checks passed
@christophebrun-forest
christophebrun-forest deleted the feature/prd-740-mcp-ms8-getworkflowrun-tool branch July 29, 2026 15:24
christophebrun-forest added a commit that referenced this pull request Aug 3, 2026
* 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>
christophebrun-forest added a commit that referenced this pull request Aug 24, 2026
…#1792)
Adds a report-only (v1) workflow toolset so an LLM can list, trigger and observe
Forest workflows through the MCP server.
Tools (all default-on):
- listWorkflows — MCP-enabled workflows, optionally filtered by collection.
Workflows whose collection was renamed or removed are filtered out, since
triggerWorkflow would reject them anyway.
- triggerWorkflow — starts a run on a record, returns { runId, runState }.
Resolves the workflow by id (O(1)), rejects unknown / MCP-disabled ids
without starting a run, and declares destructive MCP annotations.
- getWorkflowRun — the full hydrated run: runState plus the complete
workflowHistory (per-step definition and context). A run parked on a
human-gated step is not resumable via MCP in v1 (follow-up PRD-441).
Transport: the tools call @forestadmin/forestadmin-client (new WorkflowsService
→ ForestHttpApi) against /api/workflow-orchestrator/mcp-workflows/*, under the
MCP session identity (forestServerToken, Forest-Application-Source: MCP stamped
on the MCP-only routes). All four responses are projected onto an explicit
whitelist before reaching a model — stepDefinition is the one deliberate
pass-through.
Audit: triggerWorkflow is fail-closed. The pending activity log ("requested the
workflow X via MCP", no runId yet) is written before the run starts, like
create/update/delete. The fail policy now lives in createPendingActivityLog and
is arbitrated by action type and by cause: write actions fail closed, read
actions fail open with a logged warning, and a 401/403 propagates either way.
It covers both the rejected write and the 200-with-null-log-id case.
Model-facing errors: transport failures are classified before a model sees them
on all four calls — raw Node/superagent errors and the client-built 408 never
reach the model, terminal 4xx are told not to retry (shared RETRY_WILL_NOT_HELP
wording), and the non-idempotent trigger never advises a retry.
Also: TriggerType.Mcp accepted by the workflow-executor run mapper (PRD-832);
ForestAdminClient gains a required readonly workflowsService (compile-time
breaking for external implementations of the interface — the
ForestAdminClientWithCache constructor is a strict append); recordId bounded at
255 to match the server column.
Deploy order (spans three repos): workflow executors to the PRD-832 release
first (an older executor makes every MCP trigger fail loudly with a zod error),
then forestadmin-server (PRD-49, provides the mcp-workflows routes and the
by-id lookup this audit depends on), then this PR and the frontend.
Includes PRD-736 (#1771), PRD-738 (#1777), PRD-740 (#1785), PRD-831 (#1805),
PRD-832 (#1786).
fixes PRD-49
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
forest-bot added a commit that referenced this pull request Aug 24, 2026
# @forestadmin/forestadmin-client [1.43.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/forestadmin-client@1.42.1...@forestadmin/forestadmin-client@1.43.0) (2026-08-24)
### Features
* **mcp-server:** expose workflow tools in Forest MCP server (PRD-49) ([#1792](#1792)) ([7e34af2](7e34af2)), closes [#1771](#1771) [#1777](#1777) [#1785](#1785) [#1805](#1805) [#1786](#1786)
forest-bot added a commit that referenced this pull request Aug 24, 2026
# @forestadmin/mcp-server [1.23.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/mcp-server@1.22.1...@forestadmin/mcp-server@1.23.0) (2026-08-24)
### Features
* **mcp-server:** expose workflow tools in Forest MCP server (PRD-49) ([#1792](#1792)) ([7e34af2](7e34af2)), closes [#1771](#1771) [#1777](#1777) [#1785](#1785) [#1805](#1805) [#1786](#1786)
### Dependencies
* **@forestadmin/agent-client:** upgraded to 1.14.1
* **@forestadmin/forestadmin-client:** upgraded to 1.43.0
forest-bot added a commit that referenced this pull request Aug 24, 2026
# @forestadmin/workflow-executor [1.25.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/workflow-executor@1.24.0...@forestadmin/workflow-executor@1.25.0) (2026-08-24)
### Features
* **mcp-server:** expose workflow tools in Forest MCP server (PRD-49) ([#1792](#1792)) ([7e34af2](7e34af2)), closes [#1771](#1771) [#1777](#1777) [#1785](#1785) [#1805](#1805) [#1786](#1786)
### Dependencies
* **@forestadmin/agent-client:** upgraded to 1.14.1
* **@forestadmin/forestadmin-client:** upgraded to 1.43.0
forest-bot added a commit that referenced this pull request Aug 24, 2026
# @forestadmin/agent [1.97.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/agent@1.96.0...@forestadmin/agent@1.97.0) (2026-08-24)
### Features
* **mcp-server:** expose workflow tools in Forest MCP server (PRD-49) ([#1792](#1792)) ([7e34af2](7e34af2)), closes [#1771](#1771) [#1777](#1777) [#1785](#1785) [#1805](#1805) [#1786](#1786)
### Dependencies
* **@forestadmin/forestadmin-client:** upgraded to 1.43.0
* **@forestadmin/mcp-server:** upgraded to 1.23.0
* **@forestadmin/workflow-executor:** upgraded to 1.25.0
forest-bot added a commit that referenced this pull request Aug 24, 2026
# @forestadmin/agent-testing [1.2.0](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/agent-testing@1.1.79...@forestadmin/agent-testing@1.2.0) (2026-08-24)
### Features
* **mcp-server:** expose workflow tools in Forest MCP server (PRD-49) ([#1792](#1792)) ([7e34af2](7e34af2)), closes [#1771](#1771) [#1777](#1777) [#1785](#1785) [#1805](#1805) [#1786](#1786)
### Dependencies
* **@forestadmin/agent-client:** upgraded to 1.14.1
* **@forestadmin/forestadmin-client:** upgraded to 1.43.0
* **@forestadmin/agent:** upgraded to 1.97.0
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@christophebrun-forest