@usethrottle/mcp 0.6.0 → 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/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"],
@@ -1488,6 +1492,99 @@ var ACTIONS = [
1488
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."
1489
1493
  ]
1490
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
+ },
1491
1588
  {
1492
1589
  id: "create_checkout_link",
1493
1590
  title: "Create a checkout link",
@@ -1810,6 +1907,9 @@ details: ${JSON.stringify(e.details)}` : "";
1810
1907
  return `Error: ${e?.message ?? String(error)}`;
1811
1908
  }
1812
1909
 
1910
+ // src/handlers.ts
1911
+ var import_node_crypto = require("crypto");
1912
+
1813
1913
  // ../errors/dist/index.js
1814
1914
  var ThrottleError = class extends Error {
1815
1915
  code;
@@ -1925,6 +2025,10 @@ var ThrottleClient = class {
1925
2025
  const body = await this.requestJson("PATCH", path, options);
1926
2026
  return body && typeof body === "object" && "data" in body ? body.data : body;
1927
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
+ }
1928
2032
  };
1929
2033
  async function optional(load) {
1930
2034
  try {
@@ -2460,6 +2564,27 @@ var HANDLERS = {
2460
2564
  },
2461
2565
  idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
2462
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
+ }),
2463
2588
  create_checkout_link: async (ctx, args) => {
2464
2589
  const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
2465
2590
  if (lineItems.length === 0) {
@@ -3540,6 +3665,18 @@ var FULFILLMENT2 = {
3540
3665
  detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
3541
3666
  };
3542
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
+ };
3543
3680
  var SUBSCRIPTION2 = {
3544
3681
  id: S,
3545
3682
  status: S,
@@ -3745,6 +3882,9 @@ var OAUTH_PROJECTIONS = {
3745
3882
  addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
3746
3883
  subscriptions: section([SUBSCRIPTION2])
3747
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,
3748
3888
  list_subscriptions: page3(SUBSCRIPTION2),
3749
3889
  get_subscription: SUBSCRIPTION2,
3750
3890
  search_quotes: page3(QUOTE_SUMMARY2),
@@ -4005,7 +4145,7 @@ var OAUTH_PROJECTIONS = {
4005
4145
  };
4006
4146
 
4007
4147
  // src/server.ts
4008
- var VERSION = true ? "0.6.0" : "0.0.0-dev";
4148
+ var VERSION = true ? "0.7.0" : "0.0.0-dev";
4009
4149
  function registerableActions(policy) {
4010
4150
  const isProduction = policy.identity.environment.providerEnvironment === "production";
4011
4151
  return actionsForChannel("mcp").filter((action) => {