Skip to content

feat(mcp): billing read tools - #7725

Open
andypalmi wants to merge 3 commits into
mainfrom
feat/mcp-tools-billing-read
Open

feat(mcp): billing read tools#7725
andypalmi wants to merge 3 commits into
mainfrom
feat/mcp-tools-billing-read

Conversation

@andypalmi

@andypalmi andypalmi commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds read-only MCP tools for team billing visibility in forge/ee/lib/mcp/tools/billing.js:
    • platform_get_team_billing: reads a team's subscription and plan details (GET /ee/billing/teams/:teamId)
    • platform_get_team_customer_portal: returns a Stripe customer-portal URL for a team (GET /ee/billing/teams/:teamId/customer-portal, which issues a 303 redirect; the tool captures the Location header and returns it as url)
  • Both tools are annotated readOnlyHint: true, destructiveHint: false.
  • Allow-lists team:edit in IMPLICIT_TOKEN_SCOPES['user:expert-mcp'] (forge/routes/auth/permissions.js) so expert-mcp tokens can call these owner-gated billing routes. The scope's Owner role still applies, so the tools resolve only on teams where the user is an Owner.

Closes #7683

Test plan

  • eslint on changed files (also ran via commit hook's full lint)
  • permissions_spec covers the implicit grant: an owner expert-mcp token may use the granted team:edit, a member is still role-gated, and a scope outside the implicit list stays denied
  • Manual verification against a team with an active subscription

@andypalmi
andypalmi force-pushed the feat/mcp-tools-billing-read branch from 4b4e679 to a758940 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-billing-read branch from a758940 to a65f554 Compare July 6, 2026 16:38
@andypalmi
andypalmi force-pushed the feat/mcp-tools-billing-read branch from a65f554 to 66e0985 Compare July 6, 2026 22:01
@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-billing-read branch from 66e0985 to 7d39363 Compare August 3, 2026 15:28
@andypalmi
andypalmi marked this pull request as ready for review August 4, 2026 12:00
@andypalmi
andypalmi requested review from Copilot and cstns and removed request for Copilot August 4, 2026 12:00
@andypalmi
andypalmi force-pushed the feat/mcp-tools-billing-read branch from 7d39363 to 73d8d0d Compare August 4, 2026 12:14
Add team billing and customer-portal read tools with unit specs.
@andypalmi
andypalmi force-pushed the feat/mcp-tools-billing-read branch from 73d8d0d to a0fb70e Compare August 4, 2026 12:29
@andypalmi andypalmi self-assigned this Aug 4, 2026
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.18%. Comparing base (a8f760b) to head (b9c2e9e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7725      +/-   ##
==========================================
+ Coverage   76.17%   76.18%   +0.01%     
==========================================
  Files         440      441       +1     
  Lines       23604    23615      +11     
  Branches     6285     6286       +1     
==========================================
+ Hits        17981    17992      +11     
  Misses       5623     5623              
Flag Coverage Δ
backend 76.18% <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.

Base automatically changed from feat/mcp-tools-shared-schemas to main August 5, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5.14 Billing (read-only)

2 participants