Skip to content

feat(mcp): remote instance (device) read tools - #7726

Open
andypalmi wants to merge 7 commits into
mainfrom
feat/mcp-tools-team-data-read
Open

feat(mcp): remote instance (device) read tools#7726
andypalmi wants to merge 7 commits into
mainfrom
feat/mcp-tools-team-data-read

Conversation

@andypalmi

@andypalmi andypalmi commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 1 read-only MCP tool for the remote instance (device) resource, added to forge/ee/lib/mcp/tools/devices.js:

  • platform_list_team_provisioning_tokens - GET /teams/:teamId/devices/provisioning. Lists a team's device provisioning tokens. The summary view omits the token secret, so it is safe to expose read-only.

The tool describes the device resource, so it is filed with the existing device tools, following the one-file-per-resource convention. It is annotated readOnlyHint: true, destructiveHint: false.

Consolidation notes

  • The remote instance audit-log, history, and HTTP-tokens reads that this PR originally carried are generalized on feat(mcp): hosted instance read tools #7727. platform_get_instance_audit_log, platform_get_instance_history, and platform_list_instance_http_tokens each take an instanceType: 'hosted' | 'remote' argument and live in the new forge/ee/lib/mcp/tools/shared-instances-devices.js, so they serve remote instances (devices) too and no remote-only variants are needed here.
  • The CSV audit-log export is dropped. The GET /devices/:id/audit-log/export route only produces CSV, which is not a useful shape for an automation tool; the shared platform_get_instance_audit_log returns audit entries as JSON.

Permissions

No permissions changes. #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 #7708

Test plan

  • eslint clean on the changed files
  • 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.95%. Comparing base (d3419bb) to head (c9274df).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7726   +/-   ##
=======================================
  Coverage   75.94%   75.95%           
=======================================
  Files         445      445           
  Lines       23990    23994    +4     
  Branches     6404     6404           
=======================================
+ Hits        18220    18224    +4     
  Misses       5770     5770           
Flag Coverage Δ
backend 75.95% <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-team-data-read branch from 9ccc25a to 6a6f4cb 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-team-data-read branch from 6a6f4cb to 9d267f6 Compare July 6, 2026 16:39
@andypalmi
andypalmi force-pushed the feat/mcp-tools-team-data-read branch from 9d267f6 to 737394c Compare July 6, 2026 22:01
@andypalmi andypalmi changed the title feat(mcp): team data and package read tools feat(mcp): remote instance (device) read tools Jul 7, 2026
@andypalmi
andypalmi marked this pull request as draft July 30, 2026 08:21
@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-team-data-read branch from 4cc7f56 to 2e3e1d6 Compare August 3, 2026 15:32
@andypalmi
andypalmi requested a review from cstns August 3, 2026 15:47
@andypalmi
andypalmi marked this pull request as ready for review August 3, 2026 15:47
@andypalmi
andypalmi force-pushed the feat/mcp-tools-team-data-read branch from 2e3e1d6 to 312b18b Compare August 4, 2026 10:52
@andypalmi andypalmi self-assigned this Aug 4, 2026
Base automatically changed from feat/mcp-tools-shared-schemas to main August 5, 2026 08:49
Comment thread forge/ee/lib/mcp/tools/devices.js Outdated
Comment thread forge/ee/lib/mcp/tools/devices.js Outdated
Comment thread forge/ee/lib/mcp/tools/devices.js Outdated
Comment thread forge/ee/lib/mcp/tools/devices.js Outdated
Comment thread forge/ee/lib/mcp/tools/devices.js
andypalmi added 2 commits August 21, 2026 14:44
…ata-read

# Conflicts:
#	forge/routes/auth/permissions.js
…d tool

The remote instance audit-log read, including its CSV export, is generalized as the shared platform_get_instance_audit_log tool that takes an instanceType argument, so the remote-only variant is removed here. This leaves platform_list_team_provisioning_tokens as the tool this change adds.
Restore devices_spec.js to its main baseline and add coverage only for the tool this change introduces.
@andypalmi

Copy link
Copy Markdown
Contributor Author

Testing results of new/changed tools

@cstns for visibility.

This PR now adds a single tool, platform_list_team_provisioning_tokens, which was invoked against a running local platform. The context the calls ran against:

  • Three teams were available; one was seeded with a single device provisioning token, the other two had none.
  • The seeded token was created through the platform's own create route, whose response returns the token secret; the list summary is expected to omit that secret.

Payloads below are redacted for ids, names and secrets; structural values (counts, statuses, error codes, and which fields are present) are verbatim. No credential secret is reproduced.

platform_list_team_provisioning_tokens

Lists a team's device provisioning tokens. The summary view omits the token secret.

Case Input params Verdict Returned payload (redacted)
team with no tokens {teamId: TEAM_ID} PASS {meta:{}, count:0, tokens:[]}
team with one token {teamId: TEAM_ID} PASS {meta:{}, count:1, tokens:[{id, name, team, expiresAt:null}]} - no token secret field
per-token field check {teamId: TEAM_ID} PASS token entry keys are exactly id, name, team, expiresAt; token is absent
nonexistent team {teamId:"doesnotexist"} PASS 404 isError, {code:"not_found"}

Findings

  • The tool passes the route response through unchanged: the tool output matched the raw GET /teams/:teamId/devices/provisioning response byte-for-byte for the same team.
  • The summary view omits the token secret. The create route returns a token field, whereas each list entry exposes only id, name, team, and expiresAt, confirming the tool is safe to expose read-only.
  • An unknown team surfaces a clean 404 rather than an empty list.

Conclusion

The single tool added in this PR verified against its description, including the secret-omission guarantee. No open defects.

@andypalmi
andypalmi requested a review from cstns August 24, 2026 07:21
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.12-a Remote instance (device) read tools (phase 1)

2 participants