Skip to content

feat(mcp-server): add listWorkflows tool (PRD-736) - #1771

Merged
christophebrun-forest merged 2 commits into
feature/prd-49-expose-workflow-tools-in-forest-mcp-serverfrom
feature/prd-736-mcp-ms4-listworkflows-tool
Jul 24, 2026
Merged

feat(mcp-server): add listWorkflows tool (PRD-736)#1771
christophebrun-forest merged 2 commits into
feature/prd-49-expose-workflow-tools-in-forest-mcp-serverfrom
feature/prd-736-mcp-ms4-listworkflows-tool

Conversation

@christophebrun-forest

@christophebrun-forestchristophebrun-forest commented Jul 22, 2026

Copy link
Copy Markdown
Member

MS4 of PRD-49 — listWorkflows MCP tool

Exposes MCP-enabled workflows to LLM clients through a new listWorkflows tool in @forestadmin/mcp-server, so a client can discover workflows in its context before triggering one.

fixes PRD-736

What it does

  • New tool listWorkflows with args { collectionName?: string }, registered like the existing list / update / executeAction tools (registerToolWithLogging, read-only).
  • Calls the Forest server MS3 endpoint GET /api/workflow-orchestrator/workflows over the HTTP contract — Bearer forestServerToken + forest-rendering-id header + optional collectionName query. No private-api import.
  • Identity read from extra.authInfo.extra (forestServerToken + renderingId).
  • Returns [{ workflowId, name, collectionName }]. Errors (403/404/…) map to MCP tool errors via the typed errors of ServerUtils + registerToolWithLogging.

Implementation

forestadmin-client

  • WorkflowsService + ForestHttpApi.listMcpEnabledWorkflows (transport, via ServerUtils.queryWithBearerToken)
  • New types McpWorkflow, ListMcpWorkflowsParams, WorkflowsServiceInterface

mcp-server

  • listWorkflows tool + http-client wiring (WorkflowsService)
  • Extracted shared getAuthContext util (reused by activity-logs-creator)
  • Server wiring: ToolName, allTools, allToolNames, SAFE_ARGUMENTS_FOR_LOGGING

Notes

  • description is intentionally not returned — deferred to a separate product ticket (excluded from MS3 on purpose).
  • No withActivityLog on this read-only discovery tool.

Tests

  • forestadmin-client: 288 pass (WorkflowsService + transport)
  • mcp-server: 620 pass (+ new list-workflows tool tests)
  • Lint clean; manual test validated via MCP Inspector and Claude Desktop.

🤖 Generated with Claude Code

Note

Add listWorkflows MCP tool and in-process agent dispatcher to MCP server

  • Adds a new listWorkflows MCP tool in list-workflows.ts that calls forestServerClient.listMcpWorkflows with optional collectionName filtering, returning MCP-enabled workflows as JSON.
  • Introduces an in-process dispatcher (InProcessDispatcher) that routes MCP tool requests directly to the agent's Koa stack via light-my-request, bypassing the network while still running JWT auth and permission checks.
  • Refactors all tool declaration functions to accept a unified ToolContext object (with forestServerClient, logger, collectionNames, and optional agentDispatcher) and pass agentDispatcher through to buildClient/buildClientWithActions.
  • Adds WorkflowsService to ForestAdminClient and wires it through the MCP server's HTTP client so listMcpWorkflows is available server-side.
  • Improves getActionForm tool responses to include per-field description and allowedValues (normalized to {value, label}) for multiple-choice widgets.
  • Risk: In-process dispatch skips any host-app middleware mounted before the agent router; tool calls now target agentUrl (or the in-process stack) instead of the public api_endpoint.

Macroscope summarized 8a9449b.

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

Copy link
Copy Markdown

PRD-736

@qltysh

qltyshBot commented Jul 22, 2026

Copy link
Copy Markdown

7 new issues

ToolCategoryRuleCount
qltyStructureFunction with high complexity (count = 12): declareGetActionFormTool3
qltyStructureFunction with many returns (count = 4): fetchCapabilities2
qltyStructureFunction with many parameters (count = 14): constructor2

Comment threadpackages/mcp-server/src/http-client/mcp-http-client.ts
Reconcile with main and fix the listWorkflows integration break.
- Migrate the listWorkflows tool to main's new ToolContext signature
(declareXxxTool(mcpServer, ctx)) — resolves the server.ts conflict.
- Wire WorkflowsService into forestadmin-client: expose
forestAdminClient.workflowsService (build-application-services,
ForestAdminClientWithCache, ForestAdminClient interface).
- Fix agent.ts to pass workflowsService to ForestServerClientImpl before
forestServerUrl — the new constructor param was inserted mid-signature,
which broke the direct instantiation in the agent (TS2554) and would
have bound the URL to workflowsService at runtime.
- Update ForestAdminClient mocks/factories accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@christophebrun-forest
christophebrun-forest changed the base branch from feature/prd-49-expose-workflow-tools-in-forest-mcp-server to mainJuly 24, 2026 10:19
@qltysh

