@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/lib.cjs
CHANGED
|
@@ -107,6 +107,8 @@ add("Customers", "customer_addresses", ["read", "write"], { read: "View addresse
|
|
|
107
107
|
add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
|
|
108
108
|
add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
|
|
109
109
|
add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
|
|
110
|
+
add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
|
|
111
|
+
REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
|
|
110
112
|
add(
|
|
111
113
|
"Customer accounts",
|
|
112
114
|
"customer_accounts",
|
|
@@ -166,6 +168,7 @@ add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks",
|
|
|
166
168
|
add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
|
|
167
169
|
add("Webhooks & Events", "events", ["read"], { read: "View events" });
|
|
168
170
|
add("Webhooks & Events", "audit_logs", ["read"], { read: "View audit log" });
|
|
171
|
+
add("Webhooks & Events", "activity", ["write"], { write: "Add history entries to records" });
|
|
169
172
|
add("Applications", "applications", ["read", "write"], { read: "View applications", write: "Manage applications" });
|
|
170
173
|
add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
|
|
171
174
|
add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
|
|
@@ -249,6 +252,7 @@ var PREFIX_RULES = [
|
|
|
249
252
|
["quote.", "quotes:read"],
|
|
250
253
|
["return.", "order_returns:read"],
|
|
251
254
|
["payment.", "payments:read"],
|
|
255
|
+
["customer_group.", "customer_groups:read"],
|
|
252
256
|
["customer.", "customers:read"],
|
|
253
257
|
["subscription.", "subscriptions:read"],
|
|
254
258
|
["fulfillment.", "fulfillments:read"],
|
|
@@ -1062,6 +1066,26 @@ var ACTIONS = [
|
|
|
1062
1066
|
"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."
|
|
1063
1067
|
]
|
|
1064
1068
|
},
|
|
1069
|
+
{
|
|
1070
|
+
id: "get_currency_coverage",
|
|
1071
|
+
title: "Currency coverage",
|
|
1072
|
+
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.",
|
|
1073
|
+
kind: "read",
|
|
1074
|
+
scopes: ["connectors:read"],
|
|
1075
|
+
input: [
|
|
1076
|
+
{
|
|
1077
|
+
name: "applicationId",
|
|
1078
|
+
type: "string",
|
|
1079
|
+
required: false,
|
|
1080
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1081
|
+
}
|
|
1082
|
+
],
|
|
1083
|
+
requests: [{ method: "GET", path: "/api/v1/connectors/currency-coverage" }],
|
|
1084
|
+
channels: ["mcp"],
|
|
1085
|
+
guardrails: [
|
|
1086
|
+
"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."
|
|
1087
|
+
]
|
|
1088
|
+
},
|
|
1065
1089
|
{
|
|
1066
1090
|
id: "get_integration_status",
|
|
1067
1091
|
title: "Integration readiness",
|
|
@@ -1468,6 +1492,99 @@ var ACTIONS = [
|
|
|
1468
1492
|
"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."
|
|
1469
1493
|
]
|
|
1470
1494
|
},
|
|
1495
|
+
// ------------------------------------------------------------ customer groups
|
|
1496
|
+
{
|
|
1497
|
+
id: "list_customer_groups",
|
|
1498
|
+
title: "List customer groups",
|
|
1499
|
+
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.",
|
|
1500
|
+
kind: "read",
|
|
1501
|
+
scopes: ["customer_groups:read"],
|
|
1502
|
+
input: [],
|
|
1503
|
+
requests: [{ method: "GET", path: "/api/v1/customer-groups" }],
|
|
1504
|
+
channels: ["mcp"]
|
|
1505
|
+
},
|
|
1506
|
+
{
|
|
1507
|
+
id: "get_customer_group",
|
|
1508
|
+
title: "Get a customer group",
|
|
1509
|
+
description: "Fetch one customer group by id.",
|
|
1510
|
+
kind: "read",
|
|
1511
|
+
scopes: ["customer_groups:read"],
|
|
1512
|
+
input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
|
|
1513
|
+
requests: [{ method: "GET", path: "/api/v1/customer-groups/:id" }],
|
|
1514
|
+
channels: ["mcp"]
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
id: "create_customer_group",
|
|
1518
|
+
title: "Create a customer group",
|
|
1519
|
+
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.",
|
|
1520
|
+
kind: "write",
|
|
1521
|
+
scopes: ["customer_groups:write"],
|
|
1522
|
+
input: [
|
|
1523
|
+
{ name: "name", type: "string", required: true, description: "Group name, 1 to 100 characters." },
|
|
1524
|
+
{ name: "kind", type: "string", required: true, description: "fixed or percent." },
|
|
1525
|
+
{ name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. Required for percent groups." },
|
|
1526
|
+
{ name: "enabled", type: "boolean", required: false, description: "Whether the group is active.", default: true }
|
|
1527
|
+
],
|
|
1528
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups" }],
|
|
1529
|
+
channels: ["mcp"],
|
|
1530
|
+
idempotent: true
|
|
1531
|
+
},
|
|
1532
|
+
{
|
|
1533
|
+
id: "update_customer_group",
|
|
1534
|
+
title: "Update a customer group",
|
|
1535
|
+
description: "Change fields on a customer group. Only the fields supplied are touched.",
|
|
1536
|
+
kind: "write",
|
|
1537
|
+
scopes: ["customer_groups:write"],
|
|
1538
|
+
input: [
|
|
1539
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1540
|
+
{ name: "name", type: "string", required: false, description: "Group name, 1 to 100 characters." },
|
|
1541
|
+
{ name: "kind", type: "string", required: false, description: "fixed or percent." },
|
|
1542
|
+
{ 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)." },
|
|
1543
|
+
{ name: "enabled", type: "boolean", required: false, description: "Whether the group is active." }
|
|
1544
|
+
],
|
|
1545
|
+
requests: [{ method: "PATCH", path: "/api/v1/customer-groups/:id" }],
|
|
1546
|
+
channels: ["mcp"],
|
|
1547
|
+
idempotent: true
|
|
1548
|
+
},
|
|
1549
|
+
{
|
|
1550
|
+
id: "delete_customer_group",
|
|
1551
|
+
title: "Delete a customer group",
|
|
1552
|
+
description: "Delete a customer group. Its members are removed from it; the response reports removedMemberCount.",
|
|
1553
|
+
kind: "write",
|
|
1554
|
+
scopes: ["customer_groups:write"],
|
|
1555
|
+
input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
|
|
1556
|
+
requests: [{ method: "DELETE", path: "/api/v1/customer-groups/:id" }],
|
|
1557
|
+
channels: ["mcp"],
|
|
1558
|
+
idempotent: true
|
|
1559
|
+
},
|
|
1560
|
+
{
|
|
1561
|
+
id: "add_customer_group_members",
|
|
1562
|
+
title: "Add customers to a group",
|
|
1563
|
+
description: "Add up to 100 customers to a group. A customer already in another group is moved; the response counts added and moved.",
|
|
1564
|
+
kind: "write",
|
|
1565
|
+
scopes: ["customer_groups:write"],
|
|
1566
|
+
input: [
|
|
1567
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1568
|
+
{ name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
|
|
1569
|
+
],
|
|
1570
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members" }],
|
|
1571
|
+
channels: ["mcp"],
|
|
1572
|
+
idempotent: true
|
|
1573
|
+
},
|
|
1574
|
+
{
|
|
1575
|
+
id: "remove_customer_group_members",
|
|
1576
|
+
title: "Remove customers from a group",
|
|
1577
|
+
description: "Remove up to 100 customers from a group; the response counts removed.",
|
|
1578
|
+
kind: "write",
|
|
1579
|
+
scopes: ["customer_groups:write"],
|
|
1580
|
+
input: [
|
|
1581
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1582
|
+
{ name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
|
|
1583
|
+
],
|
|
1584
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members/remove" }],
|
|
1585
|
+
channels: ["mcp"],
|
|
1586
|
+
idempotent: true
|
|
1587
|
+
},
|
|
1471
1588
|
{
|
|
1472
1589
|
id: "create_checkout_link",
|
|
1473
1590
|
title: "Create a checkout link",
|
|
@@ -1790,6 +1907,9 @@ details: ${JSON.stringify(e.details)}` : "";
|
|
|
1790
1907
|
return `Error: ${e?.message ?? String(error)}`;
|
|
1791
1908
|
}
|
|
1792
1909
|
|
|
1910
|
+
// src/handlers.ts
|
|
1911
|
+
var import_node_crypto = require("crypto");
|
|
1912
|
+
|
|
1793
1913
|
// ../errors/dist/index.js
|
|
1794
1914
|
var ThrottleError = class extends Error {
|
|
1795
1915
|
code;
|
|
@@ -1905,6 +2025,10 @@ var ThrottleClient = class {
|
|
|
1905
2025
|
const body = await this.requestJson("PATCH", path, options);
|
|
1906
2026
|
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
1907
2027
|
}
|
|
2028
|
+
async delete(path, options = {}) {
|
|
2029
|
+
const body = await this.requestJson("DELETE", path, options);
|
|
2030
|
+
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
2031
|
+
}
|
|
1908
2032
|
};
|
|
1909
2033
|
async function optional(load) {
|
|
1910
2034
|
try {
|
|
@@ -2440,6 +2564,27 @@ var HANDLERS = {
|
|
|
2440
2564
|
},
|
|
2441
2565
|
idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
|
|
2442
2566
|
}),
|
|
2567
|
+
// ----------------------------------------------------------- customer groups
|
|
2568
|
+
list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
|
|
2569
|
+
get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
|
|
2570
|
+
create_customer_group: async (ctx, args) => ctx.client.post("/api/v1/customer-groups", {
|
|
2571
|
+
body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled },
|
|
2572
|
+
// Never put the merchant-written name in a header: non-Latin-1 chars make fetch throw.
|
|
2573
|
+
idempotencyKey: `mcp-create-customer-group-${Date.now()}-${(0, import_node_crypto.randomUUID)()}`
|
|
2574
|
+
}),
|
|
2575
|
+
// A null percentBps is meaningful (fixed group), so only `undefined` is dropped.
|
|
2576
|
+
update_customer_group: async (ctx, args) => ctx.client.patch(`/api/v1/customer-groups/${String(args.id)}`, {
|
|
2577
|
+
body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled }
|
|
2578
|
+
}),
|
|
2579
|
+
delete_customer_group: async (ctx, args) => ctx.client.delete(`/api/v1/customer-groups/${String(args.id)}`),
|
|
2580
|
+
add_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members`, {
|
|
2581
|
+
body: { customerIds: args.customerIds },
|
|
2582
|
+
idempotencyKey: `mcp-add-customer-group-members-${Date.now()}-${(0, import_node_crypto.randomUUID)()}`
|
|
2583
|
+
}),
|
|
2584
|
+
remove_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members/remove`, {
|
|
2585
|
+
body: { customerIds: args.customerIds },
|
|
2586
|
+
idempotencyKey: `mcp-remove-customer-group-members-${Date.now()}-${(0, import_node_crypto.randomUUID)()}`
|
|
2587
|
+
}),
|
|
2443
2588
|
create_checkout_link: async (ctx, args) => {
|
|
2444
2589
|
const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
|
|
2445
2590
|
if (lineItems.length === 0) {
|
|
@@ -2632,6 +2777,7 @@ var HANDLERS = {
|
|
|
2632
2777
|
otherDecline: otherDecline.ok ? otherDecline.value : otherDecline.unavailable
|
|
2633
2778
|
};
|
|
2634
2779
|
},
|
|
2780
|
+
get_currency_coverage: (ctx, args) => ctx.client.get("/api/v1/connectors/currency-coverage", void 0, { applicationId: args.applicationId }),
|
|
2635
2781
|
get_integration_status: async (ctx, args) => {
|
|
2636
2782
|
const opts = { applicationId: args.applicationId };
|
|
2637
2783
|
const [connectors, endpoints, coverage] = await Promise.all([
|
|
@@ -3519,6 +3665,18 @@ var FULFILLMENT2 = {
|
|
|
3519
3665
|
detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
|
|
3520
3666
|
};
|
|
3521
3667
|
var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
|
|
3668
|
+
var CUSTOMER_GROUP = {
|
|
3669
|
+
id: S,
|
|
3670
|
+
name: T,
|
|
3671
|
+
kind: S,
|
|
3672
|
+
percentBps: S,
|
|
3673
|
+
enabled: S,
|
|
3674
|
+
version: S,
|
|
3675
|
+
memberCount: S,
|
|
3676
|
+
discountCount: S,
|
|
3677
|
+
createdAt: S,
|
|
3678
|
+
updatedAt: S
|
|
3679
|
+
};
|
|
3522
3680
|
var SUBSCRIPTION2 = {
|
|
3523
3681
|
id: S,
|
|
3524
3682
|
status: S,
|
|
@@ -3724,6 +3882,9 @@ var OAUTH_PROJECTIONS = {
|
|
|
3724
3882
|
addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
|
|
3725
3883
|
subscriptions: section([SUBSCRIPTION2])
|
|
3726
3884
|
},
|
|
3885
|
+
// Group names are merchant-written (T); the rest is Throttle-generated.
|
|
3886
|
+
list_customer_groups: [CUSTOMER_GROUP],
|
|
3887
|
+
get_customer_group: CUSTOMER_GROUP,
|
|
3727
3888
|
list_subscriptions: page3(SUBSCRIPTION2),
|
|
3728
3889
|
get_subscription: SUBSCRIPTION2,
|
|
3729
3890
|
search_quotes: page3(QUOTE_SUMMARY2),
|
|
@@ -3845,6 +4006,22 @@ var OAUTH_PROJECTIONS = {
|
|
|
3845
4006
|
otherDecline: section({ rules: [{ errorCode: S, conditions: [{ type: S, op: S, values: [S] }] }] }),
|
|
3846
4007
|
routingConnectors: section([{ id: S, displayName: T, method: S }])
|
|
3847
4008
|
},
|
|
4009
|
+
get_currency_coverage: {
|
|
4010
|
+
mainCurrency: S,
|
|
4011
|
+
connection: S,
|
|
4012
|
+
currencies: [{
|
|
4013
|
+
currency: S,
|
|
4014
|
+
main: S,
|
|
4015
|
+
enabled: S,
|
|
4016
|
+
payable: S,
|
|
4017
|
+
valuation: S,
|
|
4018
|
+
services: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
4019
|
+
usage: { openCarts: S, activeSubscriptions: S }
|
|
4020
|
+
}],
|
|
4021
|
+
services: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
4022
|
+
unknownServices: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
4023
|
+
readAt: S
|
|
4024
|
+
},
|
|
3848
4025
|
get_integration_status: {
|
|
3849
4026
|
environment: { slug: S, kind: S, providerEnvironment: S },
|
|
3850
4027
|
workspace: { name: T, slug: S },
|
|
@@ -3968,7 +4145,7 @@ var OAUTH_PROJECTIONS = {
|
|
|
3968
4145
|
};
|
|
3969
4146
|
|
|
3970
4147
|
// src/server.ts
|
|
3971
|
-
var VERSION = true ? "0.
|
|
4148
|
+
var VERSION = true ? "0.7.0" : "0.0.0-dev";
|
|
3972
4149
|
function registerableActions(policy) {
|
|
3973
4150
|
const isProduction = policy.identity.environment.providerEnvironment === "production";
|
|
3974
4151
|
return actionsForChannel("mcp").filter((action) => {
|