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-forest christophebrun-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

linear-code Bot commented Jul 22, 2026

Copy link
Copy Markdown

PRD-736

@qltysh

qltysh Bot commented Jul 22, 2026

Copy link
Copy Markdown

7 new issues

Tool Category Rule Count
qlty Structure Function with high complexity (count = 12): declareGetActionFormTool 3
qlty Structure Function with many returns (count = 4): fetchCapabilities 2
qlty Structure Function with many parameters (count = 14): constructor 2

Comment thread packages/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 main July 24, 2026 10:19
@qltysh

qltysh Bot 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
New Coverage rating: A
packages/agent/src/utils/forest-schema/generator-fields.ts100.0%
New Coverage rating: A
packages/agent-client/src/action-fields/field-form-states.ts100.0%
New Coverage rating: A
...agent-client/src/action-fields/action-field-multiple-choice.ts100.0%
New Coverage rating: F
packages/agent-testing/src/forest-admin-client-mock.ts50.0%66
New Coverage rating: A
packages/agent/src/utils/query-string.ts100.0%
New Coverage rating: A
packages/agent/src/agent.ts100.0%
New Coverage rating: A
packages/agent-client/src/domains/collection.ts100.0%
New Coverage rating: A
packages/agent-client/src/http-requester.ts100.0%
New Coverage rating: A
packages/agent/src/embedded-workflow-executor.ts100.0%
New Coverage rating: A
...ages/datasource-customizer/src/decorators/binary/collection.ts100.0%
New Coverage rating: A
packages/agent/src/mcp-in-process-dispatcher.ts100.0%
New Coverage rating: B
packages/datasource-customizer/src/typing-generator.ts100.0%
New Coverage rating: A
packages/agent-client/src/index.ts100.0%
New Coverage rating: A
packages/agent/src/framework-mounter.ts100.0%
New Coverage rating: A
packages/agent-client/src/action-fields/action-field.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/associate.ts100.0%
New Coverage rating: A
packages/datasource-mongoose/src/utils/schema/fields.ts100.0%
New Coverage rating: A
packages/mcp-server/src/http-client/index.ts100.0%
New Coverage rating: A
packages/forestadmin-client/src/forest-admin-client-with-cache.ts100.0%
New Coverage rating: A
packages/forestadmin-client/src/workflows/index.ts100.0%
New Coverage rating: A
packages/forestadmin-client/src/index.ts100.0%
New Coverage rating: A
packages/mcp-server/src/forest-oauth-provider.ts100.0%
New Coverage rating: A
packages/mcp-server/src/http-client/mcp-http-client.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/create.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/delete.ts100.0%
New Coverage rating: A
packages/mcp-server/src/in-process-http-requester.ts100.0%
New Coverage rating: A
packages/forestadmin-client/src/build-application-services.ts100.0%
New Coverage rating: A
packages/mcp-server/src/server.ts100.0%
New Coverage rating: A
packages/datasource-toolkit/src/validation/type-getter.ts100.0%
New Coverage rating: A
packages/forestadmin-client/src/permissions/forest-http-api.ts100.0%
New Coverage rating: A
packages/mcp-server/src/utils/activity-logs-creator.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/execute-action.ts100.0%
New Coverage rating: A
packages/mcp-server/src/utils/agent-caller.ts100.0%
New Coverage rating: A
packages/workflow-executor/src/build-workflow-executor.ts100.0%
New Coverage rating: A
packages/plugin-flattener/src/flatten-column/helpers.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/list.ts100.0%
New Coverage rating: A
packages/plugin-flattener/src/flatten-column/customization.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/update.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/get-action-form.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/list-workflows.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/describe-collection.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/dissociate.ts100.0%
New Coverage rating: A
packages/mcp-server/src/utils/normalize-agent-url.ts100.0%
New Coverage rating: A
...ages/workflow-executor/src/adapters/agent-client-agent-port.ts100.0%
New Coverage rating: A
packages/workflow-executor/src/crypto/credential-encryption.ts100.0%
New Coverage rating: A
packages/mcp-server/src/utils/auth-context.ts100.0%
New Coverage rating: A
packages/workflow-executor/src/adapters/step-definition-mapper.ts100.0%
New Coverage rating: A
packages/workflow-executor/src/cli-core.ts100.0%
New Coverage rating: A
packages/mcp-server/src/tools/list-related.ts100.0%
New Coverage rating: A
packages/workflow-executor/src/stores/schema-migrations.ts100.0%
New Coverage rating: A
...workflow-executor/src/executors/update-record-step-executor.ts100.0%
New Coverage rating: A
...-executor/src/executors/trigger-record-action-step-executor.ts100.0%
New Coverage 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-server July 24, 2026 12:00
@christophebrun-forest
christophebrun-forest merged commit 6922326 into feature/prd-49-expose-workflow-tools-in-forest-mcp-server Jul 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
Sign up for free to 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