qltyshBot commented Jul 24, 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 (53)

RatingFile% DiffUncovered Line #s
NewCoverage rating: A
packages/agent/src/utils/forest-schema/generator-fields.ts100.0%
NewCoverage rating: A
packages/agent-client/src/action-fields/field-form-states.ts100.0%
NewCoverage rating: A
...agent-client/src/action-fields/action-field-multiple-choice.ts100.0%
NewCoverage rating: F
packages/agent-testing/src/forest-admin-client-mock.ts50.0%66
NewCoverage rating: A
packages/agent/src/utils/query-string.ts100.0%
NewCoverage rating: A
packages/agent/src/agent.ts100.0%
NewCoverage rating: A
packages/agent-client/src/domains/collection.ts100.0%
NewCoverage rating: A
packages/agent-client/src/http-requester.ts100.0%
NewCoverage rating: A
packages/agent/src/embedded-workflow-executor.ts100.0%
NewCoverage rating: A
...ages/datasource-customizer/src/decorators/binary/collection.ts100.0%
NewCoverage rating: A
packages/agent/src/mcp-in-process-dispatcher.ts100.0%
NewCoverage rating: B
packages/datasource-customizer/src/typing-generator.ts100.0%
NewCoverage rating: A
packages/agent-client/src/index.ts100.0%
NewCoverage rating: A
packages/agent/src/framework-mounter.ts100.0%
NewCoverage rating: A
packages/agent-client/src/action-fields/action-field.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/associate.ts100.0%
NewCoverage rating: A
packages/datasource-mongoose/src/utils/schema/fields.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/http-client/index.ts100.0%
NewCoverage rating: A
packages/forestadmin-client/src/forest-admin-client-with-cache.ts100.0%
NewCoverage rating: A
packages/forestadmin-client/src/workflows/index.ts100.0%
NewCoverage rating: A
packages/forestadmin-client/src/index.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/forest-oauth-provider.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/http-client/mcp-http-client.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/create.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/delete.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/in-process-http-requester.ts100.0%
NewCoverage rating: A
packages/forestadmin-client/src/build-application-services.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/server.ts100.0%
NewCoverage rating: A
packages/datasource-toolkit/src/validation/type-getter.ts100.0%
NewCoverage rating: A
packages/forestadmin-client/src/permissions/forest-http-api.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/utils/activity-logs-creator.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/execute-action.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/utils/agent-caller.ts100.0%
NewCoverage rating: A
packages/workflow-executor/src/build-workflow-executor.ts100.0%
NewCoverage rating: A
packages/plugin-flattener/src/flatten-column/helpers.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/list.ts100.0%
NewCoverage rating: A
packages/plugin-flattener/src/flatten-column/customization.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/update.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/get-action-form.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/list-workflows.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/describe-collection.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/dissociate.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/utils/normalize-agent-url.ts100.0%
NewCoverage rating: A
...ages/workflow-executor/src/adapters/agent-client-agent-port.ts100.0%
NewCoverage rating: A
packages/workflow-executor/src/crypto/credential-encryption.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/utils/auth-context.ts100.0%
NewCoverage rating: A
packages/workflow-executor/src/adapters/step-definition-mapper.ts100.0%
NewCoverage rating: A
packages/workflow-executor/src/cli-core.ts100.0%
NewCoverage rating: A
packages/mcp-server/src/tools/list-related.ts100.0%
NewCoverage rating: A
packages/workflow-executor/src/stores/schema-migrations.ts100.0%
NewCoverage rating: A
...workflow-executor/src/executors/update-record-step-executor.ts100.0%
NewCoverage rating: A
...-executor/src/executors/trigger-record-action-step-executor.ts100.0%
NewCoverage rating: A
packages/workflow-executor/src/types/validated/collection.ts100.0%
Total99.6%
🤖 Increase coverage with AI coding...
In the `feature/prd-736-mcp-ms4-listworkflows-tool` branch, add test coverage for this new code:
- `packages/agent-testing/src/forest-admin-client-mock.ts` -- Line 66

🚦 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 changed the base branch from main to feature/prd-49-expose-workflow-tools-in-forest-mcp-serverJuly 24, 2026 12:00
@christophebrun-forest
christophebrun-forest merged commit 6922326 into feature/prd-49-expose-workflow-tools-in-forest-mcp-serverJul 24, 2026
36 of 37 checks passed
@christophebrun-forest
christophebrun-forest deleted the feature/prd-736-mcp-ms4-listworkflows-tool branch July 24, 2026 12:51
christophebrun-forest added a commit that referenced this pull request Aug 3, 2026
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>
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