@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.d.cts
CHANGED
|
@@ -60,6 +60,7 @@ declare class ThrottleClient {
|
|
|
60
60
|
list<T>(path: string, query?: Record<string, unknown>, options?: PerCallOptions): Promise<ListResult<T>>;
|
|
61
61
|
post<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
62
62
|
patch<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
63
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
package/dist/lib.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ declare class ThrottleClient {
|
|
|
60
60
|
list<T>(path: string, query?: Record<string, unknown>, options?: PerCallOptions): Promise<ListResult<T>>;
|
|
61
61
|
post<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
62
62
|
patch<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
63
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
package/dist/lib.js
CHANGED
|
@@ -70,6 +70,8 @@ add("Customers", "customer_addresses", ["read", "write"], { read: "View addresse
|
|
|
70
70
|
add("Customers", "customer_payment_methods", ["read", "write"], { read: "View stored cards", write: "Manage stored cards" }, { sensitive: true });
|
|
71
71
|
add("Customers", "customer_tokens", ["read"], { read: "Check shoppers' sign-in tokens" });
|
|
72
72
|
add("Customers", "customer_directory", ["read"], { read: "Find customers by name or email" }, { sensitive: true });
|
|
73
|
+
add("Customers", "customer_groups", ["read", "write"], { read: "View customer groups", write: "Manage customer groups and members" });
|
|
74
|
+
REG["customer_groups:write"] = { ...REG["customer_groups:write"], extensionAllowed: false };
|
|
73
75
|
add(
|
|
74
76
|
"Customer accounts",
|
|
75
77
|
"customer_accounts",
|
|
@@ -129,6 +131,7 @@ add("Webhooks & Events", "webhooks", ["read", "write"], { read: "View webhooks",
|
|
|
129
131
|
add("Webhooks & Events", "webhook_deliveries", ["read", "write"], { read: "View deliveries", write: "Retry deliveries" });
|
|
130
132
|
add("Webhooks & Events", "events", ["read"], { read: "View events" });
|
|
131
133
|
add("Webhooks & Events", "audit_logs", ["read"], { read: "View audit log" });
|
|
134
|
+
add("Webhooks & Events", "activity", ["write"], { write: "Add history entries to records" });
|
|
132
135
|
add("Applications", "applications", ["read", "write"], { read: "View applications", write: "Manage applications" });
|
|
133
136
|
add("Workspace", "merchant", ["read", "write"], { read: "View workspace settings", write: "Edit workspace settings" });
|
|
134
137
|
add("Workspace", "embed_config", ["read", "write"], { read: "View embed config", write: "Edit embed config" });
|
|
@@ -212,6 +215,7 @@ var PREFIX_RULES = [
|
|
|
212
215
|
["quote.", "quotes:read"],
|
|
213
216
|
["return.", "order_returns:read"],
|
|
214
217
|
["payment.", "payments:read"],
|
|
218
|
+
["customer_group.", "customer_groups:read"],
|
|
215
219
|
["customer.", "customers:read"],
|
|
216
220
|
["subscription.", "subscriptions:read"],
|
|
217
221
|
["fulfillment.", "fulfillments:read"],
|
|
@@ -1025,6 +1029,26 @@ var ACTIONS = [
|
|
|
1025
1029
|
"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."
|
|
1026
1030
|
]
|
|
1027
1031
|
},
|
|
1032
|
+
{
|
|
1033
|
+
id: "get_currency_coverage",
|
|
1034
|
+
title: "Currency coverage",
|
|
1035
|
+
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.",
|
|
1036
|
+
kind: "read",
|
|
1037
|
+
scopes: ["connectors:read"],
|
|
1038
|
+
input: [
|
|
1039
|
+
{
|
|
1040
|
+
name: "applicationId",
|
|
1041
|
+
type: "string",
|
|
1042
|
+
required: false,
|
|
1043
|
+
description: "Application to read from. Defaults to the one this connection was authorized for. Call list_applications to see the others."
|
|
1044
|
+
}
|
|
1045
|
+
],
|
|
1046
|
+
requests: [{ method: "GET", path: "/api/v1/connectors/currency-coverage" }],
|
|
1047
|
+
channels: ["mcp"],
|
|
1048
|
+
guardrails: [
|
|
1049
|
+
"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."
|
|
1050
|
+
]
|
|
1051
|
+
},
|
|
1028
1052
|
{
|
|
1029
1053
|
id: "get_integration_status",
|
|
1030
1054
|
title: "Integration readiness",
|
|
@@ -1431,6 +1455,99 @@ var ACTIONS = [
|
|
|
1431
1455
|
"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."
|
|
1432
1456
|
]
|
|
1433
1457
|
},
|
|
1458
|
+
// ------------------------------------------------------------ customer groups
|
|
1459
|
+
{
|
|
1460
|
+
id: "list_customer_groups",
|
|
1461
|
+
title: "List customer groups",
|
|
1462
|
+
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.",
|
|
1463
|
+
kind: "read",
|
|
1464
|
+
scopes: ["customer_groups:read"],
|
|
1465
|
+
input: [],
|
|
1466
|
+
requests: [{ method: "GET", path: "/api/v1/customer-groups" }],
|
|
1467
|
+
channels: ["mcp"]
|
|
1468
|
+
},
|
|
1469
|
+
{
|
|
1470
|
+
id: "get_customer_group",
|
|
1471
|
+
title: "Get a customer group",
|
|
1472
|
+
description: "Fetch one customer group by id.",
|
|
1473
|
+
kind: "read",
|
|
1474
|
+
scopes: ["customer_groups:read"],
|
|
1475
|
+
input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
|
|
1476
|
+
requests: [{ method: "GET", path: "/api/v1/customer-groups/:id" }],
|
|
1477
|
+
channels: ["mcp"]
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
id: "create_customer_group",
|
|
1481
|
+
title: "Create a customer group",
|
|
1482
|
+
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.",
|
|
1483
|
+
kind: "write",
|
|
1484
|
+
scopes: ["customer_groups:write"],
|
|
1485
|
+
input: [
|
|
1486
|
+
{ name: "name", type: "string", required: true, description: "Group name, 1 to 100 characters." },
|
|
1487
|
+
{ name: "kind", type: "string", required: true, description: "fixed or percent." },
|
|
1488
|
+
{ name: "percentBps", type: "number", required: false, description: "Percent rate in basis points, 1-10000. Required for percent groups." },
|
|
1489
|
+
{ name: "enabled", type: "boolean", required: false, description: "Whether the group is active.", default: true }
|
|
1490
|
+
],
|
|
1491
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups" }],
|
|
1492
|
+
channels: ["mcp"],
|
|
1493
|
+
idempotent: true
|
|
1494
|
+
},
|
|
1495
|
+
{
|
|
1496
|
+
id: "update_customer_group",
|
|
1497
|
+
title: "Update a customer group",
|
|
1498
|
+
description: "Change fields on a customer group. Only the fields supplied are touched.",
|
|
1499
|
+
kind: "write",
|
|
1500
|
+
scopes: ["customer_groups:write"],
|
|
1501
|
+
input: [
|
|
1502
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1503
|
+
{ name: "name", type: "string", required: false, description: "Group name, 1 to 100 characters." },
|
|
1504
|
+
{ name: "kind", type: "string", required: false, description: "fixed or percent." },
|
|
1505
|
+
{ 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)." },
|
|
1506
|
+
{ name: "enabled", type: "boolean", required: false, description: "Whether the group is active." }
|
|
1507
|
+
],
|
|
1508
|
+
requests: [{ method: "PATCH", path: "/api/v1/customer-groups/:id" }],
|
|
1509
|
+
channels: ["mcp"],
|
|
1510
|
+
idempotent: true
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
id: "delete_customer_group",
|
|
1514
|
+
title: "Delete a customer group",
|
|
1515
|
+
description: "Delete a customer group. Its members are removed from it; the response reports removedMemberCount.",
|
|
1516
|
+
kind: "write",
|
|
1517
|
+
scopes: ["customer_groups:write"],
|
|
1518
|
+
input: [{ name: "id", type: "string", required: true, description: "Customer group id." }],
|
|
1519
|
+
requests: [{ method: "DELETE", path: "/api/v1/customer-groups/:id" }],
|
|
1520
|
+
channels: ["mcp"],
|
|
1521
|
+
idempotent: true
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
id: "add_customer_group_members",
|
|
1525
|
+
title: "Add customers to a group",
|
|
1526
|
+
description: "Add up to 100 customers to a group. A customer already in another group is moved; the response counts added and moved.",
|
|
1527
|
+
kind: "write",
|
|
1528
|
+
scopes: ["customer_groups:write"],
|
|
1529
|
+
input: [
|
|
1530
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1531
|
+
{ name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
|
|
1532
|
+
],
|
|
1533
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members" }],
|
|
1534
|
+
channels: ["mcp"],
|
|
1535
|
+
idempotent: true
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
id: "remove_customer_group_members",
|
|
1539
|
+
title: "Remove customers from a group",
|
|
1540
|
+
description: "Remove up to 100 customers from a group; the response counts removed.",
|
|
1541
|
+
kind: "write",
|
|
1542
|
+
scopes: ["customer_groups:write"],
|
|
1543
|
+
input: [
|
|
1544
|
+
{ name: "id", type: "string", required: true, description: "Customer group id." },
|
|
1545
|
+
{ name: "customerIds", type: "array", required: true, description: "Customer ids (1-100)." }
|
|
1546
|
+
],
|
|
1547
|
+
requests: [{ method: "POST", path: "/api/v1/customer-groups/:id/members/remove" }],
|
|
1548
|
+
channels: ["mcp"],
|
|
1549
|
+
idempotent: true
|
|
1550
|
+
},
|
|
1434
1551
|
{
|
|
1435
1552
|
id: "create_checkout_link",
|
|
1436
1553
|
title: "Create a checkout link",
|
|
@@ -1753,6 +1870,9 @@ details: ${JSON.stringify(e.details)}` : "";
|
|
|
1753
1870
|
return `Error: ${e?.message ?? String(error)}`;
|
|
1754
1871
|
}
|
|
1755
1872
|
|
|
1873
|
+
// src/handlers.ts
|
|
1874
|
+
import { randomUUID } from "crypto";
|
|
1875
|
+
|
|
1756
1876
|
// ../errors/dist/index.js
|
|
1757
1877
|
var ThrottleError = class extends Error {
|
|
1758
1878
|
code;
|
|
@@ -1868,6 +1988,10 @@ var ThrottleClient = class {
|
|
|
1868
1988
|
const body = await this.requestJson("PATCH", path, options);
|
|
1869
1989
|
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
1870
1990
|
}
|
|
1991
|
+
async delete(path, options = {}) {
|
|
1992
|
+
const body = await this.requestJson("DELETE", path, options);
|
|
1993
|
+
return body && typeof body === "object" && "data" in body ? body.data : body;
|
|
1994
|
+
}
|
|
1871
1995
|
};
|
|
1872
1996
|
async function optional(load) {
|
|
1873
1997
|
try {
|
|
@@ -2403,6 +2527,27 @@ var HANDLERS = {
|
|
|
2403
2527
|
},
|
|
2404
2528
|
idempotencyKey: `mcp-update-customer-${String(args.id)}-${Date.now()}`
|
|
2405
2529
|
}),
|
|
2530
|
+
// ----------------------------------------------------------- customer groups
|
|
2531
|
+
list_customer_groups: async (ctx) => ctx.client.get("/api/v1/customer-groups"),
|
|
2532
|
+
get_customer_group: async (ctx, args) => ctx.client.get(`/api/v1/customer-groups/${String(args.id)}`),
|
|
2533
|
+
create_customer_group: async (ctx, args) => ctx.client.post("/api/v1/customer-groups", {
|
|
2534
|
+
body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled },
|
|
2535
|
+
// Never put the merchant-written name in a header: non-Latin-1 chars make fetch throw.
|
|
2536
|
+
idempotencyKey: `mcp-create-customer-group-${Date.now()}-${randomUUID()}`
|
|
2537
|
+
}),
|
|
2538
|
+
// A null percentBps is meaningful (fixed group), so only `undefined` is dropped.
|
|
2539
|
+
update_customer_group: async (ctx, args) => ctx.client.patch(`/api/v1/customer-groups/${String(args.id)}`, {
|
|
2540
|
+
body: { name: args.name, kind: args.kind, percentBps: args.percentBps, enabled: args.enabled }
|
|
2541
|
+
}),
|
|
2542
|
+
delete_customer_group: async (ctx, args) => ctx.client.delete(`/api/v1/customer-groups/${String(args.id)}`),
|
|
2543
|
+
add_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members`, {
|
|
2544
|
+
body: { customerIds: args.customerIds },
|
|
2545
|
+
idempotencyKey: `mcp-add-customer-group-members-${Date.now()}-${randomUUID()}`
|
|
2546
|
+
}),
|
|
2547
|
+
remove_customer_group_members: async (ctx, args) => ctx.client.post(`/api/v1/customer-groups/${String(args.id)}/members/remove`, {
|
|
2548
|
+
body: { customerIds: args.customerIds },
|
|
2549
|
+
idempotencyKey: `mcp-remove-customer-group-members-${Date.now()}-${randomUUID()}`
|
|
2550
|
+
}),
|
|
2406
2551
|
create_checkout_link: async (ctx, args) => {
|
|
2407
2552
|
const lineItems = Array.isArray(args.lineItems) ? args.lineItems : [];
|
|
2408
2553
|
if (lineItems.length === 0) {
|
|
@@ -2595,6 +2740,7 @@ var HANDLERS = {
|
|
|
2595
2740
|
otherDecline: otherDecline.ok ? otherDecline.value : otherDecline.unavailable
|
|
2596
2741
|
};
|
|
2597
2742
|
},
|
|
2743
|
+
get_currency_coverage: (ctx, args) => ctx.client.get("/api/v1/connectors/currency-coverage", void 0, { applicationId: args.applicationId }),
|
|
2598
2744
|
get_integration_status: async (ctx, args) => {
|
|
2599
2745
|
const opts = { applicationId: args.applicationId };
|
|
2600
2746
|
const [connectors, endpoints, coverage] = await Promise.all([
|
|
@@ -3482,6 +3628,18 @@ var FULFILLMENT2 = {
|
|
|
3482
3628
|
detail: { carrier: T, serviceLevel: T, trackingNumber: T, trackingUrl: T, shippedAt: S, estimatedDelivery: S, actualDelivery: S }
|
|
3483
3629
|
};
|
|
3484
3630
|
var CUSTOMER = { id: S, netN: S, acceptsMarketing: S, createdAt: S };
|
|
3631
|
+
var CUSTOMER_GROUP = {
|
|
3632
|
+
id: S,
|
|
3633
|
+
name: T,
|
|
3634
|
+
kind: S,
|
|
3635
|
+
percentBps: S,
|
|
3636
|
+
enabled: S,
|
|
3637
|
+
version: S,
|
|
3638
|
+
memberCount: S,
|
|
3639
|
+
discountCount: S,
|
|
3640
|
+
createdAt: S,
|
|
3641
|
+
updatedAt: S
|
|
3642
|
+
};
|
|
3485
3643
|
var SUBSCRIPTION2 = {
|
|
3486
3644
|
id: S,
|
|
3487
3645
|
status: S,
|
|
@@ -3687,6 +3845,9 @@ var OAUTH_PROJECTIONS = {
|
|
|
3687
3845
|
addresses: section([{ id: S, isDefault: S, ...ADDRESS }]),
|
|
3688
3846
|
subscriptions: section([SUBSCRIPTION2])
|
|
3689
3847
|
},
|
|
3848
|
+
// Group names are merchant-written (T); the rest is Throttle-generated.
|
|
3849
|
+
list_customer_groups: [CUSTOMER_GROUP],
|
|
3850
|
+
get_customer_group: CUSTOMER_GROUP,
|
|
3690
3851
|
list_subscriptions: page3(SUBSCRIPTION2),
|
|
3691
3852
|
get_subscription: SUBSCRIPTION2,
|
|
3692
3853
|
search_quotes: page3(QUOTE_SUMMARY2),
|
|
@@ -3808,6 +3969,22 @@ var OAUTH_PROJECTIONS = {
|
|
|
3808
3969
|
otherDecline: section({ rules: [{ errorCode: S, conditions: [{ type: S, op: S, values: [S] }] }] }),
|
|
3809
3970
|
routingConnectors: section([{ id: S, displayName: T, method: S }])
|
|
3810
3971
|
},
|
|
3972
|
+
get_currency_coverage: {
|
|
3973
|
+
mainCurrency: S,
|
|
3974
|
+
connection: S,
|
|
3975
|
+
currencies: [{
|
|
3976
|
+
currency: S,
|
|
3977
|
+
main: S,
|
|
3978
|
+
enabled: S,
|
|
3979
|
+
payable: S,
|
|
3980
|
+
valuation: S,
|
|
3981
|
+
services: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
3982
|
+
usage: { openCarts: S, activeSubscriptions: S }
|
|
3983
|
+
}],
|
|
3984
|
+
services: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
3985
|
+
unknownServices: [{ id: S, displayName: T, method: S, active: S, inherited: S }],
|
|
3986
|
+
readAt: S
|
|
3987
|
+
},
|
|
3811
3988
|
get_integration_status: {
|
|
3812
3989
|
environment: { slug: S, kind: S, providerEnvironment: S },
|
|
3813
3990
|
workspace: { name: T, slug: S },
|
|
@@ -3931,7 +4108,7 @@ var OAUTH_PROJECTIONS = {
|
|
|
3931
4108
|
};
|
|
3932
4109
|
|
|
3933
4110
|
// src/server.ts
|
|
3934
|
-
var VERSION = true ? "0.
|
|
4111
|
+
var VERSION = true ? "0.7.0" : "0.0.0-dev";
|
|
3935
4112
|
function registerableActions(policy) {
|
|
3936
4113
|
const isProduction = policy.identity.environment.providerEnvironment === "production";
|
|
3937
4114
|
return actionsForChannel("mcp").filter((action) => {
|