Skip to content

feat(mcp): pipeline read tools - #7715

Merged
cstns merged 6 commits into
feat/extend-mcp-tool-feature-setfrom
feat/mcp-tools-pipelines-read
Aug 26, 2026
Merged

feat(mcp): pipeline read tools#7715
cstns merged 6 commits into
feat/extend-mcp-tool-feature-setfrom
feat/mcp-tools-pipelines-read

Conversation

@andypalmi

@andypalmi andypalmi commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Phase 1 read-only MCP tools for DevOps pipelines.

Tool file: forge/ee/lib/mcp/tools/pipelines.js

Tools added:

  • platform_list_pipelines - lists a team's or an application's pipelines; takes an optional teamId or applicationId. With applicationId it calls GET /api/v1/applications/:applicationId/pipelines, otherwise with teamId it calls GET /api/v1/teams/:teamId/pipelines.
  • platform_get_pipeline_stage - GET /api/v1/pipelines/:pipelineId/stages/:stageId

Both tools carry readOnlyHint: true and destructiveHint: false.

Permissions:
#8185 removed the hardcoded user:expert-mcp scope allow-list, so expert MCP tokens now inherit the user's permissions gated by team role and no allow-list entries are needed.

Consolidation notes

The team and application pipeline list tools are combined into a single platform_list_pipelines taking either teamId or applicationId; both routes are unpaginated and share the same role, so one tool with an id argument is simpler for the agent.

Closes #7696

Test plan

  • eslint
  • mocha unit tests

@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.96%. Comparing base (d3419bb) to head (2cc6230).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7715      +/-   ##
==========================================
+ Coverage   75.94%   75.96%   +0.01%     
==========================================
  Files         445      446       +1     
  Lines       23990    24003      +13     
  Branches     6404     6406       +2     
==========================================
+ Hits        18220    18233      +13     
  Misses       5770     5770              
Flag Coverage Δ
backend 75.96% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andypalmi
andypalmi force-pushed the feat/mcp-tools-pipelines-read branch from ef3162b to 31f4caf Compare July 4, 2026 13:33
@andypalmi andypalmi self-assigned this Jul 6, 2026
@andypalmi andypalmi added this to the 2.33 milestone Jul 6, 2026
@andypalmi andypalmi linked an issue Jul 6, 2026 that may be closed by this pull request
@andypalmi
andypalmi force-pushed the feat/mcp-tools-shared-schemas branch from 8bfb22e to 9742987 Compare July 6, 2026 13:13
@andypalmi
andypalmi force-pushed the feat/mcp-tools-pipelines-read branch 2 times, most recently from 8396005 to e179669 Compare July 6, 2026 22:01
@andypalmi
andypalmi marked this pull request as draft July 30, 2026 08:19
@andypalmi
andypalmi requested review from cstns and removed request for cstns July 30, 2026 08:19
@andypalmi
andypalmi force-pushed the feat/mcp-tools-shared-schemas branch from 103f9ae to 5773bdb Compare August 3, 2026 13:19
Add forge/ee/lib/mcp/schemas.js, a shared module of composable zod
fragments the platform read tools import instead of redefining entity-id
and pagination/search/sort/audit-log query fields in each tool file.

- entity-id params: teamId, applicationId, hostedInstanceId (UUID),
  remoteInstanceId, snapshotId
- query fragments composed per route by spreading only the params the
  backing finder honors: cursorParam/limitParam (basePagination),
  pageParam, searchQuery, sortParams, auditLogFilters
- appendQuery serialises a tool's supported params onto the request URL

The module lives one level above tools/ so the tool loader does not
register it as a tool module.

Closes #7669
@andypalmi
andypalmi force-pushed the feat/mcp-tools-shared-schemas branch from eae081f to e04360f Compare August 3, 2026 14:13
@andypalmi
andypalmi force-pushed the feat/mcp-tools-pipelines-read branch from e179669 to 7ad5d36 Compare August 3, 2026 15:25
@andypalmi
andypalmi force-pushed the feat/mcp-tools-pipelines-read branch from 7ad5d36 to 94534c2 Compare August 4, 2026 10:53
@andypalmi
andypalmi marked this pull request as ready for review August 4, 2026 12:37
@andypalmi
andypalmi requested a review from cstns August 4, 2026 12:37
@andypalmi andypalmi modified the milestones: 2.33, 3.0 Aug 4, 2026
Base automatically changed from feat/mcp-tools-shared-schemas to main August 5, 2026 08:48
Comment thread forge/ee/lib/mcp/tools/pipelines.js Outdated
andypalmi added 2 commits August 19, 2026 11:29
…owner

