@burdenoff/mcp-libs 2026.1110.5 → 2026.1110.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -124,6 +124,72 @@ const GET_QUOTAS_OF_SUB = `
124
124
  }
125
125
  }
126
126
  `;
127
+ const ADDON_FIELDS = `
128
+ id name price currency duration productId: productID isActive
129
+ requiresPaidSubscription createdAt updatedAt
130
+ `;
131
+ /** There is no single-addon query; `getSelectedAddons` resolves a list of ids. */
132
+ const GET_SELECTED_ADDONS = `
133
+ query GetSelectedAddons($addonIDs: [String!]!) {
134
+ getSelectedAddons(addonIDs: $addonIDs) { ${ADDON_FIELDS} }
135
+ }
136
+ `;
137
+ const COUPON_FIELDS = `
138
+ id code name description type value currency scope status
139
+ validFrom validUntil maxTotalUses maxUsesPerUser currentUses
140
+ minPurchaseAmount maxDiscountAmount applicableProductIds
141
+ campaignId metadata createdAt updatedAt
142
+ `;
143
+ const LIST_COUPONS = `
144
+ query ListCoupons($filter: CouponFilterInput, $limit: Int, $offset: Int) {
145
+ listCoupons(filter: $filter, limit: $limit, offset: $offset) {
146
+ coupons { ${COUPON_FIELDS} }
147
+ total hasMore
148
+ }
149
+ }
150
+ `;
151
+ /** The subgraph takes the coupon id; `GET_COUPON_BY_CODE` resolves a code. */
152
+ const GET_COUPON = `
153
+ query GetCoupon($id: ID!) {
154
+ getCoupon(id: $id) { ${COUPON_FIELDS} }
155
+ }
156
+ `;
157
+ const GET_COUPON_BY_CODE = `
158
+ query GetCouponByCode($code: String!) {
159
+ getCouponByCode(code: $code) { ${COUPON_FIELDS} }
160
+ }
161
+ `;
162
+ /** Requires billingAccountId; the period defaults server-side (LAST_30_DAYS). */
163
+ const GET_USAGE_DASHBOARD = `
164
+ query GetUsageDashboard($billingAccountId: ID!, $period: AnalyticsPeriod) {
165
+ getUsageDashboard(billingAccountId: $billingAccountId, period: $period) {
166
+ totalQuotas activeQuotas healthyQuotas warningQuotas criticalQuotas
167
+ exhaustedQuotas totalUsage
168
+ overallTrends { averageDailyUsage growthRate predictedUsage }
169
+ topUsageByQuota { quotaId quotaName usage limit percentage status }
170
+ recentActivities { id quotaName amount description tags timestamp }
171
+ }
172
+ }
173
+ `;
174
+ const GET_EARNINGS_SUMMARY = `
175
+ query MyEarningsSummary($billingAccountId: ID!) {
176
+ myEarningsSummary(billingAccountId: $billingAccountId) {
177
+ totalLifetimeAmount availableAmount pendingAmount reservedAmount
178
+ paidAmount reversedAmount moneyAmount creditsAmount
179
+ categoryBreakdown { category amount count }
180
+ }
181
+ }
182
+ `;
183
+ const PAYOUT_ACCOUNT_FIELDS = `
184
+ id billingAccountId type label displayName accountLast4 country currency
185
+ providerPreference status isDefault isActive verifiedAt metadata
186
+ createdAt updatedAt
187
+ `;
188
+ const LIST_PAYOUT_ACCOUNTS = `
189
+ query MyPayoutAccounts($billingAccountId: ID!) {
190
+ myPayoutAccounts(billingAccountId: $billingAccountId) { ${PAYOUT_ACCOUNT_FIELDS} }
191
+ }
192
+ `;
127
193
 
128
194
  // src/modules/billing/tools.ts
