Skip to content

feat(mcp): search read tools - #7717

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

feat(mcp): search read tools#7717
cstns merged 7 commits into
feat/extend-mcp-tool-feature-setfrom
feat/mcp-tools-search-read

Conversation

@andypalmi

@andypalmi andypalmi commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Phase 1 read-only MCP tools for the search scope (Story 5, #7232).

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

Tools added:

  • platform_search_team_resources - GET /api/v1/search - search across a team's applications, hosted instances, and remote instances (devices)
  • platform_search_instances - GET /api/v1/search/instances - search a team's hosted and remote instances

Both tools are read-only (readOnlyHint: true, destructiveHint: false) and require teamId and query.

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.

Closes #7677

@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 76.21%. Comparing base (d33b229) to head (7e73cae).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7717      +/-   ##
==========================================
+ Coverage   76.19%   76.21%   +0.01%     
==========================================
  Files         443      444       +1     
  Lines       23726    23737      +11     
  Branches     6314     6314              
==========================================
+ Hits        18079    18090      +11     
  Misses       5647     5647              
Flag Coverage Δ
backend 76.21% <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-search-read branch from 5ee0c36 to ee4873a Compare July 4, 2026 13:33
@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-search-read branch from ee4873a to 13df351 Compare July 6, 2026 16:39
@andypalmi
andypalmi force-pushed the feat/mcp-tools-search-read branch from 13df351 to b6831b5 Compare July 6, 2026 22:01
@andypalmi
andypalmi marked this pull request as draft July 30, 2026 08:20
@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
Add team-resource and instance search tools backed by the /api/v1/search routes.
@andypalmi
andypalmi force-pushed the feat/mcp-tools-search-read branch from b6831b5 to 23a565d Compare August 3, 2026 15:25
@andypalmi
andypalmi marked this pull request as ready for review August 4, 2026 12:35
@andypalmi andypalmi self-assigned this Aug 4, 2026
@andypalmi
andypalmi requested a review from cstns August 4, 2026 12:35
Base automatically changed from feat/mcp-tools-shared-schemas to main August 5, 2026 08:48
Comment thread forge/ee/lib/mcp/tools/search.js Outdated
Comment thread forge/ee/lib/mcp/tools/search.js Outdated
andypalmi added 2 commits August 19, 2026 12:28
Both search tools accepted an empty or whitespace-only query, which the
search endpoints treat as a guaranteed-empty call. Constrain query to a
trimmed, non-empty string so the input is rejected before the request is
made, and drop the description line describing the empty-query behaviour.
@andypalmi

Copy link
Copy Markdown
Contributor Author

Testing results of new tools

Local platform context these calls ran against:

  • One team with hosted instances and one application (no devices), and a second team with 9 hosted instances and 11 remote instances (devices), so both the instance and device match paths could be exercised.

This PR adds 2 read tools to a new search.js; both are exercised below. Payloads show the shape of what came back, with hashids redacted; the object / instanceType discriminators and names are verbatim.

platform_search_team_resources

Searches across a team's applications, hosted instances, and remote instances (devices). Requires teamId and a non-empty query. Each result carries an object discriminator (application | instance | device).

Case Input params Verdict Returned payload (overview, redacted)
matches an instance {teamId, query:"llm"} PASS {count:1, results:[{object:"instance", name:"llm"}]}
matches an application {teamId, query:"Application"} PASS {count:1, results:[{object:"application", name:"Andrea's Application"}]}
matches devices {teamId, query:"device"} PASS {count:3, results:[{object:"device", name}, ...]} (device scope covered on the team with remote instances)
no match {teamId, query:"zzznomatchxyz"} PASS {count:0, results:[]}
empty query {teamId, query:""} PASS {count:0, results:[]} (route returns empty for a blank query; the tool schema also rejects a blank/whitespace query before the call)

platform_search_instances

Searches only the hosted and remote instances of a team. Requires teamId and a non-empty query. Each result carries an instanceType discriminator (hosted | remote).

Case Input params Verdict Returned payload (overview, redacted)
matches hosted instances {teamId, query:"mcp"} PASS {count:2, results:[{instanceType:"hosted", name:"mcp"}, {instanceType:"hosted", name:"mcp-gateway"}]}
matches remote instances {teamId, query:"device"} PASS {count:2, results:[{instanceType:"remote", name}, ...]}
no match {teamId, query:"zzznomatchxyz"} PASS {count:0, results:[]}
empty query {teamId, query:""} PASS {count:0, results:[]}
invalid team {teamId:"@@bad@@", query:"mcp"} PASS {content:{code:bad_request, error:"invalid_team"}, code:400, isError:true}

Conclusion

Both new tools in search.js are verified against their descriptions under team:search: platform_search_team_resources returns typed results across applications, hosted instances, and devices; platform_search_instances returns only hosted and remote instances with an instanceType discriminator. Blank queries return empty results (and are rejected by the tool schema before the call), and an undecodable team id returns a 400. The two endpoints use independent search implementations, so their instance/device result sets can differ for the same query - this is existing route behaviour, unchanged by the tools.

…-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 087a665 into feat/extend-mcp-tool-feature-set Aug 26, 2026
28 checks passed
@cstns
cstns deleted the feat/mcp-tools-search-read branch August 26, 2026 07:38
@cstns
cstns deployed to staging August 26, 2026 07:38 — 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.8 Search

2 participants