@usethrottle/mcp 0.5.1 → 0.7.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 +1 -0
- package/dist/contract-index.json +1 -1
- package/dist/docs-index.json +1 -1
- package/dist/lib.cjs +178 -1
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.d.cts +1 -0
- package/dist/lib.d.ts +1 -0
- package/dist/lib.js +178 -1
- package/dist/lib.js.map +1 -1
- package/dist/mcp.js +178 -1
- package/dist/mcp.js.map +1 -1
- package/package.json +2 -2
package/dist/mcp.js
CHANGED
|
@@ -118,6 +118,10 @@ var ThrottleClient = class {
|
|
|
118
118
|
const body = await this.requestJson("PATCH", path, options);
|
|
119
119
|
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
120
120
|
}
|
|
121
|
+
async delete(path, options = {}) {
|
|
122
|
+
const body = await this.requestJson("DELETE", path, options);
|
|
123
|
+
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
124
|
+
}
|
|
121
125
|
};
|
|
122
126
|
async function optional(load) {
|
|
123
127
|
try {
|
|
@@ -196,6 +200,8 @@ add("Customers", "customer_addresses", ["read", "write"], { read: "View addresse
|
|
|
196
200
|
add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
|
|
197
201
|
add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
|
|
198
202
|
add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
|
|
203
|
+
add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
|
|
204
|
+
REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
|
|
199
205
|
add(
|
|
200
206
|
"Customer accounts",
|
|
201
207
|
"customer_accounts",
|
|
@@ -255,6 +261,7 @@ add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks",
|
|
|
255
261
|
add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
|
|
256
262
|
add("Webhooks & Events", "events", ["read"], { read: "View events" });
|
|
257
263
|
add("Webhooks & Events", "audit_logs", ["read"], { read: "View audit log" });
|
|
264
|
+
add("Webhooks & Events", "activity", ["write"], { write: "Add history entries to records" });
|
|
258
265
|
add("Applications", "applications", ["read", "write"], { read: "View applications", write: "Manage applications" });
|
|
259
266
|
add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
|
|
260
267
|
add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
|
|
@@ -338,6 +345,7 @@ var PREFIX_RULES = [
|
|
|
338
345
|
["quote.", "quotes:read"],
|
|
339
346
|
["return.", "order_returns:read"],
|
|
340
347
|
["payment.", "payments:read"],
|
|
348
|
+
["customer_group.", "customer_groups:read"],
|
|
341
349
|
["customer.", "customers:read"],
|
|
342
350
|
["subscription.", "subscriptions:read"],
|
|
343
351
|
["fulfillment.", "fulfillments:read"],
|
|
@@ -1151,6 +1159,26 @@ var ACTIONS = [
|
|
|
1151
1159
|
"Every sub-read proxies live to the payment provider's routing API and none are guaranteed to succeed together; report any that fail as unavailable rather than failing the whole call."
|
|
1152
1160
|
]
|
|
1153
1161
|
},
|
|
1162
|
+
{
|
|
1163
|
+
id: "get_currency_coverage",
|
|
1164
|
+
title: "Currency coverage",
|
|
1165
|
+
description: "Which currencies this application can actually be paid in: one row per enabled currency (and every currency an active payment service accepts), with the services that take it, whether it is payable, and how it is valued. Open cart and active subscription counts per currency are included only when the key also holds carts:read and subscriptions:read.",
|
|
1166
|
+
kind: "read",
|
|
1167
|
+
scopes: ["connectors:read"],
|
|
1168
|
+
input: [
|
|
1169
|
+
{
|
|
1170
|
+
name: "applicationId",
|
|
1171
|
+
type: "string",
|
|
1172
|
+
required: false,
|
|
1173
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1174
|
+
}
|
|
1175
|
+
],
|
|
1176
|
+
requests: [{ method: "GET", path: "/api/v1/connectors/currency-coverage" }],
|
|
1177
|
+
channels: ["mcp"],
|
|
1178
|
+
guardrails: [
|
|
1179
|
+
"Reads the payment provider live on every call. A currency with payable false is enabled but no active service takes it: a buyer cannot pay in it."
|
|
1180
|
+
]
|
|
1181
|
+
},
|
|
1154
1182
|
{
|
|
1155
1183
|
id: "get_integration_status",
|
|
1156
1184
|
title: "Integration readiness",
|
|
@@ -1557,6 +1585,99 @@ var ACTIONS = [
|
|
|
1557
1585
|
"The updated record is echoed back with email, phone, firstName, lastName and name nulled unless the credential holds customer_pii:read, which OAuth connections cannot hold \u2014 the update still applied, only the response is redacted."
|
|
1558
1586
|
]
|
|
1559
1587
|
},
|
|
1588
|
+
// ------------------------------------------------------------ customer groups
|
|
1589
|
+
{
|
|
1590
|
+
id: "list_customer_groups",
|
|
1591
|
+
title: "List customer groups",
|
|
1592
|
+
description: "List the customer groups of the application (at most 50), with member and discount counts. A customer belongs to at most one group; a group can be fixed or a percent group with a percentBps rate.",
|
|
1593
|
+
kind: "read",
|
|
1594
|
+
scopes: ["customer_groups:read"],
|
|
1595
|
+
input: [],
|
|
1596
|
+
requests: [{ method: "GET", path: "/api/v1/customer-groups" }],
|
|
1597
|
+
channels: ["mcp"]
|
|
1598
|
+
},
|
|
1599
|
+
{
|
|
1600
|
+
id: "get_customer_group",
|
|
1601
|
+
title: "Get a customer group",
|
|
1602
|
+
description: "Fetch one customer group by id.",
|
|
1603
|
+
kind: "read",
|
|
1604
|
+
scopes: ["customer_groups:read"],
|
|
1605
|
+
input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
|
|
1606
|
+
requests: [{ method: "GET", path: "/api/v1/customer-groups/:id" }],
|
|
1607
|
+
channels: ["mcp"]
|
|
1608
|
+
},
|
|
1609
|
+
{
|
|
1610
|
+
id: "create_customer_group",
|
|
1611
|
+
title: "Create a customer group",
|
|
1612
|
+
description: "Create a customer group. kind is fixed or percent; a percent group requires percentBps (1-10000, 1500 = 15%) and a fixed group must not have one.",
|
|
1613
|
+
kind: "write",
|
|
1614
|
+
scopes: ["customer_groups:write"],
|
|
1615
|
+
input: [
|
|
1616
|
+
{ name: "name", type: "string", required: true, description: "Group name, 1 to 100 characters." },
|
|
1617
|
+
{ name: "kind", type: "string", required: true, description: "fixed or percent." },
|
|
1618
|
+
{ name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. Required for percent groups." },
|
|
1619
|
+
{ name: "enabled", type: "boolean", required: false, description: "Whether the group is active.", default: true }
|
|
1620
|
+
],
|
|
1621
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups" }],
|
|
1622
|
+
channels: ["mcp"],
|
|
1623
|
+
idempotent: true
|
|
1624
|
+
},
|
|
1625
|
+
{
|
|
1626
|
+
id: "update_customer_group",
|
|
1627
|
+
title: "Update a customer group",
|
|
1628
|
+
description: "Change fields on a customer group. Only the fields supplied are touched.",
|
|
1629
|
+
kind: "write",
|
|
1630
|
+
scopes: ["customer_groups:write"],
|
|
1631
|
+
input: [
|
|
1632
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1633
|
+
{ name: "name", type: "string", required: false, description: "Group name, 1 to 100 characters." },
|
|
1634
|
+
{ name: "kind", type: "string", required: false, description: "fixed or percent." },
|
|
1635
|
+
{ name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. To make the group fixed, set kind to fixed (the rate is cleared)." },
|
|
1636
|
+
{ name: "enabled", type: "boolean", required: false, description: "Whether the group is active." }
|
|
1637
|
+
],
|
|
1638
|
+
requests: [{ method: "PATCH", path: "/api/v1/customer-groups/:id" }],
|
|
1639
|
+
channels: ["mcp"],
|
|
1640
|
+
idempotent: true
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
id: "delete_customer_group",
|
|
1644
|
+
title: "Delete a customer group",
|
|
1645
|
+
description: "Delete a customer group. Its members are removed from it; the response reports removedMemberCount.",
|
|
1646
|
+
kind: "write",
|
|
1647
|
+
scopes: ["customer_groups:write"],
|
|
1648
|
+
input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
|
|
1649
|
+
requests: [{ method: "DELETE", path: "/api/v1/customer-groups/:id" }],
|
|
1650
|
+
channels: ["mcp"],
|
|
1651
|
+
idempotent: true
|
|
1652
|
+
},
|
|
1653
|
+
{
|
|
1654
|
+
id: "add_customer_group_members",
|
|
1655
|
+
title: "Add customers to a group",
|
|
1656
|
+
description: "Add up to 100 customers to a group. A customer already in another group is moved; the response counts added and moved.",
|
|
1657
|
+
kind: "write",
|
|
1658
|
+
scopes: ["customer_groups:write"],
|
|
1659
|
+
input: [
|
|
1660
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1661
|
+
{ name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
|
|
1662
|
+
],
|
|
1663
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members" }],
|
|
1664
|
+
channels: ["mcp"],
|
|
1665
|
+
idempotent: true
|
|
1666
|
+
},
|
|
1667
|
+
{
|
|
1668
|
+
id: "remove_customer_group_members",
|
|
1669
|
+
title: "Remove customers from a group",
|
|
1670
|
+
description: "Remove up to 100 customers from a group; the response counts removed.",
|
|
1671
|
+
kind: "write",
|
|
1672
|
+
scopes: ["customer_groups:write"],
|
|
1673
|
+
input: [
|
|
1674
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1675
|
+
{ name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
|
|
1676
|
+
],
|
|
1677
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members/remove" }],
|
|
1678
|
+
channels: ["mcp"],
|
|
1679
|
+
idempotent: true
|
|
1680
|
+
},
|
|
1560
1681
|
{
|
|
1561
1682
|
id: "create_checkout_link",
|
|
1562
1683
|
title: "Create a checkout link",
|
|
@@ -1879,6 +2000,9 @@ details: ${JSON.stringify(e.details)}` : "";
|
|
|
1879
2000
|
return `Error: ${e?.message ?? String(error)}`;
|
|
1880
2001
|
}
|
|
1881
2002
|
|
|
2003
|
+
// src/handlers.ts
|
|
2004
|
+
import { randomUUID } from "crypto";
|
|
2005
|
+
|
|
1882
2006
|
// src/contract.ts
|
|
1883
2007
|
var RETIRED_FIELDS = {
|
|
1884
2008
|
storeId: "applicationId",
|
|
@@ -2402,6 +2526,27 @@ var HANDLERS = {
|
|
|
2402
2526
|
},
|
|
2403
2527
|
idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
|
|
2404
2528
|
}),
|
|
2529
|
+
// ----------------------------------------------------------- customer groups
|
|
2530
|
+
list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
|
|
2531
|
+
get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
|
|
2532
|
+
create_customer_group: async (ctx, args) => ctx.client.post("/api/v1/customer-groups", {
|
|
2533
|
+
body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled },
|
|
2534
|
+
// Never put the merchant-written name in a header: non-Latin-1 chars make fetch throw.
|
|
2535
|
+
idempotencyKey: `mcp-create-customer-group-${Date.now()}-${randomUUID()}`
|
|
2536
|
+
}),
|
|
2537
|
+
// A null percentBps is meaningful (fixed group), so only `undefined` is dropped.
|
|
2538
|
+
update_customer_group: async (ctx, args) => ctx.client.patch(`/api/v1/customer-groups/${String(args.id)}`, {
|
|
2539
|
+
body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled }
|
|
2540
|
+
}),
|
|
2541
|
+
delete_customer_group: async (ctx, args) => ctx.client.delete(`/api/v1/customer-groups/${String(args.id)}`),
|
|
2542
|
+
add_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members`, {
|
|
2543
|
+
body: { customerIds: args.customerIds },
|
|
2544
|
+
idempotencyKey: `mcp-add-customer-group-members-${Date.now()}-${randomUUID()}`
|
|
2545
|
+
}),
|
|
2546
|
+
remove_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members/remove`, {
|
|
2547
|
+
body: { customerIds: args.customerIds },
|
|
2548
|
+
idempotencyKey: `mcp-remove-customer-group-members-${Date.now()}-${randomUUID()}`
|
|
2549
|
+
}),
|
|
2405
2550
|
create_checkout_link: async (ctx, args) => {
|
|
2406
2551
|
const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
|
|
2407
2552
|
if (lineItems.length === 0) {
|
|
@@ -2594,6 +2739,7 @@ var HANDLERS = {
|
|
|
2594
2739
|
otherDecline: otherDecline.ok ? otherDecline.value : otherDecline.unavailable
|
|
2595
2740
|
};
|
|
2596
2741
|
},
|
|
2742
|
+
get_currency_coverage: (ctx, args) => ctx.client.get("/api/v1/connectors/currency-coverage", void 0, { applicationId: args.applicationId }),
|
|
2597
2743
|
get_integration_status: async (ctx, args) => {
|
|
2598
2744
|
const opts = { applicationId: args.applicationId };
|
|
2599
2745
|
const [connectors, endpoints, coverage] = await Promise.all([
|
|
@@ -3398,6 +3544,18 @@ var FULFILLMENT2 = {
|
|
|
3398
3544
|
detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
|
|
3399
3545
|
};
|
|
3400
3546
|
var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
|
|
3547
|
+
var CUSTOMER_GROUP = {
|
|
3548
|
+
id: S,
|
|
3549
|
+
name: T,
|
|
3550
|
+
kind: S,
|
|
3551
|
+
percentBps: S,
|
|
3552
|
+
enabled: S,
|
|
3553
|
+
version: S,
|
|
3554
|
+
memberCount: S,
|
|
3555
|
+
discountCount: S,
|
|
3556
|
+
createdAt: S,
|
|
3557
|
+
updatedAt: S
|
|
3558
|
+
};
|
|
3401
3559
|
var SUBSCRIPTION2 = {
|
|
3402
3560
|
id: S,
|
|
3403
3561
|
status: S,
|
|
@@ -3603,6 +3761,9 @@ var OAUTH_PROJECTIONS = {
|
|
|
3603
3761
|
addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
|
|
3604
3762
|
subscriptions: section([SUBSCRIPTION2])
|
|
3605
3763
|
},
|
|
3764
|
+
// Group names are merchant-written (T); the rest is Throttle-generated.
|
|
3765
|
+
list_customer_groups: [CUSTOMER_GROUP],
|
|
3766
|
+
get_customer_group: CUSTOMER_GROUP,
|
|
3606
3767
|
list_subscriptions: page3(SUBSCRIPTION2),
|
|
3607
3768
|
get_subscription: SUBSCRIPTION2,
|
|
3608
3769
|
search_quotes: page3(QUOTE_SUMMARY2),
|
|
@@ -3724,6 +3885,22 @@ var OAUTH_PROJECTIONS = {
|
|
|
3724
3885
|
otherDecline: section({ rules: [{ errorCode: S, conditions: [{ type: S, op: S, values: [S] }] }] }),
|
|
3725
3886
|
routingConnectors: section([{ id: S, displayName: T, method: S }])
|
|
3726
3887
|
},
|
|
3888
|
+
get_currency_coverage: {
|
|
3889
|
+
mainCurrency: S,
|
|
3890
|
+
connection: S,
|
|
3891
|
+
currencies: [{
|
|
3892
|
+
currency: S,
|
|
3893
|
+
main: S,
|
|
3894
|
+
enabled: S,
|
|
3895
|
+
payable: S,
|
|
3896
|
+
valuation: S,
|
|
3897
|
+
services: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
3898
|
+
usage: { openCarts: S, activeSubscriptions: S }
|
|
3899
|
+
}],
|
|
3900
|
+
services: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
3901
|
+
unknownServices: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
3902
|
+
readAt: S
|
|
3903
|
+
},
|
|
3727
3904
|
get_integration_status: {
|
|
3728
3905
|
environment: { slug: S, kind: S, providerEnvironment: S },
|
|
3729
3906
|
workspace: { name: T, slug: S },
|
|
@@ -3847,7 +4024,7 @@ var OAUTH_PROJECTIONS = {
|
|
|
3847
4024
|
};
|
|
3848
4025
|
|
|
3849
4026
|
// src/server.ts
|
|
3850
|
-
var VERSION = true ? "0.
|
|
4027
|
+
var VERSION = true ? "0.7.0" : "0.0.0-dev";
|
|
3851
4028
|
function registerableActions(policy) {
|
|
3852
4029
|
const isProduction = policy.identity.environment.providerEnvironment === "production";
|
|
3853
4030
|
return actionsForChannel("mcp").filter((action) => {
|