Skip to content

feat(mcp): notification and self-service read tools - #7718

Open
andypalmi wants to merge 5 commits into
mainfrom
feat/mcp-tools-notifications-read
Open

feat(mcp): notification and self-service read tools#7718
andypalmi wants to merge 5 commits into
mainfrom
feat/mcp-tools-notifications-read

Conversation

@andypalmi

@andypalmi andypalmi commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Phase 1 read-only MCP tools for user self-service #7702 .

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

Tools added:

  • platform_get_current_user - GET /api/v1/user
  • platform_list_notifications - GET /api/v1/user/notifications (paginated)
  • platform_list_own_invitations - GET /api/v1/user/invitations

All three are tagged readOnlyHint: true, 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.

Write, delete, and admin-only endpoints from the parent issue #7703 #7704 are out of scope for this PR, as are the excluded sensitive self-service routes (change_password, account deletion, MFA, tokens).

Closes #7702

Test plan

  • eslint clean on changed files
  • CI

@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 (d28ce07).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7718      +/-   ##
==========================================
+ Coverage   75.94%   75.96%   +0.01%     
==========================================
  Files         445      446       +1     
  Lines       23990    24002      +12     
  Branches     6404     6404              
==========================================
+ Hits        18220    18232      +12     
  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-notifications-read branch from 179b11c to 73b4713 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-notifications-read branch from 73b4713 to e6e47ac Compare July 6, 2026 16:38
@andypalmi
andypalmi force-pushed the feat/mcp-tools-notifications-read branch from e6e47ac to 0438f64 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 read-only MCP tools for the current user profile, own notifications and own team invitations, and allow-list their scopes for the expert-mcp platform token.
@andypalmi
andypalmi force-pushed the feat/mcp-tools-notifications-read branch from 0438f64 to 65cb66e Compare August 3, 2026 15:26
@andypalmi
andypalmi requested a review from cstns August 4, 2026 12:35
@andypalmi andypalmi self-assigned this Aug 4, 2026
@andypalmi
andypalmi marked this pull request as ready for review August 4, 2026 12:35
Base automatically changed from feat/mcp-tools-shared-schemas to main August 5, 2026 08:48
Lists the authenticated user's own notifications, with pagination.
Use this to check for unread alerts or recent activity addressed to the current user.`,
annotations: { readOnlyHint: true, destructiveHint: false },
inputSchema: { ...basePagination },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this endpoint does not support pagination

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET /api/v1/user/notifications does paginate. It runs through getNotifications in forge/services/notifications.js, which calls app.getPaginationOptions(request) and passes it to Notification.forUser, and the response carries meta and count. Confirmed against a running instance: platform_list_notifications { limit: 1 } returned 1 of 4 notifications with meta.next_cursor set, and passing that cursor back returned the next entry. So cursor and limit are correct on this tool.

Use this to check whether the current user has any pending invitations to join a team.
No parameters or body required.`,
annotations: { readOnlyHint: true, destructiveHint: false },
inputSchema: {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is paginated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET /api/v1/user/invitations does not paginate. It calls Invitation.forUser(request.session.User) with no pagination options and always returns meta: {} (that line carries a // For future pagination note in forge/routes/api/userInvitations.js), returning every invitation. Confirmed against a running instance: with two pending invitations, platform_list_own_invitations { limit: 1 } still returned both, and { limit: 1, cursor: "bogus" } returned the same two with no error. So the params have no effect, which is why this tool has no pagination params; we can add them if the endpoint gains real pagination later.

@andypalmi

Copy link
Copy Markdown
Contributor Author

Verified the pagination behavior by invoking the tools against a local instance.

platform_list_notifications (account had 4 notifications):

  • {} -> count 4, meta: {}, 4 items
  • { limit: 1 } -> count 4, meta: { next_cursor: <id> }, 1 item
  • { limit: 1, cursor: <that id> } -> next item, meta: { next_cursor: <next id> }
  • { limit: 50 } -> count 4, meta: {}, 4 items

platform_list_own_invitations (account had 2 pending invitations):

  • {} -> count 2, meta: {}, 2 items
  • { limit: 1 } -> count 2, meta: {}, 2 items (limit ignored)
  • { limit: 1, cursor: "bogus" } -> identical, no error

Conclusion: notifications supports cursor/limit; invitations does not, matching the current tool schemas.

@andypalmi
andypalmi requested a review from cstns August 20, 2026 08:51
…cations-read

# Conflicts:
#	forge/routes/auth/permissions.js
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.9-a Read tools (phase 1)

2 participants