@usethrottle/mcp 0.4.0 → 0.4.2
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 +14 -7
- package/dist/contract-index.json +1 -1
- package/dist/docs-index.json +1 -1
- package/dist/lib.cjs +67 -3
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.js +67 -3
- package/dist/lib.js.map +1 -1
- package/dist/mcp.js +67 -3
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.cjs
CHANGED
|
@@ -94,6 +94,8 @@ add("Customers", "customers", ["read", "write"], { read: "View customers", write
|
|
|
94
94
|
add("Customers", "customer_pii", ["read"], { read: "View customer PII" }, { sensitive: true });
|
|
95
95
|
add("Customers", "customer_addresses", ["read", "write"], { read: "View addresses", write: "Manage addresses" });
|
|
96
96
|
add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
|
|
97
|
+
add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
|
|
98
|
+
add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
|
|
97
99
|
add(
|
|
98
100
|
"Customer accounts",
|
|
99
101
|
"customer_accounts",
|
|
@@ -226,6 +228,7 @@ var EVENT_SCOPE_OVERRIDES = {
|
|
|
226
228
|
"subscription.invoice_refunded": "payment_refunds:read",
|
|
227
229
|
"payment.disputed": "payment_disputes:read",
|
|
228
230
|
"payment.dispute_cleared": "payment_disputes:read",
|
|
231
|
+
"payment.dispute_lost": "payment_disputes:read",
|
|
229
232
|
"fulfillment.digital.delivered": "fulfillment_digital:read"
|
|
230
233
|
};
|
|
231
234
|
var PREFIX_RULES = [
|
|
@@ -344,6 +347,29 @@ function redactShopperPii(value) {
|
|
|
344
347
|
return walk(value, null, 0);
|
|
345
348
|
}
|
|
346
349
|
|
|
350
|
+
// ../core-scopes/src/public-payment.ts
|
|
351
|
+
var RAW_PROCESSOR_KEYS = ["processorResponse", "gr4vy_payment_method"];
|
|
352
|
+
var RAW = new Set(RAW_PROCESSOR_KEYS);
|
|
353
|
+
function isPlainObject2(value) {
|
|
354
|
+
if (value === null || typeof value !== "object") return false;
|
|
355
|
+
const proto = Object.getPrototypeOf(value);
|
|
356
|
+
return proto === Object.prototype || proto === null;
|
|
357
|
+
}
|
|
358
|
+
function strip(value, depth) {
|
|
359
|
+
if (depth > 32) return value;
|
|
360
|
+
if (Array.isArray(value)) return value.map((v) => strip(v, depth + 1));
|
|
361
|
+
if (!isPlainObject2(value)) return value;
|
|
362
|
+
const out = {};
|
|
363
|
+
for (const [key, child] of Object.entries(value)) {
|
|
364
|
+
if (RAW.has(key)) continue;
|
|
365
|
+
out[key] = strip(child, depth + 1);
|
|
366
|
+
}
|
|
367
|
+
return out;
|
|
368
|
+
}
|
|
369
|
+
function stripRawProcessorData(value) {
|
|
370
|
+
return strip(value, 0);
|
|
371
|
+
}
|
|
372
|
+
|
|
347
373
|
// ../action-catalog/src/actions.ts
|
|
348
374
|
var OAUTH_WITHHELD = "Over an OAuth connection (ChatGPT, Claude) these are withheld, because a buyer can type them: line-item and quote-item names, SKUs and reference ids; company; every address line except the country; the merchant's external ids; notes, messages, reasons and metadata. Describe items by quantity and amount, and say the rest is withheld rather than missing.";
|
|
349
375
|
var ACTIONS = [
|
|
@@ -1356,7 +1382,7 @@ var ACTIONS = [
|
|
|
1356
1382
|
{
|
|
1357
1383
|
id: "create_customer",
|
|
1358
1384
|
title: "Create a customer",
|
|
1359
|
-
description: "Create a customer record.
|
|
1385
|
+
description: "Create a customer record. Email and externalId are each unique per application: a value that already belongs to a customer fails with 409 customer_already_exists rather than returning the existing record, so use search_customers first if the buyer may already exist.",
|
|
1360
1386
|
kind: "write",
|
|
1361
1387
|
scopes: ["customers:write"],
|
|
1362
1388
|
input: [
|
|
@@ -1588,6 +1614,29 @@ var ACTIONS = [
|
|
|
1588
1614
|
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1589
1615
|
idempotent: true
|
|
1590
1616
|
},
|
|
1617
|
+
{
|
|
1618
|
+
id: "set_subscription_payment_method",
|
|
1619
|
+
title: "Change a subscription's card",
|
|
1620
|
+
description: "Set the saved card one subscription renews on. Only that subscription moves; the customer's default card and their other subscriptions stay as they are. Nothing is charged now.",
|
|
1621
|
+
kind: "write",
|
|
1622
|
+
scopes: ["subscriptions:write"],
|
|
1623
|
+
input: [
|
|
1624
|
+
{ name: "id", type: "string", required: true, description: "Subscription id." },
|
|
1625
|
+
{
|
|
1626
|
+
name: "paymentMethodId",
|
|
1627
|
+
type: "string",
|
|
1628
|
+
required: true,
|
|
1629
|
+
description: "One of the subscription customer's saved cards (GET /api/v1/customers/:id/payment-methods): active and in date."
|
|
1630
|
+
}
|
|
1631
|
+
],
|
|
1632
|
+
requests: [{ method: "PATCH", path: "/api/v1/subscriptions/:id/payment-method" }],
|
|
1633
|
+
channels: ["mcp", "zapier", "make", "n8n"],
|
|
1634
|
+
idempotent: true,
|
|
1635
|
+
guardrails: [
|
|
1636
|
+
"Changes which card future renewals charge. Confirm the subscription and the card (brand, last four) with the user first.",
|
|
1637
|
+
"409 payment_method_unusable: the card is not this customer's active, in-date saved card. 409 invalid_state: the subscription is cancelled or completed."
|
|
1638
|
+
]
|
|
1639
|
+
},
|
|
1591
1640
|
{
|
|
1592
1641
|
id: "cancel_subscription",
|
|
1593
1642
|
title: "Cancel a subscription",
|
|
@@ -2426,6 +2475,14 @@ var HANDLERS = {
|
|
|
2426
2475
|
idempotencyKey: `mcp-manage-subscription-${id}-${action}-${Date.now()}`
|
|
2427
2476
|
});
|
|
2428
2477
|
},
|
|
2478
|
+
set_subscription_payment_method: async (ctx, args) => {
|
|
2479
|
+
const id = String(args.id);
|
|
2480
|
+
return ctx.client.patch(`/api/v1/subscriptions/${id}/payment-method`, {
|
|
2481
|
+
// `id` is the path parameter; the body is `.strict()`.
|
|
2482
|
+
body: { paymentMethodId: args.paymentMethodId },
|
|
2483
|
+
idempotencyKey: `mcp-set-subscription-card-${id}-${String(args.paymentMethodId)}-${Date.now()}`
|
|
2484
|
+
});
|
|
2485
|
+
},
|
|
2429
2486
|
create_quote: async (ctx, args) => {
|
|
2430
2487
|
const items = Array.isArray(args.items) ? args.items : [];
|
|
2431
2488
|
if (args.netN !== void 0 && items.some((item) => item && item.recurring)) {
|
|
@@ -2690,6 +2747,7 @@ var DISPLAY_QUALIFIERS = [
|
|
|
2690
2747
|
"Payment processing",
|
|
2691
2748
|
"Disputed",
|
|
2692
2749
|
"Authorization expired",
|
|
2750
|
+
"Chargeback lost",
|
|
2693
2751
|
"Returned",
|
|
2694
2752
|
"Partially returned",
|
|
2695
2753
|
"Delivered",
|
|
@@ -2767,6 +2825,8 @@ var PAYMENT = {
|
|
|
2767
2825
|
cardBrand: S,
|
|
2768
2826
|
disputed: S,
|
|
2769
2827
|
disputeOpenedAt: S,
|
|
2828
|
+
disputeOutcome: S,
|
|
2829
|
+
disputeClosedAt: S,
|
|
2770
2830
|
errorCode: S,
|
|
2771
2831
|
netN: S,
|
|
2772
2832
|
netNSource: S,
|
|
@@ -2829,6 +2889,10 @@ var SUBSCRIPTION = {
|
|
|
2829
2889
|
pendingIntervalCount: S,
|
|
2830
2890
|
scheduleTotal: S,
|
|
2831
2891
|
nextPaymentAmount: S,
|
|
2892
|
+
// A physical subscription (0236): the method is an enum, and the ship-to is
|
|
2893
|
+
// kept to its country like every other address here.
|
|
2894
|
+
deliveryMethod: S,
|
|
2895
|
+
shippingAddress: ADDRESS,
|
|
2832
2896
|
paymentSchedule: [{
|
|
2833
2897
|
index: S,
|
|
2834
2898
|
amount: S,
|
|
@@ -3205,7 +3269,7 @@ var OAUTH_PROJECTIONS = {
|
|
|
3205
3269
|
};
|
|
3206
3270
|
|
|
3207
3271
|
// src/server.ts
|
|
3208
|
-
var VERSION = true ? "0.4.
|
|
3272
|
+
var VERSION = true ? "0.4.2" : "0.0.0-dev";
|
|
3209
3273
|
function registerableActions(policy) {
|
|
3210
3274
|
const isProduction = policy.identity.environment.providerEnvironment === "production";
|
|
3211
3275
|
return actionsForChannel("mcp").filter((action) => {
|
|
@@ -3318,7 +3382,7 @@ function createServer(options) {
|
|
|
3318
3382
|
isError: true
|
|
3319
3383
|
};
|
|
3320
3384
|
}
|
|
3321
|
-
const result = await handler(ctx, args ?? {});
|
|
3385
|
+
const result = stripRawProcessorData(await handler(ctx, args ?? {}));
|
|
3322
3386
|
const shown = redactPii ? redactShopperPii(project(result, OAUTH_PROJECTIONS[action.id])) : result;
|
|
3323
3387
|
return { content: [{ type: "text", text: formatResult(shown) }] };
|
|
3324
3388
|
} catch (error) {
|