@carrierllc/mcp 0.0.1 → 0.2.0
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 +216 -3
- package/dist/apps/app-state.d.ts +19 -0
- package/dist/apps/app-state.d.ts.map +1 -0
- package/dist/apps/app-state.js +28 -0
- package/dist/apps/app-state.js.map +1 -0
- package/dist/apps/balance-topup.d.ts +19 -0
- package/dist/apps/balance-topup.d.ts.map +1 -0
- package/dist/apps/balance-topup.js +121 -0
- package/dist/apps/balance-topup.js.map +1 -0
- package/dist/apps/fleet-health-app.d.ts +29 -0
- package/dist/apps/fleet-health-app.d.ts.map +1 -0
- package/dist/apps/fleet-health-app.js +152 -0
- package/dist/apps/fleet-health-app.js.map +1 -0
- package/dist/apps/index.d.ts +37 -0
- package/dist/apps/index.d.ts.map +1 -0
- package/dist/apps/index.js +42 -0
- package/dist/apps/index.js.map +1 -0
- package/dist/apps/provisioning-wizard.d.ts +11 -0
- package/dist/apps/provisioning-wizard.d.ts.map +1 -0
- package/dist/apps/provisioning-wizard.js +345 -0
- package/dist/apps/provisioning-wizard.js.map +1 -0
- package/dist/audit.d.ts +31 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +42 -0
- package/dist/audit.js.map +1 -0
- package/dist/billing-thresholds.d.ts +71 -0
- package/dist/billing-thresholds.d.ts.map +1 -0
- package/dist/billing-thresholds.js +238 -0
- package/dist/billing-thresholds.js.map +1 -0
- package/dist/billing.d.ts +95 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +239 -0
- package/dist/billing.js.map +1 -0
- package/dist/clerk.d.ts +125 -0
- package/dist/clerk.d.ts.map +1 -0
- package/dist/clerk.js +389 -0
- package/dist/clerk.js.map +1 -0
- package/dist/client.d.ts +35 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +75 -0
- package/dist/client.js.map +1 -0
- package/dist/credits.d.ts +165 -0
- package/dist/credits.d.ts.map +1 -0
- package/dist/credits.js +483 -0
- package/dist/credits.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/intelligence.d.ts +4 -0
- package/dist/intelligence.d.ts.map +1 -0
- package/dist/intelligence.js +899 -0
- package/dist/intelligence.js.map +1 -0
- package/dist/list-recent-ocs-events.d.ts +48 -0
- package/dist/list-recent-ocs-events.d.ts.map +1 -0
- package/dist/list-recent-ocs-events.js +160 -0
- package/dist/list-recent-ocs-events.js.map +1 -0
- package/dist/manus-client.d.ts +429 -0
- package/dist/manus-client.d.ts.map +1 -0
- package/dist/manus-client.js +401 -0
- package/dist/manus-client.js.map +1 -0
- package/dist/manus-common.d.ts +5 -0
- package/dist/manus-common.d.ts.map +1 -0
- package/dist/manus-common.js +5 -0
- package/dist/manus-common.js.map +1 -0
- package/dist/manus-schedule.d.ts +74 -0
- package/dist/manus-schedule.d.ts.map +1 -0
- package/dist/manus-schedule.js +213 -0
- package/dist/manus-schedule.js.map +1 -0
- package/dist/manus-usage.d.ts +32 -0
- package/dist/manus-usage.d.ts.map +1 -0
- package/dist/manus-usage.js +120 -0
- package/dist/manus-usage.js.map +1 -0
- package/dist/manus-webhook.d.ts +60 -0
- package/dist/manus-webhook.d.ts.map +1 -0
- package/dist/manus-webhook.js +361 -0
- package/dist/manus-webhook.js.map +1 -0
- package/dist/pricing-tools.d.ts +26 -0
- package/dist/pricing-tools.d.ts.map +1 -0
- package/dist/pricing-tools.js +428 -0
- package/dist/pricing-tools.js.map +1 -0
- package/dist/projects-tools.d.ts +39 -0
- package/dist/projects-tools.d.ts.map +1 -0
- package/dist/projects-tools.js +545 -0
- package/dist/projects-tools.js.map +1 -0
- package/dist/prompts.d.ts +7 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +151 -0
- package/dist/prompts.js.map +1 -0
- package/dist/stripe-connect-tools.d.ts +33 -0
- package/dist/stripe-connect-tools.d.ts.map +1 -0
- package/dist/stripe-connect-tools.js +504 -0
- package/dist/stripe-connect-tools.js.map +1 -0
- package/dist/timing-safe-equal.d.ts +5 -0
- package/dist/timing-safe-equal.d.ts.map +1 -0
- package/dist/timing-safe-equal.js +13 -0
- package/dist/timing-safe-equal.js.map +1 -0
- package/dist/tools-backlog.d.ts +28 -0
- package/dist/tools-backlog.d.ts.map +1 -0
- package/dist/tools-backlog.js +315 -0
- package/dist/tools-backlog.js.map +1 -0
- package/dist/tools-carrier-ask.d.ts +138 -0
- package/dist/tools-carrier-ask.d.ts.map +1 -0
- package/dist/tools-carrier-ask.js +913 -0
- package/dist/tools-carrier-ask.js.map +1 -0
- package/dist/tools-pricing.d.ts +18 -0
- package/dist/tools-pricing.d.ts.map +1 -0
- package/dist/tools-pricing.js +172 -0
- package/dist/tools-pricing.js.map +1 -0
- package/dist/tools-ui-agent-ask.d.ts +29 -0
- package/dist/tools-ui-agent-ask.d.ts.map +1 -0
- package/dist/tools-ui-agent-ask.js +272 -0
- package/dist/tools-ui-agent-ask.js.map +1 -0
- package/dist/tools-ui-agent-schedule.d.ts +29 -0
- package/dist/tools-ui-agent-schedule.d.ts.map +1 -0
- package/dist/tools-ui-agent-schedule.js +517 -0
- package/dist/tools-ui-agent-schedule.js.map +1 -0
- package/dist/tools-ui-agent.d.ts +40 -0
- package/dist/tools-ui-agent.d.ts.map +1 -0
- package/dist/tools-ui-agent.js +508 -0
- package/dist/tools-ui-agent.js.map +1 -0
- package/dist/tools.d.ts +60 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +1295 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +291 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -7
- package/index.js +0 -1
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Carrier MCP — Pricing & Credits MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Exposes credit management, billing configuration, and usage analytics
|
|
5
|
+
* as MCP tools. These tools allow AI agents and users to:
|
|
6
|
+
* - Check credit balance and usage
|
|
7
|
+
* - Configure billing thresholds
|
|
8
|
+
* - View volume discount status
|
|
9
|
+
* - Manage overage settings
|
|
10
|
+
* - View billing history and projections
|
|
11
|
+
*
|
|
12
|
+
* Inspired by Stripe Projects CLI patterns:
|
|
13
|
+
* - `stripe projects billing show` → credit_balance
|
|
14
|
+
* - `stripe projects upgrade` → upgrade_plan
|
|
15
|
+
* - `stripe projects billing add` → configure_billing
|
|
16
|
+
*/
|
|
17
|
+
import { checkCredits, getCreditSummary, updateCreditConfig, TIER_CREDIT_ALLOTMENTS, SCOPE_CREDIT_COSTS, VOLUME_DISCOUNTS, DAILY_FREE_CREDITS, } from "./credits.js";
|
|
18
|
+
import { getThresholdConfig, updateThresholdConfig, } from "./billing-thresholds.js";
|
|
19
|
+
export const PRICING_TOOLS = [
|
|
20
|
+
// -------------------------------------------------------------------------
|
|
21
|
+
// credit_balance — View current credit balance and usage
|
|
22
|
+
// -------------------------------------------------------------------------
|
|
23
|
+
{
|
|
24
|
+
name: "credit_balance",
|
|
25
|
+
description: "View your current credit balance, daily free credits, overage status, " +
|
|
26
|
+
"volume discount tier, and billing threshold status. Use this to understand " +
|
|
27
|
+
"your current usage and remaining capacity before making API calls.",
|
|
28
|
+
scope: "read",
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {},
|
|
32
|
+
required: [],
|
|
33
|
+
},
|
|
34
|
+
handler: async (env, props) => {
|
|
35
|
+
const tier = props.tier;
|
|
36
|
+
const summary = await getCreditSummary(env, props.sub, tier);
|
|
37
|
+
const creditCheck = await checkCredits(env, props.sub, tier, "read");
|
|
38
|
+
return {
|
|
39
|
+
tier,
|
|
40
|
+
credits: {
|
|
41
|
+
monthly_allotment: summary.ledger.allotment,
|
|
42
|
+
consumed: summary.ledger.consumed,
|
|
43
|
+
remaining: Math.max(0, summary.ledger.allotment - summary.ledger.consumed),
|
|
44
|
+
rollover_applied: summary.ledger.rollover_applied,
|
|
45
|
+
overage_consumed: summary.ledger.overage,
|
|
46
|
+
overage_billed_cents: summary.ledger.overage_billed_cents,
|
|
47
|
+
},
|
|
48
|
+
daily_free: {
|
|
49
|
+
granted: summary.daily_free.granted,
|
|
50
|
+
consumed: summary.daily_free.consumed,
|
|
51
|
+
remaining: Math.max(0, summary.daily_free.granted - summary.daily_free.consumed),
|
|
52
|
+
},
|
|
53
|
+
volume_discount: {
|
|
54
|
+
current_pct: summary.volume_discount_pct,
|
|
55
|
+
next_tier: getNextVolumeDiscountTier(summary.ledger.consumed),
|
|
56
|
+
},
|
|
57
|
+
billing: {
|
|
58
|
+
overages_enabled: summary.config.overages_enabled,
|
|
59
|
+
threshold_triggered: summary.ledger.threshold_triggered,
|
|
60
|
+
billing_threshold_cents: summary.config.billing_threshold_cents,
|
|
61
|
+
overage_rate_cents: summary.config.overage_rate_cents,
|
|
62
|
+
},
|
|
63
|
+
rollover: summary.rollover
|
|
64
|
+
? {
|
|
65
|
+
credits: summary.rollover.credits,
|
|
66
|
+
source_month: summary.rollover.source_month,
|
|
67
|
+
expires_at: summary.rollover.expires_at,
|
|
68
|
+
}
|
|
69
|
+
: null,
|
|
70
|
+
reset_at: creditCheck.reset_at,
|
|
71
|
+
credit_costs: SCOPE_CREDIT_COSTS,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
// -------------------------------------------------------------------------
|
|
76
|
+
// configure_billing — Update billing preferences
|
|
77
|
+
// -------------------------------------------------------------------------
|
|
78
|
+
{
|
|
79
|
+
name: "configure_billing",
|
|
80
|
+
description: "Configure your billing preferences: enable/disable overages, set billing " +
|
|
81
|
+
"thresholds (bill shock prevention), configure notification percentages, " +
|
|
82
|
+
"and set hard spending caps. Pro and Enterprise tiers only.",
|
|
83
|
+
scope: "write",
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
overages_enabled: {
|
|
88
|
+
type: "boolean",
|
|
89
|
+
description: "Enable or disable auto-billed overages when monthly credits are exhausted",
|
|
90
|
+
},
|
|
91
|
+
billing_threshold_cents: {
|
|
92
|
+
type: "number",
|
|
93
|
+
description: "Amount in cents at which an invoice is automatically generated (e.g., 10000 = $100)",
|
|
94
|
+
},
|
|
95
|
+
hard_cap_cents: {
|
|
96
|
+
type: "number",
|
|
97
|
+
description: "Maximum overage spend in cents before overages are paused (0 = no cap)",
|
|
98
|
+
},
|
|
99
|
+
auto_pause_on_cap: {
|
|
100
|
+
type: "boolean",
|
|
101
|
+
description: "Whether to automatically pause overages when hard cap is reached",
|
|
102
|
+
},
|
|
103
|
+
notify_at_pct: {
|
|
104
|
+
type: "array",
|
|
105
|
+
items: { type: "number" },
|
|
106
|
+
description: "Percentage thresholds at which to send notifications (e.g., [50, 80, 95, 100])",
|
|
107
|
+
},
|
|
108
|
+
notification_email: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "Email address for billing threshold notifications",
|
|
111
|
+
},
|
|
112
|
+
webhook_url: {
|
|
113
|
+
type: "string",
|
|
114
|
+
description: "Webhook URL for billing threshold events",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
required: [],
|
|
118
|
+
},
|
|
119
|
+
handler: async (env, props, args) => {
|
|
120
|
+
const tier = props.tier;
|
|
121
|
+
if (tier === "free") {
|
|
122
|
+
return {
|
|
123
|
+
error: "Billing configuration requires Pro or Enterprise tier",
|
|
124
|
+
upgrade_url: "https://mcp.carrier.llc/upgrade",
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Update credit config
|
|
128
|
+
const creditUpdates = {};
|
|
129
|
+
if (typeof args.overages_enabled === "boolean") {
|
|
130
|
+
creditUpdates.overages_enabled = args.overages_enabled;
|
|
131
|
+
}
|
|
132
|
+
if (typeof args.billing_threshold_cents === "number") {
|
|
133
|
+
creditUpdates.billing_threshold_cents = args.billing_threshold_cents;
|
|
134
|
+
}
|
|
135
|
+
if (Array.isArray(args.notify_at_pct)) {
|
|
136
|
+
creditUpdates.notify_at_pct = args.notify_at_pct;
|
|
137
|
+
}
|
|
138
|
+
const updatedCreditConfig = Object.keys(creditUpdates).length > 0
|
|
139
|
+
? await updateCreditConfig(env, props.sub, creditUpdates)
|
|
140
|
+
: await getCreditConfigForSub(env, props.sub, tier);
|
|
141
|
+
// Update threshold config
|
|
142
|
+
const thresholdUpdates = {};
|
|
143
|
+
if (typeof args.hard_cap_cents === "number") {
|
|
144
|
+
thresholdUpdates.hard_cap_cents = args.hard_cap_cents;
|
|
145
|
+
}
|
|
146
|
+
if (typeof args.auto_pause_on_cap === "boolean") {
|
|
147
|
+
thresholdUpdates.auto_pause_on_cap = args.auto_pause_on_cap;
|
|
148
|
+
}
|
|
149
|
+
if (typeof args.notification_email === "string") {
|
|
150
|
+
thresholdUpdates.notification_email = args.notification_email;
|
|
151
|
+
}
|
|
152
|
+
if (typeof args.webhook_url === "string") {
|
|
153
|
+
thresholdUpdates.webhook_url = args.webhook_url;
|
|
154
|
+
}
|
|
155
|
+
const updatedThresholdConfig = Object.keys(thresholdUpdates).length > 0
|
|
156
|
+
? await updateThresholdConfig(env, props.sub, thresholdUpdates)
|
|
157
|
+
: await getThresholdConfig(env, props.sub, tier);
|
|
158
|
+
return {
|
|
159
|
+
status: "updated",
|
|
160
|
+
credit_config: {
|
|
161
|
+
overages_enabled: updatedCreditConfig.overages_enabled,
|
|
162
|
+
billing_threshold_cents: updatedCreditConfig.billing_threshold_cents,
|
|
163
|
+
overage_rate_cents: updatedCreditConfig.overage_rate_cents,
|
|
164
|
+
notify_at_pct: updatedCreditConfig.notify_at_pct,
|
|
165
|
+
},
|
|
166
|
+
threshold_config: {
|
|
167
|
+
hard_cap_cents: updatedThresholdConfig.hard_cap_cents,
|
|
168
|
+
auto_pause_on_cap: updatedThresholdConfig.auto_pause_on_cap,
|
|
169
|
+
invoice_threshold_cents: updatedThresholdConfig.invoice_threshold_cents,
|
|
170
|
+
notification_email: updatedThresholdConfig.notification_email,
|
|
171
|
+
webhook_url: updatedThresholdConfig.webhook_url,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
// -------------------------------------------------------------------------
|
|
177
|
+
// usage_projection — Project future usage and costs
|
|
178
|
+
// -------------------------------------------------------------------------
|
|
179
|
+
{
|
|
180
|
+
name: "usage_projection",
|
|
181
|
+
description: "Project your credit usage and costs for the remainder of the billing period " +
|
|
182
|
+
"based on current consumption rate. Includes overage cost estimates and " +
|
|
183
|
+
"recommendations for plan changes.",
|
|
184
|
+
scope: "read",
|
|
185
|
+
inputSchema: {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: {
|
|
188
|
+
days_to_project: {
|
|
189
|
+
type: "number",
|
|
190
|
+
description: "Number of days to project forward (default: remaining days in month)",
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
required: [],
|
|
194
|
+
},
|
|
195
|
+
handler: async (env, props, args) => {
|
|
196
|
+
const tier = props.tier;
|
|
197
|
+
const summary = await getCreditSummary(env, props.sub, tier);
|
|
198
|
+
const now = new Date();
|
|
199
|
+
const dayOfMonth = now.getUTCDate();
|
|
200
|
+
const daysInMonth = new Date(now.getUTCFullYear(), now.getUTCMonth() + 1, 0).getUTCDate();
|
|
201
|
+
const daysRemaining = typeof args.days_to_project === "number"
|
|
202
|
+
? args.days_to_project
|
|
203
|
+
: daysInMonth - dayOfMonth;
|
|
204
|
+
// Calculate daily burn rate
|
|
205
|
+
const dailyBurnRate = dayOfMonth > 0 ? summary.ledger.consumed / dayOfMonth : 0;
|
|
206
|
+
const projectedTotal = Math.round(summary.ledger.consumed + dailyBurnRate * daysRemaining);
|
|
207
|
+
const projectedOverage = Math.max(0, projectedTotal - summary.ledger.allotment);
|
|
208
|
+
// Calculate projected overage cost
|
|
209
|
+
const volumeDiscount = getVolumeDiscountForUsage(projectedTotal);
|
|
210
|
+
const effectiveRate = summary.config.overage_rate_cents * (1 - volumeDiscount / 100);
|
|
211
|
+
const projectedOverageCents = Math.round(projectedOverage * effectiveRate);
|
|
212
|
+
// Recommendation
|
|
213
|
+
const recommendation = generateRecommendation(tier, projectedTotal, summary.ledger.allotment, projectedOverageCents);
|
|
214
|
+
return {
|
|
215
|
+
current_period: {
|
|
216
|
+
day_of_month: dayOfMonth,
|
|
217
|
+
days_in_month: daysInMonth,
|
|
218
|
+
days_remaining: daysRemaining,
|
|
219
|
+
},
|
|
220
|
+
usage: {
|
|
221
|
+
consumed_to_date: summary.ledger.consumed,
|
|
222
|
+
daily_burn_rate: Math.round(dailyBurnRate),
|
|
223
|
+
projected_total: projectedTotal,
|
|
224
|
+
allotment: summary.ledger.allotment,
|
|
225
|
+
},
|
|
226
|
+
overage_projection: {
|
|
227
|
+
projected_overage_credits: projectedOverage,
|
|
228
|
+
projected_overage_cents: projectedOverageCents,
|
|
229
|
+
volume_discount_pct: volumeDiscount,
|
|
230
|
+
effective_rate_cents: effectiveRate,
|
|
231
|
+
},
|
|
232
|
+
recommendation,
|
|
233
|
+
};
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
// -------------------------------------------------------------------------
|
|
237
|
+
// pricing_plans — View available plans and pricing
|
|
238
|
+
// -------------------------------------------------------------------------
|
|
239
|
+
{
|
|
240
|
+
name: "pricing_plans",
|
|
241
|
+
description: "View all available Carrier MCP pricing plans with credit allotments, " +
|
|
242
|
+
"features, overage rates, and volume discount tiers. Use this to compare " +
|
|
243
|
+
"plans and understand upgrade benefits.",
|
|
244
|
+
scope: "read",
|
|
245
|
+
inputSchema: {
|
|
246
|
+
type: "object",
|
|
247
|
+
properties: {},
|
|
248
|
+
required: [],
|
|
249
|
+
},
|
|
250
|
+
handler: async (_env, props) => {
|
|
251
|
+
const currentTier = props.tier;
|
|
252
|
+
return {
|
|
253
|
+
current_plan: currentTier,
|
|
254
|
+
plans: [
|
|
255
|
+
{
|
|
256
|
+
id: "free",
|
|
257
|
+
name: "Free",
|
|
258
|
+
price_monthly_cents: 0,
|
|
259
|
+
credits_monthly: TIER_CREDIT_ALLOTMENTS.free,
|
|
260
|
+
daily_free_credits: DAILY_FREE_CREDITS,
|
|
261
|
+
scopes: ["read"],
|
|
262
|
+
features: [
|
|
263
|
+
"5,000 monthly credits",
|
|
264
|
+
"50 daily free credits",
|
|
265
|
+
"Read-only OCS access",
|
|
266
|
+
"Basic fleet monitoring",
|
|
267
|
+
],
|
|
268
|
+
overages: false,
|
|
269
|
+
rollovers: false,
|
|
270
|
+
volume_discounts: false,
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: "pro",
|
|
274
|
+
name: "Pro",
|
|
275
|
+
price_monthly_cents: 4_900,
|
|
276
|
+
credits_monthly: TIER_CREDIT_ALLOTMENTS.pro,
|
|
277
|
+
daily_free_credits: DAILY_FREE_CREDITS,
|
|
278
|
+
scopes: ["read", "write"],
|
|
279
|
+
features: [
|
|
280
|
+
"100,000 monthly credits",
|
|
281
|
+
"50 daily free credits",
|
|
282
|
+
"Read + Write OCS access",
|
|
283
|
+
"Intelligence composites",
|
|
284
|
+
"Auto-billed overages at $0.001/credit",
|
|
285
|
+
"Credit rollovers (unused → next month)",
|
|
286
|
+
"Volume discounts (up to 25% off overages)",
|
|
287
|
+
"Billing thresholds (bill shock prevention)",
|
|
288
|
+
"Configurable hard spending caps",
|
|
289
|
+
"Priority support",
|
|
290
|
+
],
|
|
291
|
+
overages: true,
|
|
292
|
+
rollovers: true,
|
|
293
|
+
volume_discounts: true,
|
|
294
|
+
overage_rate_cents: 0.1,
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
id: "enterprise",
|
|
298
|
+
name: "Enterprise",
|
|
299
|
+
price_monthly_cents: 49_900,
|
|
300
|
+
credits_monthly: "unlimited",
|
|
301
|
+
daily_free_credits: DAILY_FREE_CREDITS,
|
|
302
|
+
scopes: ["read", "write", "admin"],
|
|
303
|
+
features: [
|
|
304
|
+
"Unlimited credits",
|
|
305
|
+
"All OCS scopes (incl. admin)",
|
|
306
|
+
"Intelligence composites",
|
|
307
|
+
"Custom rate limits",
|
|
308
|
+
"SSO / SAML",
|
|
309
|
+
"Dedicated support",
|
|
310
|
+
"SLA guarantee",
|
|
311
|
+
"Custom billing terms",
|
|
312
|
+
],
|
|
313
|
+
overages: false,
|
|
314
|
+
rollovers: false,
|
|
315
|
+
volume_discounts: false,
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
volume_discount_tiers: VOLUME_DISCOUNTS,
|
|
319
|
+
credit_costs: SCOPE_CREDIT_COSTS,
|
|
320
|
+
upgrade_url: "https://mcp.carrier.llc/upgrade",
|
|
321
|
+
};
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
// -------------------------------------------------------------------------
|
|
325
|
+
// billing_events — View recent billing threshold events
|
|
326
|
+
// -------------------------------------------------------------------------
|
|
327
|
+
{
|
|
328
|
+
name: "billing_events",
|
|
329
|
+
description: "View recent billing threshold events: notifications, invoice triggers, " +
|
|
330
|
+
"hard cap alerts, and overage pauses. Useful for monitoring spend and " +
|
|
331
|
+
"understanding billing activity.",
|
|
332
|
+
scope: "read",
|
|
333
|
+
inputSchema: {
|
|
334
|
+
type: "object",
|
|
335
|
+
properties: {
|
|
336
|
+
limit: {
|
|
337
|
+
type: "number",
|
|
338
|
+
description: "Maximum number of events to return (default: 20, max: 50)",
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
required: [],
|
|
342
|
+
},
|
|
343
|
+
handler: async (env, props, args) => {
|
|
344
|
+
const limit = Math.min(typeof args.limit === "number" ? args.limit : 20, 50);
|
|
345
|
+
const eventsKey = `threshold:events:${props.sub}`;
|
|
346
|
+
const raw = await env.CARRIER_USERS.get(eventsKey, "json").catch(() => null);
|
|
347
|
+
const events = Array.isArray(raw) ? raw.slice(-limit) : [];
|
|
348
|
+
return {
|
|
349
|
+
events,
|
|
350
|
+
total: events.length,
|
|
351
|
+
threshold_config: await getThresholdConfig(env, props.sub, props.tier),
|
|
352
|
+
};
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
];
|
|
356
|
+
// ---------------------------------------------------------------------------
|
|
357
|
+
// Helpers
|
|
358
|
+
// ---------------------------------------------------------------------------
|
|
359
|
+
function getNextVolumeDiscountTier(consumed) {
|
|
360
|
+
for (const tier of VOLUME_DISCOUNTS) {
|
|
361
|
+
if (consumed < tier.threshold) {
|
|
362
|
+
return {
|
|
363
|
+
threshold: tier.threshold,
|
|
364
|
+
discount_pct: tier.discountPct,
|
|
365
|
+
credits_until: tier.threshold - consumed,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return null; // Already at max discount
|
|
370
|
+
}
|
|
371
|
+
function getVolumeDiscountForUsage(usage) {
|
|
372
|
+
let discount = 0;
|
|
373
|
+
for (const tier of VOLUME_DISCOUNTS) {
|
|
374
|
+
if (usage >= tier.threshold) {
|
|
375
|
+
discount = tier.discountPct;
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return discount;
|
|
382
|
+
}
|
|
383
|
+
function generateRecommendation(tier, projectedTotal, allotment, projectedOverageCents) {
|
|
384
|
+
if (tier === "free" && projectedTotal > allotment * 0.8) {
|
|
385
|
+
return {
|
|
386
|
+
action: "upgrade_to_pro",
|
|
387
|
+
reason: "You're projected to exceed 80% of your free tier credits. " +
|
|
388
|
+
"Pro gives you 100,000 credits/month with overages, rollovers, and volume discounts.",
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
if (tier === "pro" && projectedOverageCents > 4_900) {
|
|
392
|
+
// Overages exceed the cost of Enterprise
|
|
393
|
+
return {
|
|
394
|
+
action: "upgrade_to_enterprise",
|
|
395
|
+
reason: "Your projected overage costs exceed the Enterprise plan price. " +
|
|
396
|
+
"Enterprise gives unlimited credits at $499/month.",
|
|
397
|
+
savings_cents: projectedOverageCents - 4_900 + 4_900, // overage + pro fee vs enterprise
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
if (tier === "pro" && projectedTotal < allotment * 0.3) {
|
|
401
|
+
return {
|
|
402
|
+
action: "no_change",
|
|
403
|
+
reason: "You're using less than 30% of your Pro allotment. " +
|
|
404
|
+
"Unused credits will roll over to next month (up to 2x your allotment).",
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
action: "no_change",
|
|
409
|
+
reason: "Your current plan is well-suited to your usage pattern.",
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
async function getCreditConfigForSub(env, sub, tier) {
|
|
413
|
+
const key = `credits:config:${sub}`;
|
|
414
|
+
const raw = await env.CARRIER_USERS.get(key, "json").catch(() => null);
|
|
415
|
+
if (raw && typeof raw === "object" && "billing_threshold_cents" in raw) {
|
|
416
|
+
return raw;
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
billing_threshold_cents: 10_000,
|
|
420
|
+
overages_enabled: tier !== "free",
|
|
421
|
+
rollovers_enabled: tier !== "free",
|
|
422
|
+
overage_rate_cents: 0.1,
|
|
423
|
+
volume_discount_pct: 0,
|
|
424
|
+
notify_at_pct: [50, 80, 95, 100],
|
|
425
|
+
updated_at: new Date().toISOString(),
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=pricing-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-tools.js","sourceRoot":"","sources":["../src/pricing-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAmBjC,MAAM,CAAC,MAAM,aAAa,GAAqB;IAC7C,4EAA4E;IAC5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IAAI,KAAK,MAAM;QAClC,kBAAkB,EAAE,GAAG;QACvB,mBAAmB,EAAE,CAAC;QACtB,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;QAChC,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Carrier MCP — Projects Tools (Stripe Projects CLI Pattern)
|
|
3
|
+
*
|
|
4
|
+
* Implements the Stripe Projects CLI paradigm for Carrier:
|
|
5
|
+
* - Service catalog browsing (carrier ecosystem services)
|
|
6
|
+
* - Credential vault management (API token rotation, env sync)
|
|
7
|
+
* - Billing management via natural language (upgrade/downgrade)
|
|
8
|
+
* - LLM context generation for AI agent workflows
|
|
9
|
+
* - Multi-environment management (dev/staging/prod)
|
|
10
|
+
*
|
|
11
|
+
* These tools enable AI agents to:
|
|
12
|
+
* 1. Discover and provision Carrier services
|
|
13
|
+
* 2. Manage credentials securely
|
|
14
|
+
* 3. Handle billing operations programmatically
|
|
15
|
+
* 4. Generate context for downstream AI workflows
|
|
16
|
+
*
|
|
17
|
+
* Inspired by: `stripe projects init`, `stripe projects add`, `stripe projects catalog`
|
|
18
|
+
*/
|
|
19
|
+
import type { Env, CarrierProps, ToolScope } from "./types.js";
|
|
20
|
+
import type { Tier } from "./billing.js";
|
|
21
|
+
export interface CarrierService {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
category: string;
|
|
25
|
+
description: string;
|
|
26
|
+
tier_required: Tier;
|
|
27
|
+
scopes_required: string[];
|
|
28
|
+
endpoints: string[];
|
|
29
|
+
docs_url: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ProjectsToolDef {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
scope: ToolScope;
|
|
35
|
+
inputSchema: Record<string, unknown>;
|
|
36
|
+
handler: (env: Env, props: CarrierProps, args: Record<string, unknown>) => Promise<unknown>;
|
|
37
|
+
}
|
|
38
|
+
export declare const PROJECTS_TOOLS: ProjectsToolDef[];
|
|
39
|
+
//# sourceMappingURL=projects-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects-tools.d.ts","sourceRoot":"","sources":["../src/projects-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAOzC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,IAAI,CAAC;IACpB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAyFD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,EAAE,CACP,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB;AAED,eAAO,MAAM,cAAc,EAAE,eAAe,EA+X3C,CAAC"}
|