129
195
  /**
@@ -142,6 +208,28 @@ async function resolveBillingAccountId(ctx, override) {
142
208
  if (!data.getDefaultBillingAccount?.id) throw new Error("No default billing account on file. Pass account explicitly.");
143
209
  return data.getDefaultBillingAccount.id;
144
210
  }
211
+ /** A read: no state changes, nothing leaves Burdenoff. */
212
+ const READ_ONLY = {
213
+ readOnlyHint: true,
214
+ destructiveHint: false,
215
+ openWorldHint: false
216
+ };
217
+ /**
218
+ * Moves money, ends a paid service or deletes a payment method. Declared
219
+ * explicitly because the name-based inference misses most of these verbs
220
+ * (upgrade, cancel, grant, withdraw), and a shell that enforces destructive
221
+ * confirmation must ask before any of them runs (BOFF-10887; same defect
222
+ * class as store_cart_checkout in BOFF-10861).
223
+ */
224
+ const MONEY_MOVING = {
225
+ readOnlyHint: false,
226
+ destructiveHint: true,
227
+ openWorldHint: true
228
+ };
229
+ function failure(ctx, tool, what, error) {
230
+ ctx.logger.error(`${tool} failed`, { error: String(error) });
231
+ return errorResult(`Failed to ${what}: ${error instanceof Error ? error.message : String(error)}`);
232
+ }
145
233
  function registerBillingTools(server, ctx, track) {
146
234
  server.registerTool(track(mcpToolName(ctx.productName, "billing_subscriptions_list")), {
147
235
  title: "List Subscriptions",
@@ -182,6 +270,7 @@ function registerBillingTools(server, ctx, track) {
182
270
  server.registerTool(track(mcpToolName(ctx.productName, "billing_subscriptions_upgrade")), {
183
271
  title: "Update Subscription Seats",
184
272
  description: "Change the seat count on a subscription.",
273
+ annotations: MONEY_MOVING,
185
274
  inputSchema: {
186
275
  id: z.string().describe("Subscription ID"),
187
276
  seats: z.number().describe("Target seat count")
@@ -202,6 +291,7 @@ function registerBillingTools(server, ctx, track) {
202
291
  server.registerTool(track(mcpToolName(ctx.productName, "billing_subscriptions_cancel")), {
203
292
  title: "Cancel Subscription",
204
293
  description: "Cancel a subscription with an optional reason.",
294
+ annotations: MONEY_MOVING,
205
295
  inputSchema: {
206
296
  id: z.string().describe("Subscription ID"),
207
297
  reason: z.string().optional().describe("Cancellation reason")
@@ -348,6 +438,11 @@ function registerBillingTools(server, ctx, track) {
348
438
  server.registerTool(track(mcpToolName(ctx.productName, "billing_payment_methods_add")), {
349
439
  title: "Add Payment Method",
350
440
  description: "Add a payment method (card metadata only — provider handles secrets). Use the provider checkout URL elsewhere for full card capture.",
441
+ annotations: {
442
+ readOnlyHint: false,
443
+ destructiveHint: false,
444
+ openWorldHint: true
445
+ },
351
446
  inputSchema: {
352
447
  type: z.enum([
353
448
  "CREDIT_CARD",
@@ -386,6 +481,7 @@ function registerBillingTools(server, ctx, track) {
386
481
  server.registerTool(track(mcpToolName(ctx.productName, "billing_payment_methods_remove")), {
387
482
  title: "Remove Payment Method",
388
483
  description: "Delete a payment method by ID (on the given or default billing account).",
484
+ annotations: MONEY_MOVING,
389
485
  inputSchema: {
390
486
  id: z.string().describe("Payment method ID"),
391
487
  account: z.string().optional().describe("Billing account ID (defaults to current)")
@@ -423,6 +519,7 @@ function registerBillingTools(server, ctx, track) {
423
519
  server.registerTool(track(mcpToolName(ctx.productName, "billing_credits_grant")), {
424
520
  title: "Grant Credits",
425
521
  description: "Grant credits to a billing account (admin only).",
522
+ annotations: MONEY_MOVING,
426
523
  inputSchema: {
427
524
  account: z.string().describe("Billing account ID"),
428
525
  amount: z.number().describe("Amount to grant"),
@@ -450,6 +547,7 @@ function registerBillingTools(server, ctx, track) {
450
547
  server.registerTool(track(mcpToolName(ctx.productName, "billing_credits_withdraw")), {
451
548
  title: "Withdraw Credits",
452
549
  description: "Request a credit withdrawal to a payout account.",
550
+ annotations: MONEY_MOVING,
453
551
  inputSchema: {
454
552
  account: z.string().describe("Billing account ID"),
455
553
  amount: z.number().describe("Amount to withdraw"),
@@ -513,6 +611,156 @@ function registerBillingTools(server, ctx, track) {
513
611
  return errorResult(`Failed to list quotas: ${error instanceof Error ? error.message : String(error)}`);
514
612
  }
515
613
  });
614
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_addons_get")), {
615
+ title: "Get Addon",
616
+ description: "Get one addon by ID.",
617
+ annotations: READ_ONLY,
618
+ inputSchema: { id: z.string().min(1).describe("Addon ID") }
619
+ }, async ({ id }) => {
620
+ try {
621
+ const addon = (await ctx.gql.global.request(GET_SELECTED_ADDONS, { addonIDs: [id] })).getSelectedAddons.find((row) => row.id === id);
622
+ if (!addon) return errorResult(`Addon ${id} not found`);
623
+ return jsonResult(addon);
624
+ } catch (error) {
625
+ return failure(ctx, "billing_addons_get", "get addon", error);
626
+ }
627
+ });
628
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_addons_get_many")), {
629
+ title: "Get Addons",
630
+ description: "Get several addons by ID in one call. IDs that do not exist are left out.",
631
+ annotations: READ_ONLY,
632
+ inputSchema: { ids: z.array(z.string().min(1)).min(1).max(100).describe("Addon IDs (1-100)") }
633
+ }, async ({ ids }) => {
634
+ try {
635
+ const data = await ctx.gql.global.request(GET_SELECTED_ADDONS, { addonIDs: ids });
636
+ return jsonResult(data.getSelectedAddons);
637
+ } catch (error) {
638
+ return failure(ctx, "billing_addons_get_many", "get addons", error);
639
+ }
640
+ });
641
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_coupons_list")), {
642
+ title: "List Coupons",
643
+ description: "List coupons, optionally filtered (billing admins only). Creating or changing a coupon is not available here.",
644
+ annotations: READ_ONLY,
645
+ inputSchema: {
646
+ status: z.enum([
647
+ "ACTIVE",
648
+ "DEPLETED",
649
+ "EXPIRED",
650
+ "INACTIVE"
651
+ ]).optional(),
652
+ type: z.enum([
653
+ "FIXED_AMOUNT",
654
+ "FREE_SHIPPING",
655
+ "PERCENTAGE"
656
+ ]).optional(),
657
+ scope: z.enum([
658
+ "CAMPAIGN",
659
+ "GENERIC",
660
+ "REFERRAL",
661
+ "USER_SPECIFIC"
662
+ ]).optional(),
663
+ campaignId: z.string().optional().describe("Only this campaign"),
664
+ search: z.string().optional().describe("Search code and name"),
665
+ limit: z.number().int().min(1).max(200).optional().describe("Page size (default 50)"),
666
+ offset: z.number().int().min(0).optional().describe("Offset (default 0)")
667
+ }
668
+ }, async ({ limit, offset, ...filterArgs }) => {
669
+ try {
670
+ const filter = {};
671
+ for (const [key, value] of Object.entries(filterArgs)) if (value !== void 0) filter[key] = value;
672
+ const data = await ctx.gql.global.request(LIST_COUPONS, {
673
+ filter: Object.keys(filter).length ? filter : void 0,
674
+ limit,
675
+ offset
676
+ });
677
+ return jsonResult(data.listCoupons);
678
+ } catch (error) {
679
+ return failure(ctx, "billing_coupons_list", "list coupons", error);
680
+ }
681
+ });
682
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_coupons_get")), {
683
+ title: "Get Coupon",
684
+ description: "Get a coupon by its ID (billing admins only). Use billing_coupons_get_by_code for a code.",
685
+ annotations: READ_ONLY,
686
+ inputSchema: { id: z.string().min(1).describe("Coupon ID") }
687
+ }, async ({ id }) => {
688
+ try {
689
+ const data = await ctx.gql.global.request(GET_COUPON, { id });
690
+ if (!data.getCoupon) return errorResult(`Coupon ${id} not found`);
691
+ return jsonResult(data.getCoupon);
692
+ } catch (error) {
693
+ return failure(ctx, "billing_coupons_get", "get coupon", error);
694
+ }
695
+ });
696
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_coupons_get_by_code")), {
697
+ title: "Get Coupon By Code",
698
+ description: "Get a coupon by the code customers enter (billing admins only).",
699
+ annotations: READ_ONLY,
700
+ inputSchema: { code: z.string().min(1).describe("Coupon code") }
701
+ }, async ({ code }) => {
702
+ try {
703
+ const data = await ctx.gql.global.request(GET_COUPON_BY_CODE, { code });
704
+ if (!data.getCouponByCode) return errorResult(`Coupon ${code} not found`);
705
+ return jsonResult(data.getCouponByCode);
706
+ } catch (error) {
707
+ return failure(ctx, "billing_coupons_get_by_code", "get coupon", error);
708
+ }
709
+ });
710
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_usage_dashboard")), {
711
+ title: "Usage Dashboard",
712
+ description: "Quota health and usage of a billing account: how many quotas are healthy, near or at their limit, the top quotas by usage, trends and recent activity.",
713
+ annotations: READ_ONLY,
714
+ inputSchema: {
715
+ account: z.string().optional().describe("Billing account ID (defaults to current)"),
716
+ period: z.enum([
717
+ "CURRENT_MONTH",
718
+ "LAST_7_DAYS",
719
+ "LAST_30_DAYS",
720
+ "LAST_90_DAYS",
721
+ "LAST_MONTH"
722
+ ]).optional().describe("Window (default LAST_30_DAYS)")
723
+ }
724
+ }, async ({ account, period }) => {
725
+ try {
726
+ const billingAccountId = await resolveBillingAccountId(ctx, account);
727
+ const data = await ctx.gql.global.request(GET_USAGE_DASHBOARD, {
728
+ billingAccountId,
729
+ period
730
+ });
731
+ return jsonResult(data.getUsageDashboard);
732
+ } catch (error) {
733
+ return failure(ctx, "billing_usage_dashboard", "read the usage dashboard", error);
734
+ }
735
+ });
736
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_affiliate_earnings")), {
737
+ title: "Affiliate Earnings",
738
+ description: "Earnings summary of a billing account: lifetime, available, pending, reserved and paid amounts, by category. Requesting a payout is not available here.",
739
+ annotations: READ_ONLY,
740
+ inputSchema: { account: z.string().optional().describe("Billing account ID (defaults to current)") }
741
+ }, async ({ account }) => {
742
+ try {
743
+ const billingAccountId = await resolveBillingAccountId(ctx, account);
744
+ const data = await ctx.gql.global.request(GET_EARNINGS_SUMMARY, { billingAccountId });
745
+ return jsonResult(data.myEarningsSummary);
746
+ } catch (error) {
747
+ return failure(ctx, "billing_affiliate_earnings", "read earnings", error);
748
+ }
749
+ });
750
+ server.registerTool(track(mcpToolName(ctx.productName, "billing_affiliate_payout_accounts")), {
751
+ title: "Payout Accounts",
752
+ description: "The payout accounts registered on a billing account (only the last 4 digits of an account number are returned). Adding one is not available here.",
753
+ annotations: READ_ONLY,
754
+ inputSchema: { account: z.string().optional().describe("Billing account ID (defaults to current)") }
755
+ }, async ({ account }) => {
756
+ try {
757
+ const billingAccountId = await resolveBillingAccountId(ctx, account);
758
+ const data = await ctx.gql.global.request(LIST_PAYOUT_ACCOUNTS, { billingAccountId });
759
+ return jsonResult(data.myPayoutAccounts);
760
+ } catch (error) {
761
+ return failure(ctx, "billing_affiliate_payout_accounts", "list payout accounts", error);
762
+ }
763
+ });
516
764
  }
517
765
 
518
766
  // src/modules/billing/index.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/modules/billing/operations.ts","../../../src/modules/billing/tools.ts","../../../src/modules/billing/index.ts"],"sourcesContent":["export const GET_DEFAULT_BILLING_ACCOUNT = `\n query GetDefaultBillingAccount {\n getDefaultBillingAccount {\n id creditAmount currency\n }\n }\n`;\n\nexport const GET_ACTIVE_SUBSCRIPTIONS = `\n query GetActiveSubscriptions($billingAccountId: ID!) {\n getActiveSubscriptions(billingAccountId: $billingAccountId) {\n id status seatCount nextBillingDate\n plan { name price currency }\n }\n }\n`;\n\nexport const GET_SUBSCRIPTION = `\n query GetSubscription($billingAccountId: ID!, $id: ID!) {\n getSubscription(billingAccountId: $billingAccountId, id: $id) {\n id status startDate endDate seatCount billingAccountId\n }\n }\n`;\n\nexport const UPDATE_SUBSCRIPTION_SEATS = `\n mutation UpdateSubscriptionSeats($input: UpdateSubscriptionSeatsInput!) {\n updateSubscriptionSeats(input: $input) {\n id seatCount lastSeatChangeAt\n }\n }\n`;\n\nexport const CANCEL_SUBSCRIPTION = `\n mutation CancelSubscription($input: CancelSubscriptionInput!) {\n cancelSubscription(input: $input) {\n id status canceledAt cancellationReason\n }\n }\n`;\n\n// BOFF-8183: the live supergraph exposes `PlansFilter` (no \"Input\" suffix);\n// `PlanFilterInput` is an mcp-libs artifact that the gateway rejects with\n// `Unknown type \"PlanFilterInput\"`. The filter is optional — we forward\n// it only when the caller actually provides one.\nexport const GET_ALL_PLANS = `\n query GetAllPlans($filter: PlansFilter) {\n getAllPlans(filter: $filter) {\n id name price currency duration pricingModel\n }\n }\n`;\n\nexport const GET_PLAN = `\n query GetPlan($id: ID!) {\n getPlan(id: $id) {\n id name price pricePerSeat minSeats maxSeats isActive\n }\n }\n`;\n\n// BOFF-8183 follow-up: same family as the plan filter — the live type is\n// `AddonsFilter` (no \"Input\" suffix). The `$limit` arg is supported and\n// forwarded as a connection-style cap.\nexport const GET_ALL_ADDONS = `\n query GetAllAddOns($filter: AddonsFilter, $limit: Int) {\n getAllAddOns(filter: $filter, limit: $limit) {\n id name price currency duration isActive\n }\n }\n`;\n\nexport const GET_PAGINATED_INVOICES = `\n query GetPaginatedInvoices($billingAccountId: ID!, $page: Int, $pageSize: Int) {\n getPaginatedInvoices(billingAccountId: $billingAccountId, page: $page, pageSize: $pageSize) {\n invoices { id invoiceNumber status total currency paidAt pdfUrl }\n totalCount hasMore\n }\n }\n`;\n\n// getInvoice, deletePaymentMethod and addPaymentMethod are all scoped to a\n// billing account on global-billing-svc, and deletePaymentMethod returns a\n// bare Boolean (BOFF-4413 supergraph contract).\nexport const GET_INVOICE = `\n query GetInvoice($billingAccountId: ID!, $id: ID!) {\n getInvoice(billingAccountId: $billingAccountId, id: $id) {\n id invoiceNumber status currency subtotal tax total amountPaid dueDate paidAt\n pdfUrl invoiceUrl\n items { description quantity unitPrice amount }\n }\n }\n`;\n\nexport const GET_PAYMENT_METHODS = `\n query GetPaymentMethods($billingAccountId: ID!) {\n getPaymentMethods(billingAccountId: $billingAccountId) {\n id type last4 expiryYear brand isDefault isVerified\n }\n }\n`;\n\nexport const ADD_PAYMENT_METHOD = `\n mutation AddPaymentMethod($input: CreatePaymentMethodInput!) {\n addPaymentMethod(input: $input) {\n id type isDefault isVerified\n }\n }\n`;\n\nexport const DELETE_PAYMENT_METHOD = `\n mutation DeletePaymentMethod($billingAccountId: ID!, $id: ID!) {\n deletePaymentMethod(billingAccountId: $billingAccountId, id: $id)\n }\n`;\n\nexport const GRANT_CREDITS = `\n mutation GrantCredits($input: GrantCreditsInput!) {\n grantCredits(input: $input) {\n id amount status type\n }\n }\n`;\n\nexport const REQUEST_CREDIT_WITHDRAWAL = `\n mutation RequestCreditWithdrawal($input: RequestCreditWithdrawalInput!) {\n requestCreditWithdrawal(input: $input) {\n id status requestedAmount currency createdAt\n }\n }\n`;\n\nexport const GET_PENDING_REFUNDS = `\n query GetPendingRefunds($page: Int, $pageSize: Int) {\n getPendingRefunds(page: $page, pageSize: $pageSize) {\n records { id amount status source createdAt }\n totalCount\n }\n }\n`;\n\n// Live alpha requires BOTH `billingAccountId` and `subscriptionId` for\n// `getAllQuotasOfSub`; passing only `subscriptionId` returned\n// \"Field getAllQuotasOfSub argument billingAccountId of type ID! is\n// required\". The MCP tool already takes `billingAccountId` as a required\n// arg — we just need to forward it.\nexport const GET_QUOTAS_OF_SUB = `\n query GetQuotas($billingAccountId: ID!, $subscriptionId: ID!) {\n getAllQuotasOfSub(billingAccountId: $billingAccountId, subscriptionId: $subscriptionId) {\n id name limits currentUsageSum reusable\n }\n }\n`;\n","/**\n * Billing module tools — subscriptions, plans, addons, invoices,\n * payment-methods, credits, refunds, quotas.\n *\n * Backend: ~/products/global/billing/global-billing-svc/.\n * Ported from cli-sdk/src/modules/billing/. The CLI's stdin/options become\n * MCP tool arguments. Browser-redirect commands (Stripe checkout) are not\n * present in the source; the closest analogue (`invoices download`) returns a\n * URL — exposed here as `billing_invoices_get_pdf_url`.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport {\n GET_DEFAULT_BILLING_ACCOUNT,\n GET_ACTIVE_SUBSCRIPTIONS,\n GET_SUBSCRIPTION,\n UPDATE_SUBSCRIPTION_SEATS,\n CANCEL_SUBSCRIPTION,\n GET_ALL_PLANS,\n GET_PLAN,\n GET_ALL_ADDONS,\n GET_PAGINATED_INVOICES,\n GET_INVOICE,\n GET_PAYMENT_METHODS,\n ADD_PAYMENT_METHOD,\n DELETE_PAYMENT_METHOD,\n GRANT_CREDITS,\n REQUEST_CREDIT_WITHDRAWAL,\n GET_PENDING_REFUNDS,\n GET_QUOTAS_OF_SUB,\n} from './operations.js';\n\ninterface SubRow {\n id: string;\n status?: string;\n seatCount?: number;\n nextBillingDate?: string;\n plan?: { name: string; price?: number; currency?: string };\n}\n\ninterface PlanRow {\n id: string;\n name: string;\n price?: number;\n currency?: string;\n duration?: string;\n pricingModel?: string;\n isActive?: boolean;\n}\n\ninterface InvoiceRow {\n id: string;\n invoiceNumber?: string;\n status?: string;\n total?: number;\n currency?: string;\n paidAt?: string;\n pdfUrl?: string;\n}\n\ninterface PaymentMethodRow {\n id: string;\n type: string;\n last4?: string;\n brand?: string;\n isDefault?: boolean;\n isVerified?: boolean;\n}\n\ninterface BillingAccountRow {\n id: string;\n creditAmount?: number;\n currency?: string;\n}\n\nasync function resolveBillingAccountId(\n ctx: McpContext,\n override: string | undefined,\n): Promise<string> {\n if (override !== undefined && override !== '') return override;\n const data = await ctx.gql.global.request<{\n getDefaultBillingAccount: BillingAccountRow | null;\n }>(GET_DEFAULT_BILLING_ACCOUNT);\n if (!data.getDefaultBillingAccount?.id) {\n throw new Error('No default billing account on file. Pass account explicitly.');\n }\n return data.getDefaultBillingAccount.id;\n}\n\nexport function registerBillingTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Subscriptions ──────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_list')),\n {\n title: 'List Subscriptions',\n description: 'List active subscriptions on a billing account (defaults to current).',\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getActiveSubscriptions: SubRow[] }>(\n GET_ACTIVE_SUBSCRIPTIONS,\n { billingAccountId },\n );\n return jsonResult(data.getActiveSubscriptions);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_list failed', { error: String(error) });\n return errorResult(\n `Failed to list subscriptions: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_get')),\n {\n title: 'Get Subscription',\n description:\n 'Get a subscription by ID. Live alpha requires BOTH `billingAccountId` and `id`; the missing `billingAccountId` was rejected with \"argument billingAccountId of type ID! is required\". The MCP tool forwards the default billing account id when the caller omits one.',\n inputSchema: {\n id: z.string().describe('Subscription ID'),\n billingAccountId: z\n .string()\n .optional()\n .describe(\n \"Billing account ID (defaults to the caller's default billing account when omitted)\",\n ),\n },\n },\n async ({ id, billingAccountId }) => {\n try {\n const accountId =\n billingAccountId ?? (await resolveBillingAccountId(ctx, billingAccountId));\n if (!accountId) {\n return errorResult(\n 'No billing account id; pass `billingAccountId` or ensure `getDefaultBillingAccount` is callable for the caller.',\n );\n }\n const data = await ctx.gql.global.request<{ getSubscription: SubRow | null }>(\n GET_SUBSCRIPTION,\n { billingAccountId: accountId, id },\n );\n if (!data.getSubscription) return errorResult(`Subscription ${id} not found`);\n return jsonResult(data.getSubscription);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_get failed', { error: String(error) });\n return errorResult(\n `Failed to get subscription: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_upgrade')),\n {\n title: 'Update Subscription Seats',\n description: 'Change the seat count on a subscription.',\n inputSchema: {\n id: z.string().describe('Subscription ID'),\n seats: z.number().describe('Target seat count'),\n },\n },\n async ({ id, seats }) => {\n try {\n const input: Record<string, unknown> = { subscriptionId: id, seatCount: seats };\n const data = await ctx.gql.global.request<{ updateSubscriptionSeats: SubRow }>(\n UPDATE_SUBSCRIPTION_SEATS,\n { input },\n );\n return jsonResult(data.updateSubscriptionSeats);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_upgrade failed', { error: String(error) });\n return errorResult(\n `Failed to update seats: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_cancel')),\n {\n title: 'Cancel Subscription',\n description: 'Cancel a subscription with an optional reason.',\n inputSchema: {\n id: z.string().describe('Subscription ID'),\n reason: z.string().optional().describe('Cancellation reason'),\n },\n },\n async ({ id, reason }) => {\n try {\n const input: Record<string, unknown> = { subscriptionId: id };\n if (reason !== undefined) input.reason = reason;\n const data = await ctx.gql.global.request<{ cancelSubscription: SubRow }>(\n CANCEL_SUBSCRIPTION,\n { input },\n );\n return jsonResult(data.cancelSubscription);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_cancel failed', { error: String(error) });\n return errorResult(\n `Failed to cancel subscription: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Plans ──────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_plans_list')),\n {\n title: 'List Plans',\n description: 'List available plans, optionally filtered by product.',\n inputSchema: {\n product: z.string().optional().describe('Product ID filter'),\n },\n },\n async ({ product }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (product !== undefined) filter.productId = product;\n const data = await ctx.gql.global.request<{ getAllPlans: PlanRow[] }>(GET_ALL_PLANS, {\n filter: Object.keys(filter).length ? filter : undefined,\n });\n return jsonResult(data.getAllPlans);\n } catch (error) {\n ctx.logger.error('billing_plans_list failed', { error: String(error) });\n return errorResult(\n `Failed to list plans: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_plans_get')),\n {\n title: 'Get Plan',\n description: 'Get a plan by ID.',\n inputSchema: { id: z.string().describe('Plan ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ getPlan: PlanRow | null }>(GET_PLAN, { id });\n if (!data.getPlan) return errorResult(`Plan ${id} not found`);\n return jsonResult(data.getPlan);\n } catch (error) {\n ctx.logger.error('billing_plans_get failed', { error: String(error) });\n return errorResult(\n `Failed to get plan: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Addons ─────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_addons_list')),\n {\n title: 'List Addons',\n description: 'List addons, optionally filtered by product.',\n inputSchema: {\n product: z.string().optional().describe('Product ID filter'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ product, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (product !== undefined) filter.productId = product;\n const data = await ctx.gql.global.request<{ getAllAddOns: PlanRow[] }>(GET_ALL_ADDONS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit,\n });\n return jsonResult(data.getAllAddOns);\n } catch (error) {\n ctx.logger.error('billing_addons_list failed', { error: String(error) });\n return errorResult(\n `Failed to list addons: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Invoices ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_invoices_list')),\n {\n title: 'List Invoices',\n description: 'Paginated list of invoices on a billing account.',\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n page: z.number().optional().describe('Page number (default 1)'),\n pageSize: z.number().optional().describe('Page size (default 20)'),\n },\n },\n async ({ account, page, pageSize }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{\n getPaginatedInvoices: { invoices: InvoiceRow[]; totalCount: number };\n }>(GET_PAGINATED_INVOICES, { billingAccountId, page, pageSize });\n return jsonResult(data.getPaginatedInvoices);\n } catch (error) {\n ctx.logger.error('billing_invoices_list failed', { error: String(error) });\n return errorResult(\n `Failed to list invoices: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_invoices_get')),\n {\n title: 'Get Invoice',\n description: 'Get an invoice by ID (on the given or default billing account).',\n inputSchema: {\n id: z.string().describe('Invoice ID'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ id, account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getInvoice: InvoiceRow | null }>(GET_INVOICE, {\n billingAccountId,\n id,\n });\n if (!data.getInvoice) return errorResult(`Invoice ${id} not found`);\n return jsonResult(data.getInvoice);\n } catch (error) {\n ctx.logger.error('billing_invoices_get failed', { error: String(error) });\n return errorResult(\n `Failed to get invoice: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // Browser-redirect analogue: returns the PDF URL for the LLM to share.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_invoices_get_pdf_url')),\n {\n title: 'Get Invoice PDF URL',\n description:\n 'Return the invoice PDF download URL. The actual PDF must be opened in a browser by the user.',\n inputSchema: {\n id: z.string().describe('Invoice ID'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ id, account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getInvoice: InvoiceRow | null }>(GET_INVOICE, {\n billingAccountId,\n id,\n });\n if (!data.getInvoice?.pdfUrl) return errorResult(`Invoice ${id} has no pdfUrl`);\n return jsonResult({ url: data.getInvoice.pdfUrl });\n } catch (error) {\n ctx.logger.error('billing_invoices_get_pdf_url failed', { error: String(error) });\n return errorResult(\n `Failed to fetch invoice URL: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Payment methods ────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_payment_methods_list')),\n {\n title: 'List Payment Methods',\n description: 'List payment methods on a billing account.',\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getPaymentMethods: PaymentMethodRow[] }>(\n GET_PAYMENT_METHODS,\n { billingAccountId },\n );\n return jsonResult(data.getPaymentMethods);\n } catch (error) {\n ctx.logger.error('billing_payment_methods_list failed', { error: String(error) });\n return errorResult(\n `Failed to list payment methods: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_payment_methods_add')),\n {\n title: 'Add Payment Method',\n description:\n 'Add a payment method (card metadata only — provider handles secrets). Use the provider checkout URL elsewhere for full card capture.',\n inputSchema: {\n type: z\n .enum([\n 'CREDIT_CARD',\n 'DEBIT_CARD',\n 'BANK_TRANSFER',\n 'NETBANKING',\n 'WALLET',\n 'PAYPAL',\n 'CRYPTO',\n ])\n .describe('Payment method type'),\n last4: z.string().describe('Last 4 digits / identifier'),\n brand: z.string().optional().describe('Brand (Visa, MasterCard, etc.)'),\n expiryMonth: z.number().optional().describe('Expiry month (1-12)'),\n expiryYear: z.number().optional().describe('Expiry year (4 digits)'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n isDefault: z.boolean().optional().describe('Make it the default'),\n },\n },\n async ({ type, last4, brand, expiryMonth, expiryYear, account, isDefault }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const input: Record<string, unknown> = {\n billingAccountId,\n type,\n last4,\n isDefault: isDefault === true,\n };\n if (brand !== undefined) input.brand = brand;\n if (expiryMonth !== undefined) input.expiryMonth = expiryMonth;\n if (expiryYear !== undefined) input.expiryYear = expiryYear;\n\n const data = await ctx.gql.global.request<{ addPaymentMethod: PaymentMethodRow }>(\n ADD_PAYMENT_METHOD,\n { input },\n );\n return jsonResult(data.addPaymentMethod);\n } catch (error) {\n ctx.logger.error('billing_payment_methods_add failed', { error: String(error) });\n return errorResult(\n `Failed to add payment method: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_payment_methods_remove')),\n {\n title: 'Remove Payment Method',\n description: 'Delete a payment method by ID (on the given or default billing account).',\n inputSchema: {\n id: z.string().describe('Payment method ID'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ id, account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ deletePaymentMethod: boolean }>(\n DELETE_PAYMENT_METHOD,\n { billingAccountId, id },\n );\n if (!data.deletePaymentMethod) {\n return errorResult(`Payment method ${id} was not removed`);\n }\n return jsonResult({ status: 'success', message: 'Payment method removed', id });\n } catch (error) {\n ctx.logger.error('billing_payment_methods_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove payment method: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Credits ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_credits_balance')),\n {\n title: 'Credit Balance',\n description: 'Show current credit balance on the default billing account.',\n inputSchema: {},\n },\n async () => {\n try {\n const data = await ctx.gql.global.request<{\n getDefaultBillingAccount: BillingAccountRow | null;\n }>(GET_DEFAULT_BILLING_ACCOUNT);\n return jsonResult(data.getDefaultBillingAccount);\n } catch (error) {\n ctx.logger.error('billing_credits_balance failed', { error: String(error) });\n return errorResult(\n `Failed to read balance: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_credits_grant')),\n {\n title: 'Grant Credits',\n description: 'Grant credits to a billing account (admin only).',\n inputSchema: {\n account: z.string().describe('Billing account ID'),\n amount: z.number().describe('Amount to grant'),\n reason: z.string().optional().describe('Reason for grant'),\n },\n },\n async ({ account, amount, reason }) => {\n try {\n const input: Record<string, unknown> = {\n billingAccountId: account,\n amount,\n reason: reason ?? 'mcp-grant',\n };\n await ctx.gql.global.request(GRANT_CREDITS, { input });\n return jsonResult({ status: 'success', message: 'Credits granted', amount, account });\n } catch (error) {\n ctx.logger.error('billing_credits_grant failed', { error: String(error) });\n return errorResult(\n `Failed to grant credits: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_credits_withdraw')),\n {\n title: 'Withdraw Credits',\n description: 'Request a credit withdrawal to a payout account.',\n inputSchema: {\n account: z.string().describe('Billing account ID'),\n amount: z.number().describe('Amount to withdraw'),\n payout: z.string().describe('Payout account ID'),\n },\n },\n async ({ account, amount, payout }) => {\n try {\n const input: Record<string, unknown> = {\n billingAccountId: account,\n creditAmount: amount,\n payoutAccountId: payout,\n };\n await ctx.gql.global.request(REQUEST_CREDIT_WITHDRAWAL, { input });\n return jsonResult({ status: 'success', message: 'Withdrawal requested', amount, account });\n } catch (error) {\n ctx.logger.error('billing_credits_withdraw failed', { error: String(error) });\n return errorResult(\n `Failed to request withdrawal: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Refunds ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_refunds_list')),\n {\n title: 'List Pending Refunds',\n description: 'List pending refund records (paginated).',\n inputSchema: {\n page: z.number().optional().describe('Page number (default 0)'),\n pageSize: z.number().optional().describe('Page size (default 20)'),\n },\n },\n async ({ page, pageSize }) => {\n try {\n const data = await ctx.gql.global.request<{\n getPendingRefunds: { records: Array<Record<string, unknown>>; totalCount: number };\n }>(GET_PENDING_REFUNDS, { page, pageSize });\n return jsonResult(data.getPendingRefunds);\n } catch (error) {\n ctx.logger.error('billing_refunds_list failed', { error: String(error) });\n return errorResult(\n `Failed to list refunds: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Quota ──────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_quota_list')),\n {\n title: 'List Subscription Quotas',\n description:\n 'Get all quotas for a subscription. Live alpha requires BOTH `billingAccountId` and `subscriptionId`; the missing `billingAccountId` was rejected with \"argument billingAccountId of type ID! is required\". The MCP tool falls back to the caller\\'s default billing account when the caller omits one.',\n inputSchema: {\n subscriptionId: z.string().describe('Subscription ID'),\n billingAccountId: z\n .string()\n .optional()\n .describe(\n \"Billing account ID (defaults to the caller's default billing account when omitted)\",\n ),\n },\n },\n async ({ subscriptionId, billingAccountId }) => {\n try {\n const accountId = await resolveBillingAccountId(ctx, billingAccountId);\n const data = await ctx.gql.global.request<{\n getAllQuotasOfSub: Array<Record<string, unknown>>;\n }>(GET_QUOTAS_OF_SUB, { billingAccountId: accountId, subscriptionId });\n return jsonResult(data.getAllQuotasOfSub);\n } catch (error) {\n ctx.logger.error('billing_quota_list failed', { error: String(error) });\n return errorResult(\n `Failed to list quotas: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Billing module — subscriptions, plans, addons, invoices, payment-methods,\n * credits, refunds, quotas. Backend: ~/products/global/billing/global-billing-svc/.\n * Ported from cli-sdk/src/modules/billing/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerBillingTools } from './tools.js';\n\nconst billingModule: McpModule = {\n id: 'billing',\n version: '0.0.1',\n displayName: 'Billing',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerBillingTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default billingModule;\n"],"mappings":";;;;AAAA,MAAa,8BAA8B;;;;;;;AAQ3C,MAAa,2BAA2B;;;;;;;;AASxC,MAAa,mBAAmB;;;;;;;AAQhC,MAAa,4BAA4B;;;;;;;AAQzC,MAAa,sBAAsB;;;;;;;AAYnC,MAAa,gBAAgB;;;;;;;AAQ7B,MAAa,WAAW;;;;;;;AAWxB,MAAa,iBAAiB;;;;;;;AAQ9B,MAAa,yBAAyB;;;;;;;;AAYtC,MAAa,cAAc;;;;;;;;;AAU3B,MAAa,sBAAsB;;;;;;;AAQnC,MAAa,qBAAqB;;;;;;;AAQlC,MAAa,wBAAwB;;;;;AAMrC,MAAa,gBAAgB;;;;;;;AAQ7B,MAAa,4BAA4B;;;;;;;AAQzC,MAAa,sBAAsB;;;;;;;;AAcnC,MAAa,oBAAoB;;;;;;;;;;;;;;;;;;;ACrEjC,eAAe,wBACb,KACA,UACiB;CACjB,IAAI,aAAa,UAAa,aAAa,IAAI,OAAO;CACtD,MAAM,OAAO,MAAM,IAAI,IAAI,OAAO,QAE/B,2BAA2B;CAC9B,IAAI,CAAC,KAAK,0BAA0B,IAClC,MAAM,IAAI,MAAM,8DAA8D;CAEhF,OAAO,KAAK,yBAAyB;AACvC;AAEA,SAAgB,qBACd,QACA,KACA,OACM;CAEN,OAAO,aACL,MAAM,YAAY,IAAI,aAAa,4BAA4B,CAAC,GAChE;EACE,OAAO;EACP,aAAa;EACb,aAAa,EACX,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,0CAA0C,EACpF;CACF,GACA,OAAO,EAAE,cAAc;EACrB,IAAI;GACF,MAAM,mBAAmB,MAAM,wBAAwB,KAAK,OAAO;GACnE,MAAM,OAAO,MAAM,IAAI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AAO;GACd,IAAI,OAAO,MAAM,6BAA6B,EAAE,OAAO,OAAO,KAAK,EAAE,CAAC;GACtE,OAAO,YACL,0BAA0B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACjF;EACF;CACF,CACF;AACF;;;AC5mBA,MAAM,gBAA2B;CAC/B,IAAI;CACJ,SAAS;CACT,aAAa;CACb,WAAW,CAAC,MAAM;CAClB,cAAc,EAAE,OAAO,CAAC,EAAE;CAE1B,SAAS,QAAmB,KAAqC;EAC/D,MAAM,QAAkB,CAAC;EACzB,MAAM,SAAS,MAAsB;GACnC,MAAM,KAAK,CAAC;GACZ,OAAO;EACT;EAEA,qBAAqB,QAAQ,KAAK,KAAK;EAEvC,OAAO;GAAE;GAAO,WAAW,CAAC;GAAG,SAAS,CAAC;EAAE;CAC7C;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/modules/billing/operations.ts","../../../src/modules/billing/tools.ts","../../../src/modules/billing/index.ts"],"sourcesContent":["export const GET_DEFAULT_BILLING_ACCOUNT = `\n query GetDefaultBillingAccount {\n getDefaultBillingAccount {\n id creditAmount currency\n }\n }\n`;\n\nexport const GET_ACTIVE_SUBSCRIPTIONS = `\n query GetActiveSubscriptions($billingAccountId: ID!) {\n getActiveSubscriptions(billingAccountId: $billingAccountId) {\n id status seatCount nextBillingDate\n plan { name price currency }\n }\n }\n`;\n\nexport const GET_SUBSCRIPTION = `\n query GetSubscription($billingAccountId: ID!, $id: ID!) {\n getSubscription(billingAccountId: $billingAccountId, id: $id) {\n id status startDate endDate seatCount billingAccountId\n }\n }\n`;\n\nexport const UPDATE_SUBSCRIPTION_SEATS = `\n mutation UpdateSubscriptionSeats($input: UpdateSubscriptionSeatsInput!) {\n updateSubscriptionSeats(input: $input) {\n id seatCount lastSeatChangeAt\n }\n }\n`;\n\nexport const CANCEL_SUBSCRIPTION = `\n mutation CancelSubscription($input: CancelSubscriptionInput!) {\n cancelSubscription(input: $input) {\n id status canceledAt cancellationReason\n }\n }\n`;\n\n// BOFF-8183: the live supergraph exposes `PlansFilter` (no \"Input\" suffix);\n// `PlanFilterInput` is an mcp-libs artifact that the gateway rejects with\n// `Unknown type \"PlanFilterInput\"`. The filter is optional — we forward\n// it only when the caller actually provides one.\nexport const GET_ALL_PLANS = `\n query GetAllPlans($filter: PlansFilter) {\n getAllPlans(filter: $filter) {\n id name price currency duration pricingModel\n }\n }\n`;\n\nexport const GET_PLAN = `\n query GetPlan($id: ID!) {\n getPlan(id: $id) {\n id name price pricePerSeat minSeats maxSeats isActive\n }\n }\n`;\n\n// BOFF-8183 follow-up: same family as the plan filter — the live type is\n// `AddonsFilter` (no \"Input\" suffix). The `$limit` arg is supported and\n// forwarded as a connection-style cap.\nexport const GET_ALL_ADDONS = `\n query GetAllAddOns($filter: AddonsFilter, $limit: Int) {\n getAllAddOns(filter: $filter, limit: $limit) {\n id name price currency duration isActive\n }\n }\n`;\n\nexport const GET_PAGINATED_INVOICES = `\n query GetPaginatedInvoices($billingAccountId: ID!, $page: Int, $pageSize: Int) {\n getPaginatedInvoices(billingAccountId: $billingAccountId, page: $page, pageSize: $pageSize) {\n invoices { id invoiceNumber status total currency paidAt pdfUrl }\n totalCount hasMore\n }\n }\n`;\n\n// getInvoice, deletePaymentMethod and addPaymentMethod are all scoped to a\n// billing account on global-billing-svc, and deletePaymentMethod returns a\n// bare Boolean (BOFF-4413 supergraph contract).\nexport const GET_INVOICE = `\n query GetInvoice($billingAccountId: ID!, $id: ID!) {\n getInvoice(billingAccountId: $billingAccountId, id: $id) {\n id invoiceNumber status currency subtotal tax total amountPaid dueDate paidAt\n pdfUrl invoiceUrl\n items { description quantity unitPrice amount }\n }\n }\n`;\n\nexport const GET_PAYMENT_METHODS = `\n query GetPaymentMethods($billingAccountId: ID!) {\n getPaymentMethods(billingAccountId: $billingAccountId) {\n id type last4 expiryYear brand isDefault isVerified\n }\n }\n`;\n\nexport const ADD_PAYMENT_METHOD = `\n mutation AddPaymentMethod($input: CreatePaymentMethodInput!) {\n addPaymentMethod(input: $input) {\n id type isDefault isVerified\n }\n }\n`;\n\nexport const DELETE_PAYMENT_METHOD = `\n mutation DeletePaymentMethod($billingAccountId: ID!, $id: ID!) {\n deletePaymentMethod(billingAccountId: $billingAccountId, id: $id)\n }\n`;\n\nexport const GRANT_CREDITS = `\n mutation GrantCredits($input: GrantCreditsInput!) {\n grantCredits(input: $input) {\n id amount status type\n }\n }\n`;\n\nexport const REQUEST_CREDIT_WITHDRAWAL = `\n mutation RequestCreditWithdrawal($input: RequestCreditWithdrawalInput!) {\n requestCreditWithdrawal(input: $input) {\n id status requestedAmount currency createdAt\n }\n }\n`;\n\nexport const GET_PENDING_REFUNDS = `\n query GetPendingRefunds($page: Int, $pageSize: Int) {\n getPendingRefunds(page: $page, pageSize: $pageSize) {\n records { id amount status source createdAt }\n totalCount\n }\n }\n`;\n\n// Live alpha requires BOTH `billingAccountId` and `subscriptionId` for\n// `getAllQuotasOfSub`; passing only `subscriptionId` returned\n// \"Field getAllQuotasOfSub argument billingAccountId of type ID! is\n// required\". The MCP tool already takes `billingAccountId` as a required\n// arg — we just need to forward it.\nexport const GET_QUOTAS_OF_SUB = `\n query GetQuotas($billingAccountId: ID!, $subscriptionId: ID!) {\n getAllQuotasOfSub(billingAccountId: $billingAccountId, subscriptionId: $subscriptionId) {\n id name limits currentUsageSum reusable\n }\n }\n`;\n\n// ── BOFF-10887: reads from the sdk-libs-node billing module ──────────────\n// Copied from sdk-libs-node src/modules/billing/operations.ts (same operation\n// names), which validates them against the production global supergraph.\n\nconst ADDON_FIELDS = `\n id name price currency duration productId: productID isActive\n requiresPaidSubscription createdAt updatedAt\n`;\n\n/** There is no single-addon query; `getSelectedAddons` resolves a list of ids. */\nexport const GET_SELECTED_ADDONS = `\n query GetSelectedAddons($addonIDs: [String!]!) {\n getSelectedAddons(addonIDs: $addonIDs) { ${ADDON_FIELDS} }\n }\n`;\n\nconst COUPON_FIELDS = `\n id code name description type value currency scope status\n validFrom validUntil maxTotalUses maxUsesPerUser currentUses\n minPurchaseAmount maxDiscountAmount applicableProductIds\n campaignId metadata createdAt updatedAt\n`;\n\n// The three coupon reads require billing `manage` at global scope (admins).\nexport const LIST_COUPONS = `\n query ListCoupons($filter: CouponFilterInput, $limit: Int, $offset: Int) {\n listCoupons(filter: $filter, limit: $limit, offset: $offset) {\n coupons { ${COUPON_FIELDS} }\n total hasMore\n }\n }\n`;\n\n/** The subgraph takes the coupon id; `GET_COUPON_BY_CODE` resolves a code. */\nexport const GET_COUPON = `\n query GetCoupon($id: ID!) {\n getCoupon(id: $id) { ${COUPON_FIELDS} }\n }\n`;\n\nexport const GET_COUPON_BY_CODE = `\n query GetCouponByCode($code: String!) {\n getCouponByCode(code: $code) { ${COUPON_FIELDS} }\n }\n`;\n\n/** Requires billingAccountId; the period defaults server-side (LAST_30_DAYS). */\nexport const GET_USAGE_DASHBOARD = `\n query GetUsageDashboard($billingAccountId: ID!, $period: AnalyticsPeriod) {\n getUsageDashboard(billingAccountId: $billingAccountId, period: $period) {\n totalQuotas activeQuotas healthyQuotas warningQuotas criticalQuotas\n exhaustedQuotas totalUsage\n overallTrends { averageDailyUsage growthRate predictedUsage }\n topUsageByQuota { quotaId quotaName usage limit percentage status }\n recentActivities { id quotaName amount description tags timestamp }\n }\n }\n`;\n\nexport const GET_EARNINGS_SUMMARY = `\n query MyEarningsSummary($billingAccountId: ID!) {\n myEarningsSummary(billingAccountId: $billingAccountId) {\n totalLifetimeAmount availableAmount pendingAmount reservedAmount\n paidAmount reversedAmount moneyAmount creditsAmount\n categoryBreakdown { category amount count }\n }\n }\n`;\n\nconst PAYOUT_ACCOUNT_FIELDS = `\n id billingAccountId type label displayName accountLast4 country currency\n providerPreference status isDefault isActive verifiedAt metadata\n createdAt updatedAt\n`;\n\nexport const LIST_PAYOUT_ACCOUNTS = `\n query MyPayoutAccounts($billingAccountId: ID!) {\n myPayoutAccounts(billingAccountId: $billingAccountId) { ${PAYOUT_ACCOUNT_FIELDS} }\n }\n`;\n","/**\n * Billing module tools — subscriptions, plans, addons, invoices,\n * payment-methods, credits, refunds, quotas.\n *\n * Backend: ~/products/global/billing/global-billing-svc/.\n * Ported from cli-sdk/src/modules/billing/. The CLI's stdin/options become\n * MCP tool arguments. Browser-redirect commands (Stripe checkout) are not\n * present in the source; the closest analogue (`invoices download`) returns a\n * URL — exposed here as `billing_invoices_get_pdf_url`.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport {\n jsonResult,\n errorResult,\n mcpToolName,\n type McpContext,\n type ToolAnnotations,\n} from '../../core/index.js';\nimport {\n GET_DEFAULT_BILLING_ACCOUNT,\n GET_ACTIVE_SUBSCRIPTIONS,\n GET_SUBSCRIPTION,\n UPDATE_SUBSCRIPTION_SEATS,\n CANCEL_SUBSCRIPTION,\n GET_ALL_PLANS,\n GET_PLAN,\n GET_ALL_ADDONS,\n GET_PAGINATED_INVOICES,\n GET_INVOICE,\n GET_PAYMENT_METHODS,\n ADD_PAYMENT_METHOD,\n DELETE_PAYMENT_METHOD,\n GRANT_CREDITS,\n REQUEST_CREDIT_WITHDRAWAL,\n GET_PENDING_REFUNDS,\n GET_QUOTAS_OF_SUB,\n GET_SELECTED_ADDONS,\n LIST_COUPONS,\n GET_COUPON,\n GET_COUPON_BY_CODE,\n GET_USAGE_DASHBOARD,\n GET_EARNINGS_SUMMARY,\n LIST_PAYOUT_ACCOUNTS,\n} from './operations.js';\n\ninterface SubRow {\n id: string;\n status?: string;\n seatCount?: number;\n nextBillingDate?: string;\n plan?: { name: string; price?: number; currency?: string };\n}\n\ninterface PlanRow {\n id: string;\n name: string;\n price?: number;\n currency?: string;\n duration?: string;\n pricingModel?: string;\n isActive?: boolean;\n}\n\ninterface InvoiceRow {\n id: string;\n invoiceNumber?: string;\n status?: string;\n total?: number;\n currency?: string;\n paidAt?: string;\n pdfUrl?: string;\n}\n\ninterface PaymentMethodRow {\n id: string;\n type: string;\n last4?: string;\n brand?: string;\n isDefault?: boolean;\n isVerified?: boolean;\n}\n\ninterface BillingAccountRow {\n id: string;\n creditAmount?: number;\n currency?: string;\n}\n\nasync function resolveBillingAccountId(\n ctx: McpContext,\n override: string | undefined,\n): Promise<string> {\n if (override !== undefined && override !== '') return override;\n const data = await ctx.gql.global.request<{\n getDefaultBillingAccount: BillingAccountRow | null;\n }>(GET_DEFAULT_BILLING_ACCOUNT);\n if (!data.getDefaultBillingAccount?.id) {\n throw new Error('No default billing account on file. Pass account explicitly.');\n }\n return data.getDefaultBillingAccount.id;\n}\n\n/** A read: no state changes, nothing leaves Burdenoff. */\nconst READ_ONLY: ToolAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n openWorldHint: false,\n};\n\n/**\n * Moves money, ends a paid service or deletes a payment method. Declared\n * explicitly because the name-based inference misses most of these verbs\n * (upgrade, cancel, grant, withdraw), and a shell that enforces destructive\n * confirmation must ask before any of them runs (BOFF-10887; same defect\n * class as store_cart_checkout in BOFF-10861).\n */\nconst MONEY_MOVING: ToolAnnotations = {\n readOnlyHint: false,\n destructiveHint: true,\n openWorldHint: true,\n};\n\nfunction failure(ctx: McpContext, tool: string, what: string, error: unknown) {\n ctx.logger.error(`${tool} failed`, { error: String(error) });\n return errorResult(\n `Failed to ${what}: ${error instanceof Error ? error.message : String(error)}`,\n );\n}\n\nexport function registerBillingTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Subscriptions ──────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_list')),\n {\n title: 'List Subscriptions',\n description: 'List active subscriptions on a billing account (defaults to current).',\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getActiveSubscriptions: SubRow[] }>(\n GET_ACTIVE_SUBSCRIPTIONS,\n { billingAccountId },\n );\n return jsonResult(data.getActiveSubscriptions);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_list failed', { error: String(error) });\n return errorResult(\n `Failed to list subscriptions: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_get')),\n {\n title: 'Get Subscription',\n description:\n 'Get a subscription by ID. Live alpha requires BOTH `billingAccountId` and `id`; the missing `billingAccountId` was rejected with \"argument billingAccountId of type ID! is required\". The MCP tool forwards the default billing account id when the caller omits one.',\n inputSchema: {\n id: z.string().describe('Subscription ID'),\n billingAccountId: z\n .string()\n .optional()\n .describe(\n \"Billing account ID (defaults to the caller's default billing account when omitted)\",\n ),\n },\n },\n async ({ id, billingAccountId }) => {\n try {\n const accountId =\n billingAccountId ?? (await resolveBillingAccountId(ctx, billingAccountId));\n if (!accountId) {\n return errorResult(\n 'No billing account id; pass `billingAccountId` or ensure `getDefaultBillingAccount` is callable for the caller.',\n );\n }\n const data = await ctx.gql.global.request<{ getSubscription: SubRow | null }>(\n GET_SUBSCRIPTION,\n { billingAccountId: accountId, id },\n );\n if (!data.getSubscription) return errorResult(`Subscription ${id} not found`);\n return jsonResult(data.getSubscription);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_get failed', { error: String(error) });\n return errorResult(\n `Failed to get subscription: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_upgrade')),\n {\n title: 'Update Subscription Seats',\n description: 'Change the seat count on a subscription.',\n annotations: MONEY_MOVING,\n inputSchema: {\n id: z.string().describe('Subscription ID'),\n seats: z.number().describe('Target seat count'),\n },\n },\n async ({ id, seats }) => {\n try {\n const input: Record<string, unknown> = { subscriptionId: id, seatCount: seats };\n const data = await ctx.gql.global.request<{ updateSubscriptionSeats: SubRow }>(\n UPDATE_SUBSCRIPTION_SEATS,\n { input },\n );\n return jsonResult(data.updateSubscriptionSeats);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_upgrade failed', { error: String(error) });\n return errorResult(\n `Failed to update seats: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_subscriptions_cancel')),\n {\n title: 'Cancel Subscription',\n description: 'Cancel a subscription with an optional reason.',\n annotations: MONEY_MOVING,\n inputSchema: {\n id: z.string().describe('Subscription ID'),\n reason: z.string().optional().describe('Cancellation reason'),\n },\n },\n async ({ id, reason }) => {\n try {\n const input: Record<string, unknown> = { subscriptionId: id };\n if (reason !== undefined) input.reason = reason;\n const data = await ctx.gql.global.request<{ cancelSubscription: SubRow }>(\n CANCEL_SUBSCRIPTION,\n { input },\n );\n return jsonResult(data.cancelSubscription);\n } catch (error) {\n ctx.logger.error('billing_subscriptions_cancel failed', { error: String(error) });\n return errorResult(\n `Failed to cancel subscription: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Plans ──────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_plans_list')),\n {\n title: 'List Plans',\n description: 'List available plans, optionally filtered by product.',\n inputSchema: {\n product: z.string().optional().describe('Product ID filter'),\n },\n },\n async ({ product }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (product !== undefined) filter.productId = product;\n const data = await ctx.gql.global.request<{ getAllPlans: PlanRow[] }>(GET_ALL_PLANS, {\n filter: Object.keys(filter).length ? filter : undefined,\n });\n return jsonResult(data.getAllPlans);\n } catch (error) {\n ctx.logger.error('billing_plans_list failed', { error: String(error) });\n return errorResult(\n `Failed to list plans: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_plans_get')),\n {\n title: 'Get Plan',\n description: 'Get a plan by ID.',\n inputSchema: { id: z.string().describe('Plan ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ getPlan: PlanRow | null }>(GET_PLAN, { id });\n if (!data.getPlan) return errorResult(`Plan ${id} not found`);\n return jsonResult(data.getPlan);\n } catch (error) {\n ctx.logger.error('billing_plans_get failed', { error: String(error) });\n return errorResult(\n `Failed to get plan: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Addons ─────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_addons_list')),\n {\n title: 'List Addons',\n description: 'List addons, optionally filtered by product.',\n inputSchema: {\n product: z.string().optional().describe('Product ID filter'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ product, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (product !== undefined) filter.productId = product;\n const data = await ctx.gql.global.request<{ getAllAddOns: PlanRow[] }>(GET_ALL_ADDONS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit,\n });\n return jsonResult(data.getAllAddOns);\n } catch (error) {\n ctx.logger.error('billing_addons_list failed', { error: String(error) });\n return errorResult(\n `Failed to list addons: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Invoices ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_invoices_list')),\n {\n title: 'List Invoices',\n description: 'Paginated list of invoices on a billing account.',\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n page: z.number().optional().describe('Page number (default 1)'),\n pageSize: z.number().optional().describe('Page size (default 20)'),\n },\n },\n async ({ account, page, pageSize }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{\n getPaginatedInvoices: { invoices: InvoiceRow[]; totalCount: number };\n }>(GET_PAGINATED_INVOICES, { billingAccountId, page, pageSize });\n return jsonResult(data.getPaginatedInvoices);\n } catch (error) {\n ctx.logger.error('billing_invoices_list failed', { error: String(error) });\n return errorResult(\n `Failed to list invoices: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_invoices_get')),\n {\n title: 'Get Invoice',\n description: 'Get an invoice by ID (on the given or default billing account).',\n inputSchema: {\n id: z.string().describe('Invoice ID'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ id, account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getInvoice: InvoiceRow | null }>(GET_INVOICE, {\n billingAccountId,\n id,\n });\n if (!data.getInvoice) return errorResult(`Invoice ${id} not found`);\n return jsonResult(data.getInvoice);\n } catch (error) {\n ctx.logger.error('billing_invoices_get failed', { error: String(error) });\n return errorResult(\n `Failed to get invoice: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // Browser-redirect analogue: returns the PDF URL for the LLM to share.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_invoices_get_pdf_url')),\n {\n title: 'Get Invoice PDF URL',\n description:\n 'Return the invoice PDF download URL. The actual PDF must be opened in a browser by the user.',\n inputSchema: {\n id: z.string().describe('Invoice ID'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ id, account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getInvoice: InvoiceRow | null }>(GET_INVOICE, {\n billingAccountId,\n id,\n });\n if (!data.getInvoice?.pdfUrl) return errorResult(`Invoice ${id} has no pdfUrl`);\n return jsonResult({ url: data.getInvoice.pdfUrl });\n } catch (error) {\n ctx.logger.error('billing_invoices_get_pdf_url failed', { error: String(error) });\n return errorResult(\n `Failed to fetch invoice URL: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Payment methods ────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_payment_methods_list')),\n {\n title: 'List Payment Methods',\n description: 'List payment methods on a billing account.',\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getPaymentMethods: PaymentMethodRow[] }>(\n GET_PAYMENT_METHODS,\n { billingAccountId },\n );\n return jsonResult(data.getPaymentMethods);\n } catch (error) {\n ctx.logger.error('billing_payment_methods_list failed', { error: String(error) });\n return errorResult(\n `Failed to list payment methods: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_payment_methods_add')),\n {\n title: 'Add Payment Method',\n description:\n 'Add a payment method (card metadata only — provider handles secrets). Use the provider checkout URL elsewhere for full card capture.',\n annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },\n inputSchema: {\n type: z\n .enum([\n 'CREDIT_CARD',\n 'DEBIT_CARD',\n 'BANK_TRANSFER',\n 'NETBANKING',\n 'WALLET',\n 'PAYPAL',\n 'CRYPTO',\n ])\n .describe('Payment method type'),\n last4: z.string().describe('Last 4 digits / identifier'),\n brand: z.string().optional().describe('Brand (Visa, MasterCard, etc.)'),\n expiryMonth: z.number().optional().describe('Expiry month (1-12)'),\n expiryYear: z.number().optional().describe('Expiry year (4 digits)'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n isDefault: z.boolean().optional().describe('Make it the default'),\n },\n },\n async ({ type, last4, brand, expiryMonth, expiryYear, account, isDefault }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const input: Record<string, unknown> = {\n billingAccountId,\n type,\n last4,\n isDefault: isDefault === true,\n };\n if (brand !== undefined) input.brand = brand;\n if (expiryMonth !== undefined) input.expiryMonth = expiryMonth;\n if (expiryYear !== undefined) input.expiryYear = expiryYear;\n\n const data = await ctx.gql.global.request<{ addPaymentMethod: PaymentMethodRow }>(\n ADD_PAYMENT_METHOD,\n { input },\n );\n return jsonResult(data.addPaymentMethod);\n } catch (error) {\n ctx.logger.error('billing_payment_methods_add failed', { error: String(error) });\n return errorResult(\n `Failed to add payment method: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_payment_methods_remove')),\n {\n title: 'Remove Payment Method',\n description: 'Delete a payment method by ID (on the given or default billing account).',\n annotations: MONEY_MOVING,\n inputSchema: {\n id: z.string().describe('Payment method ID'),\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ id, account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ deletePaymentMethod: boolean }>(\n DELETE_PAYMENT_METHOD,\n { billingAccountId, id },\n );\n if (!data.deletePaymentMethod) {\n return errorResult(`Payment method ${id} was not removed`);\n }\n return jsonResult({ status: 'success', message: 'Payment method removed', id });\n } catch (error) {\n ctx.logger.error('billing_payment_methods_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove payment method: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Credits ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_credits_balance')),\n {\n title: 'Credit Balance',\n description: 'Show current credit balance on the default billing account.',\n inputSchema: {},\n },\n async () => {\n try {\n const data = await ctx.gql.global.request<{\n getDefaultBillingAccount: BillingAccountRow | null;\n }>(GET_DEFAULT_BILLING_ACCOUNT);\n return jsonResult(data.getDefaultBillingAccount);\n } catch (error) {\n ctx.logger.error('billing_credits_balance failed', { error: String(error) });\n return errorResult(\n `Failed to read balance: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_credits_grant')),\n {\n title: 'Grant Credits',\n description: 'Grant credits to a billing account (admin only).',\n annotations: MONEY_MOVING,\n inputSchema: {\n account: z.string().describe('Billing account ID'),\n amount: z.number().describe('Amount to grant'),\n reason: z.string().optional().describe('Reason for grant'),\n },\n },\n async ({ account, amount, reason }) => {\n try {\n const input: Record<string, unknown> = {\n billingAccountId: account,\n amount,\n reason: reason ?? 'mcp-grant',\n };\n await ctx.gql.global.request(GRANT_CREDITS, { input });\n return jsonResult({ status: 'success', message: 'Credits granted', amount, account });\n } catch (error) {\n ctx.logger.error('billing_credits_grant failed', { error: String(error) });\n return errorResult(\n `Failed to grant credits: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_credits_withdraw')),\n {\n title: 'Withdraw Credits',\n description: 'Request a credit withdrawal to a payout account.',\n annotations: MONEY_MOVING,\n inputSchema: {\n account: z.string().describe('Billing account ID'),\n amount: z.number().describe('Amount to withdraw'),\n payout: z.string().describe('Payout account ID'),\n },\n },\n async ({ account, amount, payout }) => {\n try {\n const input: Record<string, unknown> = {\n billingAccountId: account,\n creditAmount: amount,\n payoutAccountId: payout,\n };\n await ctx.gql.global.request(REQUEST_CREDIT_WITHDRAWAL, { input });\n return jsonResult({ status: 'success', message: 'Withdrawal requested', amount, account });\n } catch (error) {\n ctx.logger.error('billing_credits_withdraw failed', { error: String(error) });\n return errorResult(\n `Failed to request withdrawal: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Refunds ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_refunds_list')),\n {\n title: 'List Pending Refunds',\n description: 'List pending refund records (paginated).',\n inputSchema: {\n page: z.number().optional().describe('Page number (default 0)'),\n pageSize: z.number().optional().describe('Page size (default 20)'),\n },\n },\n async ({ page, pageSize }) => {\n try {\n const data = await ctx.gql.global.request<{\n getPendingRefunds: { records: Array<Record<string, unknown>>; totalCount: number };\n }>(GET_PENDING_REFUNDS, { page, pageSize });\n return jsonResult(data.getPendingRefunds);\n } catch (error) {\n ctx.logger.error('billing_refunds_list failed', { error: String(error) });\n return errorResult(\n `Failed to list refunds: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Quota ──────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_quota_list')),\n {\n title: 'List Subscription Quotas',\n description:\n 'Get all quotas for a subscription. Live alpha requires BOTH `billingAccountId` and `subscriptionId`; the missing `billingAccountId` was rejected with \"argument billingAccountId of type ID! is required\". The MCP tool falls back to the caller\\'s default billing account when the caller omits one.',\n inputSchema: {\n subscriptionId: z.string().describe('Subscription ID'),\n billingAccountId: z\n .string()\n .optional()\n .describe(\n \"Billing account ID (defaults to the caller's default billing account when omitted)\",\n ),\n },\n },\n async ({ subscriptionId, billingAccountId }) => {\n try {\n const accountId = await resolveBillingAccountId(ctx, billingAccountId);\n const data = await ctx.gql.global.request<{\n getAllQuotasOfSub: Array<Record<string, unknown>>;\n }>(GET_QUOTAS_OF_SUB, { billingAccountId: accountId, subscriptionId });\n return jsonResult(data.getAllQuotasOfSub);\n } catch (error) {\n ctx.logger.error('billing_quota_list failed', { error: String(error) });\n return errorResult(\n `Failed to list quotas: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── BOFF-10887: reads the SDK added in its 2026-11-02 wave ──────────────\n // Money-moving SDK operations (coupons.create/update, credits.spend,\n // affiliate.addPayoutAccount/requestPayout) are deliberately not tools; the\n // reasons are in .parity-allowlist.yaml.\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_addons_get')),\n {\n title: 'Get Addon',\n description: 'Get one addon by ID.',\n annotations: READ_ONLY,\n inputSchema: { id: z.string().min(1).describe('Addon ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ getSelectedAddons: PlanRow[] }>(\n GET_SELECTED_ADDONS,\n { addonIDs: [id] },\n );\n const addon = data.getSelectedAddons.find((row) => row.id === id);\n if (!addon) return errorResult(`Addon ${id} not found`);\n return jsonResult(addon);\n } catch (error) {\n return failure(ctx, 'billing_addons_get', 'get addon', error);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_addons_get_many')),\n {\n title: 'Get Addons',\n description: 'Get several addons by ID in one call. IDs that do not exist are left out.',\n annotations: READ_ONLY,\n inputSchema: {\n ids: z.array(z.string().min(1)).min(1).max(100).describe('Addon IDs (1-100)'),\n },\n },\n async ({ ids }) => {\n try {\n const data = await ctx.gql.global.request<{ getSelectedAddons: PlanRow[] }>(\n GET_SELECTED_ADDONS,\n { addonIDs: ids },\n );\n return jsonResult(data.getSelectedAddons);\n } catch (error) {\n return failure(ctx, 'billing_addons_get_many', 'get addons', error);\n }\n },\n );\n\n // Coupon reads need billing `manage` at global scope; the gateway refuses\n // everyone else.\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_coupons_list')),\n {\n title: 'List Coupons',\n description:\n 'List coupons, optionally filtered (billing admins only). Creating or changing a coupon is not available here.',\n annotations: READ_ONLY,\n inputSchema: {\n status: z.enum(['ACTIVE', 'DEPLETED', 'EXPIRED', 'INACTIVE']).optional(),\n type: z.enum(['FIXED_AMOUNT', 'FREE_SHIPPING', 'PERCENTAGE']).optional(),\n scope: z.enum(['CAMPAIGN', 'GENERIC', 'REFERRAL', 'USER_SPECIFIC']).optional(),\n campaignId: z.string().optional().describe('Only this campaign'),\n search: z.string().optional().describe('Search code and name'),\n limit: z.number().int().min(1).max(200).optional().describe('Page size (default 50)'),\n offset: z.number().int().min(0).optional().describe('Offset (default 0)'),\n },\n },\n async ({ limit, offset, ...filterArgs }) => {\n try {\n const filter: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(filterArgs)) {\n if (value !== undefined) filter[key] = value;\n }\n const data = await ctx.gql.global.request<{ listCoupons: unknown }>(LIST_COUPONS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit,\n offset,\n });\n return jsonResult(data.listCoupons);\n } catch (error) {\n return failure(ctx, 'billing_coupons_list', 'list coupons', error);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_coupons_get')),\n {\n title: 'Get Coupon',\n description:\n 'Get a coupon by its ID (billing admins only). Use billing_coupons_get_by_code for a code.',\n annotations: READ_ONLY,\n inputSchema: { id: z.string().min(1).describe('Coupon ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ getCoupon: unknown }>(GET_COUPON, { id });\n if (!data.getCoupon) return errorResult(`Coupon ${id} not found`);\n return jsonResult(data.getCoupon);\n } catch (error) {\n return failure(ctx, 'billing_coupons_get', 'get coupon', error);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_coupons_get_by_code')),\n {\n title: 'Get Coupon By Code',\n description: 'Get a coupon by the code customers enter (billing admins only).',\n annotations: READ_ONLY,\n inputSchema: { code: z.string().min(1).describe('Coupon code') },\n },\n async ({ code }) => {\n try {\n const data = await ctx.gql.global.request<{ getCouponByCode: unknown }>(\n GET_COUPON_BY_CODE,\n { code },\n );\n if (!data.getCouponByCode) return errorResult(`Coupon ${code} not found`);\n return jsonResult(data.getCouponByCode);\n } catch (error) {\n return failure(ctx, 'billing_coupons_get_by_code', 'get coupon', error);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_usage_dashboard')),\n {\n title: 'Usage Dashboard',\n description:\n 'Quota health and usage of a billing account: how many quotas are healthy, near or at their limit, the top quotas by usage, trends and recent activity.',\n annotations: READ_ONLY,\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n period: z\n .enum(['CURRENT_MONTH', 'LAST_7_DAYS', 'LAST_30_DAYS', 'LAST_90_DAYS', 'LAST_MONTH'])\n .optional()\n .describe('Window (default LAST_30_DAYS)'),\n },\n },\n async ({ account, period }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ getUsageDashboard: unknown }>(\n GET_USAGE_DASHBOARD,\n { billingAccountId, period },\n );\n return jsonResult(data.getUsageDashboard);\n } catch (error) {\n return failure(ctx, 'billing_usage_dashboard', 'read the usage dashboard', error);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_affiliate_earnings')),\n {\n title: 'Affiliate Earnings',\n description:\n 'Earnings summary of a billing account: lifetime, available, pending, reserved and paid amounts, by category. Requesting a payout is not available here.',\n annotations: READ_ONLY,\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ myEarningsSummary: unknown }>(\n GET_EARNINGS_SUMMARY,\n { billingAccountId },\n );\n return jsonResult(data.myEarningsSummary);\n } catch (error) {\n return failure(ctx, 'billing_affiliate_earnings', 'read earnings', error);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'billing_affiliate_payout_accounts')),\n {\n title: 'Payout Accounts',\n description:\n 'The payout accounts registered on a billing account (only the last 4 digits of an account number are returned). Adding one is not available here.',\n annotations: READ_ONLY,\n inputSchema: {\n account: z.string().optional().describe('Billing account ID (defaults to current)'),\n },\n },\n async ({ account }) => {\n try {\n const billingAccountId = await resolveBillingAccountId(ctx, account);\n const data = await ctx.gql.global.request<{ myPayoutAccounts: unknown }>(\n LIST_PAYOUT_ACCOUNTS,\n { billingAccountId },\n );\n return jsonResult(data.myPayoutAccounts);\n } catch (error) {\n return failure(ctx, 'billing_affiliate_payout_accounts', 'list payout accounts', error);\n }\n },\n );\n}\n","/**\n * Billing module — subscriptions, plans, addons, invoices, payment-methods,\n * credits, refunds, quotas. Backend: ~/products/global/billing/global-billing-svc/.\n * Ported from cli-sdk/src/modules/billing/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerBillingTools } from './tools.js';\n\nconst billingModule: McpModule = {\n id: 'billing',\n version: '0.0.1',\n displayName: 'Billing',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerBillingTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default billingModule;\n"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YAAY,IAAI,aAAa,mCAAmC,CAAC,GACvE;EACE,OAAO;EACP,aACE;EACF,aAAa;EACb,aAAa,EACX,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,0CAA0C,EACpF;CACF,GACA,OAAO,EAAE,cAAc;EACrB,IAAI;GACF,MAAM,mBAAmB,MAAM,wBAAwB,KAAK,OAAO;GACnE,MAAM,OAAO,MAAM,IAAI,IAAI,OAAO,QAChC,sBACA,EAAE,iBAAiB,CACrB;GACA,OAAO,WAAW,KAAK,gBAAgB;EACzC,SAAS,OAAO;GACd,OAAO,QAAQ,KAAK,qCAAqC,wBAAwB,KAAK;EACxF;CACF,CACF;AACF;;;AC32BA,MAAM,gBAA2B;CAC/B,IAAI;CACJ,SAAS;CACT,aAAa;CACb,WAAW,CAAC,MAAM;CAClB,cAAc,EAAE,OAAO,CAAC,EAAE;CAE1B,SAAS,QAAmB,KAAqC;EAC/D,MAAM,QAAkB,CAAC;EACzB,MAAM,SAAS,MAAsB;GACnC,MAAM,KAAK,CAAC;GACZ,OAAO;EACT;EAEA,qBAAqB,QAAQ,KAAK,KAAK;EAEvC,OAAO;GAAE;GAAO,WAAW,CAAC;GAAG,SAAS,CAAC;EAAE;CAC7C;AACF"}
@@ -15,3 +15,10 @@ export declare const GRANT_CREDITS = "\n mutation GrantCredits($input: GrantCre
15
15
  export declare const REQUEST_CREDIT_WITHDRAWAL = "\n mutation RequestCreditWithdrawal($input: RequestCreditWithdrawalInput!) {\n requestCreditWithdrawal(input: $input) {\n id status requestedAmount currency createdAt\n }\n }\n";
16
16
  export declare const GET_PENDING_REFUNDS = "\n query GetPendingRefunds($page: Int, $pageSize: Int) {\n getPendingRefunds(page: $page, pageSize: $pageSize) {\n records { id amount status source createdAt }\n totalCount\n }\n }\n";
17
17
  export declare const GET_QUOTAS_OF_SUB = "\n query GetQuotas($billingAccountId: ID!, $subscriptionId: ID!) {\n getAllQuotasOfSub(billingAccountId: $billingAccountId, subscriptionId: $subscriptionId) {\n id name limits currentUsageSum reusable\n }\n }\n";
18
+ export declare const GET_SELECTED_ADDONS = "\n query GetSelectedAddons($addonIDs: [String!]!) {\n getSelectedAddons(addonIDs: $addonIDs) { \n id name price currency duration productId: productID isActive\n requiresPaidSubscription createdAt updatedAt\n }\n }\n";
19
+ export declare const LIST_COUPONS = "\n query ListCoupons($filter: CouponFilterInput, $limit: Int, $offset: Int) {\n listCoupons(filter: $filter, limit: $limit, offset: $offset) {\n coupons { \n id code name description type value currency scope status\n validFrom validUntil maxTotalUses maxUsesPerUser currentUses\n minPurchaseAmount maxDiscountAmount applicableProductIds\n campaignId metadata createdAt updatedAt\n }\n total hasMore\n }\n }\n";
20
+ export declare const GET_COUPON = "\n query GetCoupon($id: ID!) {\n getCoupon(id: $id) { \n id code name description type value currency scope status\n validFrom validUntil maxTotalUses maxUsesPerUser currentUses\n minPurchaseAmount maxDiscountAmount applicableProductIds\n campaignId metadata createdAt updatedAt\n }\n }\n";
21
+ export declare const GET_COUPON_BY_CODE = "\n query GetCouponByCode($code: String!) {\n getCouponByCode(code: $code) { \n id code name description type value currency scope status\n validFrom validUntil maxTotalUses maxUsesPerUser currentUses\n minPurchaseAmount maxDiscountAmount applicableProductIds\n campaignId metadata createdAt updatedAt\n }\n }\n";
22
+ export declare const GET_USAGE_DASHBOARD = "\n query GetUsageDashboard($billingAccountId: ID!, $period: AnalyticsPeriod) {\n getUsageDashboard(billingAccountId: $billingAccountId, period: $period) {\n totalQuotas activeQuotas healthyQuotas warningQuotas criticalQuotas\n exhaustedQuotas totalUsage\n overallTrends { averageDailyUsage growthRate predictedUsage }\n topUsageByQuota { quotaId quotaName usage limit percentage status }\n recentActivities { id quotaName amount description tags timestamp }\n }\n }\n";
23
+ export declare const GET_EARNINGS_SUMMARY = "\n query MyEarningsSummary($billingAccountId: ID!) {\n myEarningsSummary(billingAccountId: $billingAccountId) {\n totalLifetimeAmount availableAmount pendingAmount reservedAmount\n paidAmount reversedAmount moneyAmount creditsAmount\n categoryBreakdown { category amount count }\n }\n }\n";
24
+ export declare const LIST_PAYOUT_ACCOUNTS = "\n query MyPayoutAccounts($billingAccountId: ID!) {\n myPayoutAccounts(billingAccountId: $billingAccountId) { \n id billingAccountId type label displayName accountLast4 country currency\n providerPreference status isDefault isActive verifiedAt metadata\n createdAt updatedAt\n }\n }\n";
@@ -30,9 +30,9 @@ export declare const LessonTypeEnum: z.ZodEnum<{
30
30
  export declare const EnrollmentStatusEnum: z.ZodEnum<{
31
31
  COMPLETED: "COMPLETED";
32
32
  IN_PROGRESS: "IN_PROGRESS";
33
+ EXPIRED: "EXPIRED";
33
34
  ENROLLED: "ENROLLED";
34
35
  DROPPED: "DROPPED";
35
- EXPIRED: "EXPIRED";
36
36
  }>;
37
37
  export declare const ProgressStatusEnum: z.ZodEnum<{
38
38
  COMPLETED: "COMPLETED";