Reword the platform_list_pipelines description to say team results include
only the applications the caller can access, without referencing token scoping.

Return a 400 when neither or both of teamId and applicationId are supplied,
so the handler no longer builds an invalid /teams/undefined/pipelines URL.
@andypalmi

Copy link
Copy Markdown
Contributor Author

Testing results of new tools

Local platform context these calls ran against:

  • One application (Andrea's Application) with 11 hosted instances, no pipelines to start with.
  • A pipeline was seeded (MCP Verify Pipeline) with two chained stages: Dev (targets a hosted instance, create_snapshot action) then Staging (targets a hosted instance, use_latest_snapshot action).

This PR adds 2 read tools to a new pipelines.js; both are exercised below. Payloads show the shape of what came back, with hashids and instance UUIDs redacted as PIPELINE_ID STAGE_ID APP_ID INSTANCE_ID; structural values (counts, actions, stage names) are verbatim.

platform_list_pipelines

Lists a team's or a single application's pipelines. The handler requires exactly one of teamId or applicationId and returns a 400 otherwise (both stay optional strings so the function schema keeps no top-level union). Each pipeline is returned with its ordered stages and their instance targets.

Case Input params Verdict Returned payload (overview, redacted)
by teamId {teamId} PASS {count:1, pipelines:[{id:PIPELINE_ID, name, stages:[Dev(create_snapshot)->Staging(use_latest_snapshot)], application:{id:APP_ID,name}}]}
by applicationId {applicationId} PASS same pipeline record; stages array length 2, in Dev->Staging order (no application block on the application-scoped route)
neither {} PASS {content:"Provide exactly one of teamId or applicationId.", code:400, isError:true}
both {teamId,applicationId} PASS {content:"Provide exactly one of teamId or applicationId.", code:400, isError:true}
nonexistent teamId {teamId:"zzzzzzzzzz"} PASS {content:{code:not_found}, code:404, isError:true}
nonexistent applicationId {applicationId:"zzzzzzzzzz"} PASS {content:{code:not_found}, code:404, isError:true}

platform_get_pipeline_stage

Fetches one stage within a pipeline, including its target (hosted instance here) and snapshot action. Requires both pipelineId and stageId.

Case Input params Verdict Returned payload (overview, redacted)
valid (Dev stage) {pipelineId,stageId} PASS {id:STAGE_ID, name:"Dev", action:"create_snapshot", deployToDevices:false, instances:[{id:INSTANCE_ID,name,url,...}], NextStageId:STAGE_ID}
valid (Staging stage) {pipelineId,stageId} PASS {name:"Staging", action:"use_latest_snapshot", instances:[one], NextStageId:null} (tail of the chain)
nonexistent stageId {pipelineId, stageId:"zzzzzzzzzz"} PASS {content:{code:not_found}, code:404, isError:true}
nonexistent pipelineId {pipelineId:"zzzzzzzzzz", stageId} PASS {content:{code:not_found}, code:404, isError:true}
stage from another pipeline {pipelineId, stageId:<other pipeline's stage>} PASS {content:{code:not_found}, code:404, isError:true} (route rejects a stage not belonging to the given pipeline)

Conclusion

Both new tools in pipelines.js are verified against their descriptions, including the exactly-one-owner rule and both owner paths (team:pipeline:list, application:pipeline:list) on platform_list_pipelines, the ordered-stage output, the stage lookup with its instance target and snapshot action (pipeline:read), and the not-found paths including a stage that belongs to a different pipeline.

…nes-read

# Conflicts:
#	forge/routes/auth/permissions.js
@cstns
cstns changed the base branch from main to feat/extend-mcp-tool-feature-set August 26, 2026 07:35
@cstns
cstns merged commit ea0481f into feat/extend-mcp-tool-feature-set Aug 26, 2026
29 checks passed
@cstns
cstns deleted the feat/mcp-tools-pipelines-read branch August 26, 2026 07:37
@cstns
cstns deployed to staging August 26, 2026 07:37 — with GitHub Actions Active
@cstns cstns mentioned this pull request Aug 26, 2026
11 tasks
andypalmi added a commit that referenced this pull request Aug 26, 2026
## Description

Feature branch for extending mcp tools

## Related Issue(s)

#7727
#7726
#7724
#7723
#7722
#7721
#7720
#7719
#7718
#7717
#7716
#7715


Co-authored-by: andypalmi <andrea@flowfuse.com>
Co-authored-by: Andrea Palmieri <76187074+andypalmi@users.noreply.github.com>
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.

5.5-a Read tools (phase 1)

2 participants