@burdenoff/mcp-libs 2026.511.1
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.
- package/README.md +76 -0
- package/dist/chunk-4GBVJ4OY.js +847 -0
- package/dist/chunk-4GBVJ4OY.js.map +1 -0
- package/dist/chunk-H2OYWLOA.js +919 -0
- package/dist/chunk-H2OYWLOA.js.map +1 -0
- package/dist/chunk-JFEQYSWM.js +174 -0
- package/dist/chunk-JFEQYSWM.js.map +1 -0
- package/dist/chunk-WWFVD7BO.js +273 -0
- package/dist/chunk-WWFVD7BO.js.map +1 -0
- package/dist/context-1jV4NsLv.d.cts +138 -0
- package/dist/context-1jV4NsLv.d.ts +138 -0
- package/dist/core/index.cjs +953 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +59 -0
- package/dist/core/index.d.ts +59 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/http-BP4c721D.d.cts +22 -0
- package/dist/http-DXTeCD5r.d.ts +22 -0
- package/dist/index.cjs +1013 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/module-DBcfA-i3.d.ts +67 -0
- package/dist/module-DFQBZNK6.d.cts +67 -0
- package/dist/modules/auth/index.cjs +533 -0
- package/dist/modules/auth/index.cjs.map +1 -0
- package/dist/modules/auth/index.d.cts +51 -0
- package/dist/modules/auth/index.d.ts +51 -0
- package/dist/modules/auth/index.js +159 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/billing/index.cjs +655 -0
- package/dist/modules/billing/index.cjs.map +1 -0
- package/dist/modules/billing/index.d.cts +8 -0
- package/dist/modules/billing/index.d.ts +8 -0
- package/dist/modules/billing/index.js +606 -0
- package/dist/modules/billing/index.js.map +1 -0
- package/dist/modules/channels/index.cjs +443 -0
- package/dist/modules/channels/index.cjs.map +1 -0
- package/dist/modules/channels/index.d.cts +8 -0
- package/dist/modules/channels/index.d.ts +8 -0
- package/dist/modules/channels/index.js +394 -0
- package/dist/modules/channels/index.js.map +1 -0
- package/dist/modules/conversations/index.cjs +288 -0
- package/dist/modules/conversations/index.cjs.map +1 -0
- package/dist/modules/conversations/index.d.cts +8 -0
- package/dist/modules/conversations/index.d.ts +8 -0
- package/dist/modules/conversations/index.js +239 -0
- package/dist/modules/conversations/index.js.map +1 -0
- package/dist/modules/devportal/index.cjs +796 -0
- package/dist/modules/devportal/index.cjs.map +1 -0
- package/dist/modules/devportal/index.d.cts +8 -0
- package/dist/modules/devportal/index.d.ts +8 -0
- package/dist/modules/devportal/index.js +747 -0
- package/dist/modules/devportal/index.js.map +1 -0
- package/dist/modules/export/index.cjs +333 -0
- package/dist/modules/export/index.cjs.map +1 -0
- package/dist/modules/export/index.d.cts +8 -0
- package/dist/modules/export/index.d.ts +8 -0
- package/dist/modules/export/index.js +284 -0
- package/dist/modules/export/index.js.map +1 -0
- package/dist/modules/files/index.cjs +278 -0
- package/dist/modules/files/index.cjs.map +1 -0
- package/dist/modules/files/index.d.cts +8 -0
- package/dist/modules/files/index.d.ts +8 -0
- package/dist/modules/files/index.js +229 -0
- package/dist/modules/files/index.js.map +1 -0
- package/dist/modules/groups/index.cjs +451 -0
- package/dist/modules/groups/index.cjs.map +1 -0
- package/dist/modules/groups/index.d.cts +8 -0
- package/dist/modules/groups/index.d.ts +8 -0
- package/dist/modules/groups/index.js +402 -0
- package/dist/modules/groups/index.js.map +1 -0
- package/dist/modules/health/index.cjs +159 -0
- package/dist/modules/health/index.cjs.map +1 -0
- package/dist/modules/health/index.d.cts +8 -0
- package/dist/modules/health/index.d.ts +8 -0
- package/dist/modules/health/index.js +36 -0
- package/dist/modules/health/index.js.map +1 -0
- package/dist/modules/integrations/index.cjs +316 -0
- package/dist/modules/integrations/index.cjs.map +1 -0
- package/dist/modules/integrations/index.d.cts +8 -0
- package/dist/modules/integrations/index.d.ts +8 -0
- package/dist/modules/integrations/index.js +267 -0
- package/dist/modules/integrations/index.js.map +1 -0
- package/dist/modules/notifications/index.cjs +222 -0
- package/dist/modules/notifications/index.cjs.map +1 -0
- package/dist/modules/notifications/index.d.cts +8 -0
- package/dist/modules/notifications/index.d.ts +8 -0
- package/dist/modules/notifications/index.js +173 -0
- package/dist/modules/notifications/index.js.map +1 -0
- package/dist/modules/organizations/index.cjs +267 -0
- package/dist/modules/organizations/index.cjs.map +1 -0
- package/dist/modules/organizations/index.d.cts +8 -0
- package/dist/modules/organizations/index.d.ts +8 -0
- package/dist/modules/organizations/index.js +218 -0
- package/dist/modules/organizations/index.js.map +1 -0
- package/dist/modules/products/index.cjs +736 -0
- package/dist/modules/products/index.cjs.map +1 -0
- package/dist/modules/products/index.d.cts +8 -0
- package/dist/modules/products/index.d.ts +8 -0
- package/dist/modules/products/index.js +687 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/rbac/index.cjs +378 -0
- package/dist/modules/rbac/index.cjs.map +1 -0
- package/dist/modules/rbac/index.d.cts +8 -0
- package/dist/modules/rbac/index.d.ts +8 -0
- package/dist/modules/rbac/index.js +329 -0
- package/dist/modules/rbac/index.js.map +1 -0
- package/dist/modules/sandbox/index.cjs +318 -0
- package/dist/modules/sandbox/index.cjs.map +1 -0
- package/dist/modules/sandbox/index.d.cts +8 -0
- package/dist/modules/sandbox/index.d.ts +8 -0
- package/dist/modules/sandbox/index.js +225 -0
- package/dist/modules/sandbox/index.js.map +1 -0
- package/dist/modules/scheduler/index.cjs +267 -0
- package/dist/modules/scheduler/index.cjs.map +1 -0
- package/dist/modules/scheduler/index.d.cts +8 -0
- package/dist/modules/scheduler/index.d.ts +8 -0
- package/dist/modules/scheduler/index.js +218 -0
- package/dist/modules/scheduler/index.js.map +1 -0
- package/dist/modules/security/index.cjs +529 -0
- package/dist/modules/security/index.cjs.map +1 -0
- package/dist/modules/security/index.d.cts +8 -0
- package/dist/modules/security/index.d.ts +8 -0
- package/dist/modules/security/index.js +480 -0
- package/dist/modules/security/index.js.map +1 -0
- package/dist/modules/store/index.cjs +450 -0
- package/dist/modules/store/index.cjs.map +1 -0
- package/dist/modules/store/index.d.cts +8 -0
- package/dist/modules/store/index.d.ts +8 -0
- package/dist/modules/store/index.js +401 -0
- package/dist/modules/store/index.js.map +1 -0
- package/dist/modules/support/index.cjs +285 -0
- package/dist/modules/support/index.cjs.map +1 -0
- package/dist/modules/support/index.d.cts +8 -0
- package/dist/modules/support/index.d.ts +8 -0
- package/dist/modules/support/index.js +236 -0
- package/dist/modules/support/index.js.map +1 -0
- package/dist/modules/tags/index.cjs +421 -0
- package/dist/modules/tags/index.cjs.map +1 -0
- package/dist/modules/tags/index.d.cts +8 -0
- package/dist/modules/tags/index.d.ts +8 -0
- package/dist/modules/tags/index.js +372 -0
- package/dist/modules/tags/index.js.map +1 -0
- package/dist/modules/tours/index.cjs +225 -0
- package/dist/modules/tours/index.cjs.map +1 -0
- package/dist/modules/tours/index.d.cts +8 -0
- package/dist/modules/tours/index.d.ts +8 -0
- package/dist/modules/tours/index.js +176 -0
- package/dist/modules/tours/index.js.map +1 -0
- package/dist/modules/vibecontrols/index.cjs +5551 -0
- package/dist/modules/vibecontrols/index.cjs.map +1 -0
- package/dist/modules/vibecontrols/index.d.cts +8 -0
- package/dist/modules/vibecontrols/index.d.ts +8 -0
- package/dist/modules/vibecontrols/index.js +4380 -0
- package/dist/modules/vibecontrols/index.js.map +1 -0
- package/dist/modules/workspaces/index.cjs +552 -0
- package/dist/modules/workspaces/index.cjs.map +1 -0
- package/dist/modules/workspaces/index.d.cts +8 -0
- package/dist/modules/workspaces/index.d.ts +8 -0
- package/dist/modules/workspaces/index.js +503 -0
- package/dist/modules/workspaces/index.js.map +1 -0
- package/dist/tool-name-CQf_IqAj.d.cts +47 -0
- package/dist/tool-name-DlnrBsZ6.d.ts +47 -0
- package/dist/transports/index.cjs +183 -0
- package/dist/transports/index.cjs.map +1 -0
- package/dist/transports/index.d.cts +13 -0
- package/dist/transports/index.d.ts +13 -0
- package/dist/transports/index.js +3 -0
- package/dist/transports/index.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import { mcpToolName, jsonResult, errorResult } from '../../chunk-H2OYWLOA.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// src/modules/billing/operations.ts
|
|
5
|
+
var GET_DEFAULT_BILLING_ACCOUNT = `
|
|
6
|
+
query GetDefaultBillingAccount {
|
|
7
|
+
getDefaultBillingAccount {
|
|
8
|
+
id creditAmount currency
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
var GET_ACTIVE_SUBSCRIPTIONS = `
|
|
13
|
+
query GetActiveSubscriptions($billingAccountId: ID!) {
|
|
14
|
+
getActiveSubscriptions(billingAccountId: $billingAccountId) {
|
|
15
|
+
id status seatCount nextBillingDate
|
|
16
|
+
plan { name price currency }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
var GET_SUBSCRIPTION = `
|
|
21
|
+
query GetSubscription($id: ID!) {
|
|
22
|
+
getSubscription(id: $id) {
|
|
23
|
+
id status startDate endDate seatCount billingAccountId
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
var UPDATE_SUBSCRIPTION_SEATS = `
|
|
28
|
+
mutation UpdateSubscriptionSeats($input: UpdateSubscriptionSeatsInput!) {
|
|
29
|
+
updateSubscriptionSeats(input: $input) {
|
|
30
|
+
id seatCount lastSeatChangeAt
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
var CANCEL_SUBSCRIPTION = `
|
|
35
|
+
mutation CancelSubscription($input: CancelSubscriptionInput!) {
|
|
36
|
+
cancelSubscription(input: $input) {
|
|
37
|
+
id status canceledAt cancellationReason
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
var GET_ALL_PLANS = `
|
|
42
|
+
query GetAllPlans($filter: PlanFilterInput) {
|
|
43
|
+
getAllPlans(filter: $filter) {
|
|
44
|
+
id name price currency duration pricingModel
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
var GET_PLAN = `
|
|
49
|
+
query GetPlan($id: ID!) {
|
|
50
|
+
getPlan(id: $id) {
|
|
51
|
+
id name price pricePerSeat minSeats maxSeats isActive
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
var GET_ALL_ADDONS = `
|
|
56
|
+
query GetAllAddOns($filter: AddOnFilterInput, $limit: Int) {
|
|
57
|
+
getAllAddOns(filter: $filter, limit: $limit) {
|
|
58
|
+
id name price currency duration isActive
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
var GET_PAGINATED_INVOICES = `
|
|
63
|
+
query GetPaginatedInvoices($billingAccountId: ID!, $page: Int, $pageSize: Int) {
|
|
64
|
+
getPaginatedInvoices(billingAccountId: $billingAccountId, page: $page, pageSize: $pageSize) {
|
|
65
|
+
invoices { id invoiceNumber status total currency paidAt pdfUrl }
|
|
66
|
+
totalCount hasMore
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
var GET_INVOICE = `
|
|
71
|
+
query GetInvoice($id: ID!) {
|
|
72
|
+
getInvoice(id: $id) {
|
|
73
|
+
id invoiceNumber status subtotal tax total
|
|
74
|
+
items { description amount }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
var GET_PAYMENT_METHODS = `
|
|
79
|
+
query GetPaymentMethods($billingAccountId: ID!) {
|
|
80
|
+
getPaymentMethods(billingAccountId: $billingAccountId) {
|
|
81
|
+
id type last4 expiryYear brand isDefault isVerified
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
var ADD_PAYMENT_METHOD = `
|
|
86
|
+
mutation AddPaymentMethod($input: AddPaymentMethodInput!) {
|
|
87
|
+
addPaymentMethod(input: $input) {
|
|
88
|
+
id type isDefault isVerified
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
var DELETE_PAYMENT_METHOD = `
|
|
93
|
+
mutation DeletePaymentMethod($id: ID!) {
|
|
94
|
+
deletePaymentMethod(id: $id) { success }
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
var GRANT_CREDITS = `
|
|
98
|
+
mutation GrantCredits($input: GrantCreditsInput!) {
|
|
99
|
+
grantCredits(input: $input) {
|
|
100
|
+
id amount status type
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
var REQUEST_CREDIT_WITHDRAWAL = `
|
|
105
|
+
mutation RequestCreditWithdrawal($input: RequestCreditWithdrawalInput!) {
|
|
106
|
+
requestCreditWithdrawal(input: $input) {
|
|
107
|
+
id status amount
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
var GET_PENDING_REFUNDS = `
|
|
112
|
+
query GetPendingRefunds($page: Int, $pageSize: Int) {
|
|
113
|
+
getPendingRefunds(page: $page, pageSize: $pageSize) {
|
|
114
|
+
records { id amount status source createdAt }
|
|
115
|
+
totalCount
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
var GET_QUOTAS_OF_SUB = `
|
|
120
|
+
query GetQuotas($subscriptionId: ID!) {
|
|
121
|
+
getAllQuotasOfSub(subscriptionId: $subscriptionId) {
|
|
122
|
+
id name limits currentUsageSum reusable
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
// src/modules/billing/tools.ts
|
|
128
|
+
async function resolveBillingAccountId(ctx, override) {
|
|
129
|
+
if (override !== void 0 && override !== "") return override;
|
|
130
|
+
const data = await ctx.gql.global.request(GET_DEFAULT_BILLING_ACCOUNT);
|
|
131
|
+
if (!data.getDefaultBillingAccount?.id) {
|
|
132
|
+
throw new Error("No default billing account on file. Pass account explicitly.");
|
|
133
|
+
}
|
|
134
|
+
return data.getDefaultBillingAccount.id;
|
|
135
|
+
}
|
|
136
|
+
function registerBillingTools(server, ctx, track) {
|
|
137
|
+
server.registerTool(
|
|
138
|
+
track(mcpToolName(ctx.productName, "billing_subscriptions_list")),
|
|
139
|
+
{
|
|
140
|
+
title: "List Subscriptions",
|
|
141
|
+
description: "List active subscriptions on a billing account (defaults to current).",
|
|
142
|
+
inputSchema: {
|
|
143
|
+
account: z.string().optional().describe("Billing account ID (defaults to current)")
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
async ({ account }) => {
|
|
147
|
+
try {
|
|
148
|
+
const billingAccountId = await resolveBillingAccountId(ctx, account);
|
|
149
|
+
const data = await ctx.gql.global.request(
|
|
150
|
+
GET_ACTIVE_SUBSCRIPTIONS,
|
|
151
|
+
{ billingAccountId }
|
|
152
|
+
);
|
|
153
|
+
return jsonResult(data.getActiveSubscriptions);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
ctx.logger.error("billing_subscriptions_list failed", { error: String(error) });
|
|
156
|
+
return errorResult(
|
|
157
|
+
`Failed to list subscriptions: ${error instanceof Error ? error.message : String(error)}`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
server.registerTool(
|
|
163
|
+
track(mcpToolName(ctx.productName, "billing_subscriptions_get")),
|
|
164
|
+
{
|
|
165
|
+
title: "Get Subscription",
|
|
166
|
+
description: "Get a subscription by ID.",
|
|
167
|
+
inputSchema: { id: z.string().describe("Subscription ID") }
|
|
168
|
+
},
|
|
169
|
+
async ({ id }) => {
|
|
170
|
+
try {
|
|
171
|
+
const data = await ctx.gql.global.request(
|
|
172
|
+
GET_SUBSCRIPTION,
|
|
173
|
+
{ id }
|
|
174
|
+
);
|
|
175
|
+
if (!data.getSubscription) return errorResult(`Subscription ${id} not found`);
|
|
176
|
+
return jsonResult(data.getSubscription);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
ctx.logger.error("billing_subscriptions_get failed", { error: String(error) });
|
|
179
|
+
return errorResult(
|
|
180
|
+
`Failed to get subscription: ${error instanceof Error ? error.message : String(error)}`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
server.registerTool(
|
|
186
|
+
track(mcpToolName(ctx.productName, "billing_subscriptions_upgrade")),
|
|
187
|
+
{
|
|
188
|
+
title: "Update Subscription Seats",
|
|
189
|
+
description: "Change the seat count on a subscription.",
|
|
190
|
+
inputSchema: {
|
|
191
|
+
id: z.string().describe("Subscription ID"),
|
|
192
|
+
seats: z.number().describe("Target seat count")
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
async ({ id, seats }) => {
|
|
196
|
+
try {
|
|
197
|
+
const input = { subscriptionId: id, seatCount: seats };
|
|
198
|
+
const data = await ctx.gql.global.request(
|
|
199
|
+
UPDATE_SUBSCRIPTION_SEATS,
|
|
200
|
+
{ input }
|
|
201
|
+
);
|
|
202
|
+
return jsonResult(data.updateSubscriptionSeats);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
ctx.logger.error("billing_subscriptions_upgrade failed", { error: String(error) });
|
|
205
|
+
return errorResult(
|
|
206
|
+
`Failed to update seats: ${error instanceof Error ? error.message : String(error)}`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
server.registerTool(
|
|
212
|
+
track(mcpToolName(ctx.productName, "billing_subscriptions_cancel")),
|
|
213
|
+
{
|
|
214
|
+
title: "Cancel Subscription",
|
|
215
|
+
description: "Cancel a subscription with an optional reason.",
|
|
216
|
+
inputSchema: {
|
|
217
|
+
id: z.string().describe("Subscription ID"),
|
|
218
|
+
reason: z.string().optional().describe("Cancellation reason")
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
async ({ id, reason }) => {
|
|
222
|
+
try {
|
|
223
|
+
const input = { subscriptionId: id };
|
|
224
|
+
if (reason !== void 0) input.reason = reason;
|
|
225
|
+
const data = await ctx.gql.global.request(
|
|
226
|
+
CANCEL_SUBSCRIPTION,
|
|
227
|
+
{ input }
|
|
228
|
+
);
|
|
229
|
+
return jsonResult(data.cancelSubscription);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
ctx.logger.error("billing_subscriptions_cancel failed", { error: String(error) });
|
|
232
|
+
return errorResult(
|
|
233
|
+
`Failed to cancel subscription: ${error instanceof Error ? error.message : String(error)}`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
server.registerTool(
|
|
239
|
+
track(mcpToolName(ctx.productName, "billing_plans_list")),
|
|
240
|
+
{
|
|
241
|
+
title: "List Plans",
|
|
242
|
+
description: "List available plans, optionally filtered by product.",
|
|
243
|
+
inputSchema: {
|
|
244
|
+
product: z.string().optional().describe("Product ID filter")
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
async ({ product }) => {
|
|
248
|
+
try {
|
|
249
|
+
const filter = {};
|
|
250
|
+
if (product !== void 0) filter.productId = product;
|
|
251
|
+
const data = await ctx.gql.global.request(GET_ALL_PLANS, {
|
|
252
|
+
filter: Object.keys(filter).length ? filter : void 0
|
|
253
|
+
});
|
|
254
|
+
return jsonResult(data.getAllPlans);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
ctx.logger.error("billing_plans_list failed", { error: String(error) });
|
|
257
|
+
return errorResult(
|
|
258
|
+
`Failed to list plans: ${error instanceof Error ? error.message : String(error)}`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
server.registerTool(
|
|
264
|
+
track(mcpToolName(ctx.productName, "billing_plans_get")),
|
|
265
|
+
{
|
|
266
|
+
title: "Get Plan",
|
|
267
|
+
description: "Get a plan by ID.",
|
|
268
|
+
inputSchema: { id: z.string().describe("Plan ID") }
|
|
269
|
+
},
|
|
270
|
+
async ({ id }) => {
|
|
271
|
+
try {
|
|
272
|
+
const data = await ctx.gql.global.request(GET_PLAN, { id });
|
|
273
|
+
if (!data.getPlan) return errorResult(`Plan ${id} not found`);
|
|
274
|
+
return jsonResult(data.getPlan);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
ctx.logger.error("billing_plans_get failed", { error: String(error) });
|
|
277
|
+
return errorResult(
|
|
278
|
+
`Failed to get plan: ${error instanceof Error ? error.message : String(error)}`
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
server.registerTool(
|
|
284
|
+
track(mcpToolName(ctx.productName, "billing_addons_list")),
|
|
285
|
+
{
|
|
286
|
+
title: "List Addons",
|
|
287
|
+
description: "List addons, optionally filtered by product.",
|
|
288
|
+
inputSchema: {
|
|
289
|
+
product: z.string().optional().describe("Product ID filter"),
|
|
290
|
+
limit: z.number().optional().describe("Page size (default 50)")
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
async ({ product, limit }) => {
|
|
294
|
+
try {
|
|
295
|
+
const filter = {};
|
|
296
|
+
if (product !== void 0) filter.productId = product;
|
|
297
|
+
const data = await ctx.gql.global.request(GET_ALL_ADDONS, {
|
|
298
|
+
filter: Object.keys(filter).length ? filter : void 0,
|
|
299
|
+
limit
|
|
300
|
+
});
|
|
301
|
+
return jsonResult(data.getAllAddOns);
|
|
302
|
+
} catch (error) {
|
|
303
|
+
ctx.logger.error("billing_addons_list failed", { error: String(error) });
|
|
304
|
+
return errorResult(
|
|
305
|
+
`Failed to list addons: ${error instanceof Error ? error.message : String(error)}`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
server.registerTool(
|
|
311
|
+
track(mcpToolName(ctx.productName, "billing_invoices_list")),
|
|
312
|
+
{
|
|
313
|
+
title: "List Invoices",
|
|
314
|
+
description: "Paginated list of invoices on a billing account.",
|
|
315
|
+
inputSchema: {
|
|
316
|
+
account: z.string().optional().describe("Billing account ID (defaults to current)"),
|
|
317
|
+
page: z.number().optional().describe("Page number (default 1)"),
|
|
318
|
+
pageSize: z.number().optional().describe("Page size (default 20)")
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
async ({ account, page, pageSize }) => {
|
|
322
|
+
try {
|
|
323
|
+
const billingAccountId = await resolveBillingAccountId(ctx, account);
|
|
324
|
+
const data = await ctx.gql.global.request(GET_PAGINATED_INVOICES, { billingAccountId, page, pageSize });
|
|
325
|
+
return jsonResult(data.getPaginatedInvoices);
|
|
326
|
+
} catch (error) {
|
|
327
|
+
ctx.logger.error("billing_invoices_list failed", { error: String(error) });
|
|
328
|
+
return errorResult(
|
|
329
|
+
`Failed to list invoices: ${error instanceof Error ? error.message : String(error)}`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
server.registerTool(
|
|
335
|
+
track(mcpToolName(ctx.productName, "billing_invoices_get")),
|
|
336
|
+
{
|
|
337
|
+
title: "Get Invoice",
|
|
338
|
+
description: "Get an invoice by ID.",
|
|
339
|
+
inputSchema: { id: z.string().describe("Invoice ID") }
|
|
340
|
+
},
|
|
341
|
+
async ({ id }) => {
|
|
342
|
+
try {
|
|
343
|
+
const data = await ctx.gql.global.request(GET_INVOICE, {
|
|
344
|
+
id
|
|
345
|
+
});
|
|
346
|
+
if (!data.getInvoice) return errorResult(`Invoice ${id} not found`);
|
|
347
|
+
return jsonResult(data.getInvoice);
|
|
348
|
+
} catch (error) {
|
|
349
|
+
ctx.logger.error("billing_invoices_get failed", { error: String(error) });
|
|
350
|
+
return errorResult(
|
|
351
|
+
`Failed to get invoice: ${error instanceof Error ? error.message : String(error)}`
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
);
|
|
356
|
+
server.registerTool(
|
|
357
|
+
track(mcpToolName(ctx.productName, "billing_invoices_get_pdf_url")),
|
|
358
|
+
{
|
|
359
|
+
title: "Get Invoice PDF URL",
|
|
360
|
+
description: "Return the invoice PDF download URL. The actual PDF must be opened in a browser by the user.",
|
|
361
|
+
inputSchema: { id: z.string().describe("Invoice ID") }
|
|
362
|
+
},
|
|
363
|
+
async ({ id }) => {
|
|
364
|
+
try {
|
|
365
|
+
const data = await ctx.gql.global.request(GET_INVOICE, {
|
|
366
|
+
id
|
|
367
|
+
});
|
|
368
|
+
if (!data.getInvoice?.pdfUrl) return errorResult(`Invoice ${id} has no pdfUrl`);
|
|
369
|
+
return jsonResult({ url: data.getInvoice.pdfUrl });
|
|
370
|
+
} catch (error) {
|
|
371
|
+
ctx.logger.error("billing_invoices_get_pdf_url failed", { error: String(error) });
|
|
372
|
+
return errorResult(
|
|
373
|
+
`Failed to fetch invoice URL: ${error instanceof Error ? error.message : String(error)}`
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
server.registerTool(
|
|
379
|
+
track(mcpToolName(ctx.productName, "billing_payment_methods_list")),
|
|
380
|
+
{
|
|
381
|
+
title: "List Payment Methods",
|
|
382
|
+
description: "List payment methods on a billing account.",
|
|
383
|
+
inputSchema: {
|
|
384
|
+
account: z.string().optional().describe("Billing account ID (defaults to current)")
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
async ({ account }) => {
|
|
388
|
+
try {
|
|
389
|
+
const billingAccountId = await resolveBillingAccountId(ctx, account);
|
|
390
|
+
const data = await ctx.gql.global.request(
|
|
391
|
+
GET_PAYMENT_METHODS,
|
|
392
|
+
{ billingAccountId }
|
|
393
|
+
);
|
|
394
|
+
return jsonResult(data.getPaymentMethods);
|
|
395
|
+
} catch (error) {
|
|
396
|
+
ctx.logger.error("billing_payment_methods_list failed", { error: String(error) });
|
|
397
|
+
return errorResult(
|
|
398
|
+
`Failed to list payment methods: ${error instanceof Error ? error.message : String(error)}`
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
server.registerTool(
|
|
404
|
+
track(mcpToolName(ctx.productName, "billing_payment_methods_add")),
|
|
405
|
+
{
|
|
406
|
+
title: "Add Payment Method",
|
|
407
|
+
description: "Add a payment method (card metadata only \u2014 provider handles secrets). Use the provider checkout URL elsewhere for full card capture.",
|
|
408
|
+
inputSchema: {
|
|
409
|
+
type: z.enum(["CREDIT_CARD", "BANK", "UPI"]).describe("Payment method type"),
|
|
410
|
+
last4: z.string().describe("Last 4 digits / identifier"),
|
|
411
|
+
brand: z.string().optional().describe("Brand (Visa, MasterCard, etc.)"),
|
|
412
|
+
expiryMonth: z.number().optional().describe("Expiry month (1-12)"),
|
|
413
|
+
expiryYear: z.number().optional().describe("Expiry year (4 digits)"),
|
|
414
|
+
account: z.string().optional().describe("Billing account ID (defaults to current)"),
|
|
415
|
+
isDefault: z.boolean().optional().describe("Make it the default")
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
async ({ type, last4, brand, expiryMonth, expiryYear, account, isDefault }) => {
|
|
419
|
+
try {
|
|
420
|
+
const billingAccountId = await resolveBillingAccountId(ctx, account);
|
|
421
|
+
const input = {
|
|
422
|
+
billingAccountId,
|
|
423
|
+
type,
|
|
424
|
+
last4,
|
|
425
|
+
isDefault: isDefault === true
|
|
426
|
+
};
|
|
427
|
+
if (brand !== void 0) input.brand = brand;
|
|
428
|
+
if (expiryMonth !== void 0) input.expiryMonth = expiryMonth;
|
|
429
|
+
if (expiryYear !== void 0) input.expiryYear = expiryYear;
|
|
430
|
+
const data = await ctx.gql.global.request(
|
|
431
|
+
ADD_PAYMENT_METHOD,
|
|
432
|
+
{ input }
|
|
433
|
+
);
|
|
434
|
+
return jsonResult(data.addPaymentMethod);
|
|
435
|
+
} catch (error) {
|
|
436
|
+
ctx.logger.error("billing_payment_methods_add failed", { error: String(error) });
|
|
437
|
+
return errorResult(
|
|
438
|
+
`Failed to add payment method: ${error instanceof Error ? error.message : String(error)}`
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
);
|
|
443
|
+
server.registerTool(
|
|
444
|
+
track(mcpToolName(ctx.productName, "billing_payment_methods_remove")),
|
|
445
|
+
{
|
|
446
|
+
title: "Remove Payment Method",
|
|
447
|
+
description: "Delete a payment method by ID.",
|
|
448
|
+
inputSchema: { id: z.string().describe("Payment method ID") }
|
|
449
|
+
},
|
|
450
|
+
async ({ id }) => {
|
|
451
|
+
try {
|
|
452
|
+
await ctx.gql.global.request(
|
|
453
|
+
DELETE_PAYMENT_METHOD,
|
|
454
|
+
{ id }
|
|
455
|
+
);
|
|
456
|
+
return jsonResult({ status: "success", message: "Payment method removed", id });
|
|
457
|
+
} catch (error) {
|
|
458
|
+
ctx.logger.error("billing_payment_methods_remove failed", { error: String(error) });
|
|
459
|
+
return errorResult(
|
|
460
|
+
`Failed to remove payment method: ${error instanceof Error ? error.message : String(error)}`
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
server.registerTool(
|
|
466
|
+
track(mcpToolName(ctx.productName, "billing_credits_balance")),
|
|
467
|
+
{
|
|
468
|
+
title: "Credit Balance",
|
|
469
|
+
description: "Show current credit balance on the default billing account.",
|
|
470
|
+
inputSchema: {}
|
|
471
|
+
},
|
|
472
|
+
async () => {
|
|
473
|
+
try {
|
|
474
|
+
const data = await ctx.gql.global.request(GET_DEFAULT_BILLING_ACCOUNT);
|
|
475
|
+
return jsonResult(data.getDefaultBillingAccount);
|
|
476
|
+
} catch (error) {
|
|
477
|
+
ctx.logger.error("billing_credits_balance failed", { error: String(error) });
|
|
478
|
+
return errorResult(
|
|
479
|
+
`Failed to read balance: ${error instanceof Error ? error.message : String(error)}`
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
server.registerTool(
|
|
485
|
+
track(mcpToolName(ctx.productName, "billing_credits_grant")),
|
|
486
|
+
{
|
|
487
|
+
title: "Grant Credits",
|
|
488
|
+
description: "Grant credits to a billing account (admin only).",
|
|
489
|
+
inputSchema: {
|
|
490
|
+
account: z.string().describe("Billing account ID"),
|
|
491
|
+
amount: z.number().describe("Amount to grant"),
|
|
492
|
+
reason: z.string().optional().describe("Reason for grant")
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
async ({ account, amount, reason }) => {
|
|
496
|
+
try {
|
|
497
|
+
const input = {
|
|
498
|
+
billingAccountId: account,
|
|
499
|
+
amount,
|
|
500
|
+
reason: reason ?? "mcp-grant"
|
|
501
|
+
};
|
|
502
|
+
await ctx.gql.global.request(GRANT_CREDITS, { input });
|
|
503
|
+
return jsonResult({ status: "success", message: "Credits granted", amount, account });
|
|
504
|
+
} catch (error) {
|
|
505
|
+
ctx.logger.error("billing_credits_grant failed", { error: String(error) });
|
|
506
|
+
return errorResult(
|
|
507
|
+
`Failed to grant credits: ${error instanceof Error ? error.message : String(error)}`
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
);
|
|
512
|
+
server.registerTool(
|
|
513
|
+
track(mcpToolName(ctx.productName, "billing_credits_withdraw")),
|
|
514
|
+
{
|
|
515
|
+
title: "Withdraw Credits",
|
|
516
|
+
description: "Request a credit withdrawal to a payout account.",
|
|
517
|
+
inputSchema: {
|
|
518
|
+
account: z.string().describe("Billing account ID"),
|
|
519
|
+
amount: z.number().describe("Amount to withdraw"),
|
|
520
|
+
payout: z.string().describe("Payout account ID")
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
async ({ account, amount, payout }) => {
|
|
524
|
+
try {
|
|
525
|
+
const input = {
|
|
526
|
+
billingAccountId: account,
|
|
527
|
+
creditAmount: amount,
|
|
528
|
+
payoutAccountId: payout
|
|
529
|
+
};
|
|
530
|
+
await ctx.gql.global.request(REQUEST_CREDIT_WITHDRAWAL, { input });
|
|
531
|
+
return jsonResult({ status: "success", message: "Withdrawal requested", amount, account });
|
|
532
|
+
} catch (error) {
|
|
533
|
+
ctx.logger.error("billing_credits_withdraw failed", { error: String(error) });
|
|
534
|
+
return errorResult(
|
|
535
|
+
`Failed to request withdrawal: ${error instanceof Error ? error.message : String(error)}`
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
server.registerTool(
|
|
541
|
+
track(mcpToolName(ctx.productName, "billing_refunds_list")),
|
|
542
|
+
{
|
|
543
|
+
title: "List Pending Refunds",
|
|
544
|
+
description: "List pending refund records (paginated).",
|
|
545
|
+
inputSchema: {
|
|
546
|
+
page: z.number().optional().describe("Page number (default 0)"),
|
|
547
|
+
pageSize: z.number().optional().describe("Page size (default 20)")
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
async ({ page, pageSize }) => {
|
|
551
|
+
try {
|
|
552
|
+
const data = await ctx.gql.global.request(GET_PENDING_REFUNDS, { page, pageSize });
|
|
553
|
+
return jsonResult(data.getPendingRefunds);
|
|
554
|
+
} catch (error) {
|
|
555
|
+
ctx.logger.error("billing_refunds_list failed", { error: String(error) });
|
|
556
|
+
return errorResult(
|
|
557
|
+
`Failed to list refunds: ${error instanceof Error ? error.message : String(error)}`
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
server.registerTool(
|
|
563
|
+
track(mcpToolName(ctx.productName, "billing_quota_list")),
|
|
564
|
+
{
|
|
565
|
+
title: "List Subscription Quotas",
|
|
566
|
+
description: "Get all quotas for a subscription.",
|
|
567
|
+
inputSchema: {
|
|
568
|
+
subscriptionId: z.string().describe("Subscription ID")
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
async ({ subscriptionId }) => {
|
|
572
|
+
try {
|
|
573
|
+
const data = await ctx.gql.global.request(GET_QUOTAS_OF_SUB, { subscriptionId });
|
|
574
|
+
return jsonResult(data.getAllQuotasOfSub);
|
|
575
|
+
} catch (error) {
|
|
576
|
+
ctx.logger.error("billing_quota_list failed", { error: String(error) });
|
|
577
|
+
return errorResult(
|
|
578
|
+
`Failed to list quotas: ${error instanceof Error ? error.message : String(error)}`
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// src/modules/billing/index.ts
|
|
586
|
+
var billingModule = {
|
|
587
|
+
id: "billing",
|
|
588
|
+
version: "0.0.1",
|
|
589
|
+
displayName: "Billing",
|
|
590
|
+
dependsOn: ["auth"],
|
|
591
|
+
capabilities: { tools: {} },
|
|
592
|
+
register(server, ctx) {
|
|
593
|
+
const tools = [];
|
|
594
|
+
const track = (n) => {
|
|
595
|
+
tools.push(n);
|
|
596
|
+
return n;
|
|
597
|
+
};
|
|
598
|
+
registerBillingTools(server, ctx, track);
|
|
599
|
+
return { tools, resources: [], prompts: [] };
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
var billing_default = billingModule;
|
|
603
|
+
|
|
604
|
+
export { billing_default as default };
|
|
605
|
+
//# sourceMappingURL=index.js.map
|
|
606
|
+
//# sourceMappingURL=index.js.map
|