@open-loyalty/mcp-server 1.5.3 → 1.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/config.d.ts +4 -0
- package/dist/config.js +11 -0
- package/dist/index.js +0 -8
- package/dist/server.js +13 -0
- package/dist/tools/achievement/handlers.js +47 -0
- package/dist/tools/achievement/index.d.ts +11 -4
- package/dist/tools/achievement/index.js +12 -1
- package/dist/tools/achievement/schemas.d.ts +4 -4
- package/dist/tools/achievement/schemas.js +13 -12
- package/dist/tools/admin/handlers.d.ts +48 -0
- package/dist/tools/admin/handlers.js +159 -0
- package/dist/tools/admin/index.d.ts +86 -0
- package/dist/tools/admin/index.js +64 -0
- package/dist/tools/admin/schemas.d.ts +40 -0
- package/dist/tools/admin/schemas.js +40 -0
- package/dist/tools/analytics/handlers.d.ts +42 -0
- package/dist/tools/analytics/handlers.js +282 -0
- package/dist/tools/analytics/index.d.ts +108 -0
- package/dist/tools/analytics/index.js +91 -0
- package/dist/tools/analytics/schemas.d.ts +42 -0
- package/dist/tools/analytics/schemas.js +47 -0
- package/dist/tools/apikey/handlers.d.ts +15 -0
- package/dist/tools/apikey/handlers.js +53 -0
- package/dist/tools/apikey/index.d.ts +41 -0
- package/dist/tools/apikey/index.js +38 -0
- package/dist/tools/apikey/schemas.d.ts +31 -0
- package/dist/tools/apikey/schemas.js +15 -0
- package/dist/tools/audit/handlers.d.ts +20 -0
- package/dist/tools/audit/handlers.js +82 -0
- package/dist/tools/audit/index.d.ts +36 -0
- package/dist/tools/audit/index.js +28 -0
- package/dist/tools/audit/schemas.d.ts +62 -0
- package/dist/tools/audit/schemas.js +18 -0
- package/dist/tools/badge/handlers.d.ts +45 -0
- package/dist/tools/badge/handlers.js +135 -0
- package/dist/tools/badge/index.d.ts +68 -0
- package/dist/tools/badge/index.js +47 -0
- package/dist/tools/badge/schemas.d.ts +37 -0
- package/dist/tools/badge/schemas.js +31 -0
- package/dist/tools/campaign/handlers.js +61 -0
- package/dist/tools/campaign/index.d.ts +12 -0
- package/dist/tools/campaign/index.js +20 -1
- package/dist/tools/campaign/member-handlers.js +37 -1
- package/dist/tools/campaign/schemas.js +16 -14
- package/dist/tools/custom-event/handlers.d.ts +98 -0
- package/dist/tools/custom-event/handlers.js +238 -0
- package/dist/tools/custom-event/index.d.ts +139 -0
- package/dist/tools/custom-event/index.js +78 -0
- package/dist/tools/custom-event/schemas.d.ts +87 -0
- package/dist/tools/custom-event/schemas.js +59 -0
- package/dist/tools/export/handlers.d.ts +29 -0
- package/dist/tools/export/handlers.js +128 -0
- package/dist/tools/export/index.d.ts +56 -0
- package/dist/tools/export/index.js +46 -0
- package/dist/tools/export/schemas.d.ts +42 -0
- package/dist/tools/export/schemas.js +41 -0
- package/dist/tools/import/handlers.d.ts +22 -0
- package/dist/tools/import/handlers.js +123 -0
- package/dist/tools/import/index.d.ts +45 -0
- package/dist/tools/import/index.js +41 -0
- package/dist/tools/import/schemas.d.ts +57 -0
- package/dist/tools/import/schemas.js +39 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +11 -11
- package/dist/tools/member/handlers.js +30 -0
- package/dist/tools/member/index.d.ts +10 -0
- package/dist/tools/member/index.js +10 -0
- package/dist/tools/member/schemas.js +13 -13
- package/dist/tools/points/handlers.js +73 -0
- package/dist/tools/points/index.d.ts +6 -0
- package/dist/tools/points/index.js +6 -0
- package/dist/tools/points/schemas.js +1 -1
- package/dist/tools/referral/index.d.ts +3 -0
- package/dist/tools/referral/index.js +3 -0
- package/dist/tools/reward/handlers.js +21 -13
- package/dist/tools/reward/index.d.ts +9 -0
- package/dist/tools/reward/index.js +12 -1
- package/dist/tools/reward/schemas.js +2 -2
- package/dist/tools/role/handlers.d.ts +35 -0
- package/dist/tools/role/handlers.js +127 -0
- package/dist/tools/role/index.d.ts +99 -0
- package/dist/tools/role/index.js +65 -0
- package/dist/tools/role/schemas.d.ts +56 -0
- package/dist/tools/role/schemas.js +35 -0
- package/dist/tools/segment/handlers.js +68 -1
- package/dist/tools/segment/index.d.ts +9 -0
- package/dist/tools/segment/index.js +13 -0
- package/dist/tools/segment/schemas.js +8 -5
- package/dist/tools/store/handlers.d.ts +25 -0
- package/dist/tools/store/handlers.js +89 -0
- package/dist/tools/store/index.d.ts +55 -0
- package/dist/tools/store/index.js +46 -0
- package/dist/tools/store/schemas.d.ts +38 -0
- package/dist/tools/store/schemas.js +23 -0
- package/dist/tools/tierset/handlers.js +92 -1
- package/dist/tools/tierset/index.d.ts +6 -0
- package/dist/tools/tierset/index.js +8 -1
- package/dist/tools/transaction/handlers.js +40 -0
- package/dist/tools/transaction/index.d.ts +4 -0
- package/dist/tools/transaction/index.js +4 -0
- package/dist/tools/transaction/schemas.js +3 -3
- package/dist/tools/wallet-type/index.d.ts +4 -0
- package/dist/tools/wallet-type/index.js +5 -1
- package/dist/tools/webhook/handlers.d.ts +34 -0
- package/dist/tools/webhook/handlers.js +147 -0
- package/dist/tools/webhook/index.d.ts +97 -0
- package/dist/tools/webhook/index.js +65 -0
- package/dist/tools/webhook/schemas.d.ts +72 -0
- package/dist/tools/{webhook.js → webhook/schemas.js} +0 -140
- package/dist/types/schemas/tierset.js +3 -1
- package/package.json +1 -1
- package/dist/tools/admin.d.ts +0 -165
- package/dist/tools/admin.js +0 -205
- package/dist/tools/analytics.d.ts +0 -180
- package/dist/tools/analytics.js +0 -255
- package/dist/tools/apikey.d.ts +0 -79
- package/dist/tools/apikey.js +0 -85
- package/dist/tools/audit.d.ts +0 -111
- package/dist/tools/audit.js +0 -94
- package/dist/tools/badge.d.ts +0 -143
- package/dist/tools/badge.js +0 -174
- package/dist/tools/custom-event.d.ts +0 -315
- package/dist/tools/custom-event.js +0 -271
- package/dist/tools/export.d.ts +0 -118
- package/dist/tools/export.js +0 -152
- package/dist/tools/import.d.ts +0 -116
- package/dist/tools/import.js +0 -143
- package/dist/tools/role.d.ts +0 -180
- package/dist/tools/role.js +0 -173
- package/dist/tools/store.d.ts +0 -109
- package/dist/tools/store.js +0 -125
- package/dist/tools/webhook.d.ts +0 -192
|
@@ -6,6 +6,7 @@ export declare const walletTypeToolDefinitions: readonly [{
|
|
|
6
6
|
readonly title: "List Point Currencies";
|
|
7
7
|
readonly description: string;
|
|
8
8
|
readonly readOnly: true;
|
|
9
|
+
readonly idempotent: true;
|
|
9
10
|
readonly inputSchema: {
|
|
10
11
|
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
11
12
|
};
|
|
@@ -15,6 +16,7 @@ export declare const walletTypeToolDefinitions: readonly [{
|
|
|
15
16
|
readonly title: "Get Point Currency Details";
|
|
16
17
|
readonly description: string;
|
|
17
18
|
readonly readOnly: true;
|
|
19
|
+
readonly idempotent: true;
|
|
18
20
|
readonly inputSchema: {
|
|
19
21
|
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
20
22
|
walletTypeId: import("zod").ZodString;
|
|
@@ -25,6 +27,7 @@ export declare const walletTypeToolDefinitions: readonly [{
|
|
|
25
27
|
readonly title: "Create Point Currency";
|
|
26
28
|
readonly description: string;
|
|
27
29
|
readonly readOnly: false;
|
|
30
|
+
readonly idempotent: false;
|
|
28
31
|
readonly inputSchema: {
|
|
29
32
|
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
30
33
|
translations: import("zod").ZodObject<{
|
|
@@ -76,6 +79,7 @@ export declare const walletTypeToolDefinitions: readonly [{
|
|
|
76
79
|
}, {
|
|
77
80
|
readonly name: "ol_wallet_type_update";
|
|
78
81
|
readonly title: "Update Point Currency";
|
|
82
|
+
readonly idempotent: true;
|
|
79
83
|
readonly description: string;
|
|
80
84
|
readonly readOnly: false;
|
|
81
85
|
readonly inputSchema: {
|
|
@@ -15,6 +15,7 @@ export const walletTypeToolDefinitions = [
|
|
|
15
15
|
"(code: 'default', units: points) pre-installed. " +
|
|
16
16
|
"Returns walletTypeId (UUID), code (unique identifier like 'default'), and name for each wallet type.",
|
|
17
17
|
readOnly: true,
|
|
18
|
+
idempotent: true,
|
|
18
19
|
inputSchema: WalletTypeListInputSchema,
|
|
19
20
|
handler: walletTypeList,
|
|
20
21
|
},
|
|
@@ -25,6 +26,7 @@ export const walletTypeToolDefinitions = [
|
|
|
25
26
|
"Returns configuration including limits, expiry settings, and translations. " +
|
|
26
27
|
"💡 TIP: Use ol_wallet_type_list() first to find the walletTypeId.",
|
|
27
28
|
readOnly: true,
|
|
29
|
+
idempotent: true,
|
|
28
30
|
inputSchema: WalletTypeGetInputSchema,
|
|
29
31
|
handler: walletTypeGet,
|
|
30
32
|
},
|
|
@@ -36,16 +38,18 @@ export const walletTypeToolDefinitions = [
|
|
|
36
38
|
"1. Point expiration -- 'all_time_active' (never expire, growing financial liability) vs '365' (standard 1-year) vs annual date? " +
|
|
37
39
|
"2. Pending period -- allTimeNotLocked=true (immediate, no fraud protection) vs false + unitDaysLocked (fraud/return protection)? " +
|
|
38
40
|
"3. Negative balance -- allow members to go below zero? (credit risk, default: no) " +
|
|
39
|
-
"REQUIRED: translations.en.name, unitSingularName, unitPluralName, unitDaysExpiryAfter. " +
|
|
41
|
+
"REQUIRED: translations.en.name, unitSingularName, unitPluralName, unitDaysExpiryAfter (STRING value -- '365' not 365, or 'all_time_active' for no expiry). " +
|
|
40
42
|
"NOTE: 'active' and 'limits' not supported at creation -- use ol_wallet_type_update. " +
|
|
41
43
|
"New wallets are blocked for ~2 minutes after creation.",
|
|
42
44
|
readOnly: false,
|
|
45
|
+
idempotent: false,
|
|
43
46
|
inputSchema: WalletTypeCreateInputSchema,
|
|
44
47
|
handler: walletTypeCreate,
|
|
45
48
|
},
|
|
46
49
|
{
|
|
47
50
|
name: "ol_wallet_type_update",
|
|
48
51
|
title: "Update Point Currency",
|
|
52
|
+
idempotent: true,
|
|
49
53
|
description: "Update an existing wallet type's configuration. " +
|
|
50
54
|
"⚠️ IMPORTANT: Only provide fields you want to change - others are preserved. " +
|
|
51
55
|
"⚠️ CANNOT CHANGE: The 'code' field cannot be modified after creation. " +
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { WebhookHeader, WebhookSubscription, WebhookSubscriptionListResponse, WebhookEventTypesResponse } from "./schemas.js";
|
|
2
|
+
export declare function webhookList(input: {
|
|
3
|
+
storeCode?: string;
|
|
4
|
+
page?: number;
|
|
5
|
+
perPage?: number;
|
|
6
|
+
eventName?: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
}): Promise<WebhookSubscriptionListResponse>;
|
|
9
|
+
export declare function webhookCreate(input: {
|
|
10
|
+
storeCode?: string;
|
|
11
|
+
eventName: string;
|
|
12
|
+
url: string;
|
|
13
|
+
headers?: WebhookHeader[];
|
|
14
|
+
}): Promise<{
|
|
15
|
+
webhookSubscriptionId: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function webhookGet(input: {
|
|
18
|
+
storeCode?: string;
|
|
19
|
+
webhookSubscriptionId: string;
|
|
20
|
+
}): Promise<WebhookSubscription>;
|
|
21
|
+
export declare function webhookUpdate(input: {
|
|
22
|
+
storeCode?: string;
|
|
23
|
+
webhookSubscriptionId: string;
|
|
24
|
+
eventName?: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
headers?: WebhookHeader[];
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
export declare function webhookDelete(input: {
|
|
29
|
+
storeCode?: string;
|
|
30
|
+
webhookSubscriptionId: string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
export declare function webhookEvents(input: {
|
|
33
|
+
storeCode?: string;
|
|
34
|
+
}): Promise<WebhookEventTypesResponse>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { apiGet, apiPost, apiPut, apiDelete } from "../../client/http.js";
|
|
2
|
+
import { formatApiError, OpenLoyaltyError } from "../../utils/errors.js";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { getStoreCode } from "../../config.js";
|
|
5
|
+
export async function webhookList(input) {
|
|
6
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
7
|
+
const params = new URLSearchParams();
|
|
8
|
+
if (input.page)
|
|
9
|
+
params.append("_page", String(input.page));
|
|
10
|
+
if (input.perPage)
|
|
11
|
+
params.append("_itemsOnPage", String(input.perPage));
|
|
12
|
+
if (input.eventName)
|
|
13
|
+
params.append("eventName", input.eventName);
|
|
14
|
+
if (input.url)
|
|
15
|
+
params.append("url", input.url);
|
|
16
|
+
const queryString = params.toString();
|
|
17
|
+
const url = `/${storeCode}/webhook/subscription${queryString ? `?${queryString}` : ""}`;
|
|
18
|
+
try {
|
|
19
|
+
const response = await apiGet(url);
|
|
20
|
+
return response;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
|
24
|
+
throw new OpenLoyaltyError({
|
|
25
|
+
code: "STORE_NOT_FOUND",
|
|
26
|
+
message: "No webhook subscriptions found for this store",
|
|
27
|
+
hint: "Use ol_store_list() to verify the store code is correct.",
|
|
28
|
+
relatedTool: "ol_webhook_list",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (axios.isAxiosError(error) && error.response?.status === 403) {
|
|
32
|
+
throw new OpenLoyaltyError({
|
|
33
|
+
code: "WEBHOOK_PERMISSION_DENIED",
|
|
34
|
+
message: "You don't have permission to view webhook subscriptions",
|
|
35
|
+
hint: "Webhook management requires the WEBHOOK:VIEW permission. Use ol_admin_get_permissions() to check your access.",
|
|
36
|
+
relatedTool: "ol_webhook_list",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
throw formatApiError(error, "ol_webhook_list");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function webhookCreate(input) {
|
|
43
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
44
|
+
const payload = {
|
|
45
|
+
eventName: input.eventName,
|
|
46
|
+
url: input.url,
|
|
47
|
+
};
|
|
48
|
+
if (input.headers) {
|
|
49
|
+
payload.headers = input.headers;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const response = await apiPost(`/${storeCode}/webhook/subscription`, { webhookSubscription: payload });
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (axios.isAxiosError(error) && error.response?.status === 400) {
|
|
57
|
+
const allMessages = [error.response?.data?.message || "", ...(error.response?.data?.errors || []).map((e) => e.message)].join(" ").toLowerCase();
|
|
58
|
+
if (allMessages.includes("event") && (allMessages.includes("invalid") || allMessages.includes("choice") || allMessages.includes("not found"))) {
|
|
59
|
+
throw new OpenLoyaltyError({ code: "INVALID_EVENT_NAME", message: `Event name '${input.eventName}' is not valid`,
|
|
60
|
+
hint: "Use ol_webhook_events() to discover available event types before creating subscriptions.", relatedTool: "ol_webhook_create" });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
throw formatApiError(error, "ol_webhook_create");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export async function webhookGet(input) {
|
|
67
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
68
|
+
try {
|
|
69
|
+
const response = await apiGet(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`);
|
|
70
|
+
return response;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
|
74
|
+
throw new OpenLoyaltyError({ code: "NOT_FOUND", message: `Webhook subscription '${input.webhookSubscriptionId}' not found`,
|
|
75
|
+
hint: "Use ol_webhook_list() to find existing webhook subscriptions and their IDs.", relatedTool: "ol_webhook_get" });
|
|
76
|
+
}
|
|
77
|
+
throw formatApiError(error, "ol_webhook_get");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export async function webhookUpdate(input) {
|
|
81
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
82
|
+
const payload = {};
|
|
83
|
+
if (input.eventName)
|
|
84
|
+
payload.eventName = input.eventName;
|
|
85
|
+
if (input.url)
|
|
86
|
+
payload.url = input.url;
|
|
87
|
+
if (input.headers)
|
|
88
|
+
payload.headers = input.headers;
|
|
89
|
+
try {
|
|
90
|
+
await apiPut(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`, { webhookSubscription: payload });
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (axios.isAxiosError(error)) {
|
|
94
|
+
if (error.response?.status === 404) {
|
|
95
|
+
throw new OpenLoyaltyError({ code: "NOT_FOUND", message: `Webhook subscription '${input.webhookSubscriptionId}' not found`,
|
|
96
|
+
hint: "Use ol_webhook_list() to find existing webhook subscriptions and their IDs.", relatedTool: "ol_webhook_update" });
|
|
97
|
+
}
|
|
98
|
+
if (error.response?.status === 400) {
|
|
99
|
+
const allMessages = [error.response?.data?.message || "", ...(error.response?.data?.errors || []).map((e) => e.message)].join(" ").toLowerCase();
|
|
100
|
+
if (allMessages.includes("event") && (allMessages.includes("invalid") || allMessages.includes("choice"))) {
|
|
101
|
+
throw new OpenLoyaltyError({ code: "INVALID_EVENT_NAME", message: `Event name '${input.eventName}' is not valid`,
|
|
102
|
+
hint: "Use ol_webhook_events() to discover available event types.", relatedTool: "ol_webhook_update" });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw formatApiError(error, "ol_webhook_update");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export async function webhookDelete(input) {
|
|
110
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
111
|
+
try {
|
|
112
|
+
await apiDelete(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
|
116
|
+
throw new OpenLoyaltyError({ code: "NOT_FOUND", message: `Webhook subscription '${input.webhookSubscriptionId}' not found`,
|
|
117
|
+
hint: "Use ol_webhook_list() to find existing webhook subscriptions and their IDs.", relatedTool: "ol_webhook_delete" });
|
|
118
|
+
}
|
|
119
|
+
throw formatApiError(error, "ol_webhook_delete");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export async function webhookEvents(input) {
|
|
123
|
+
const storeCode = getStoreCode(input.storeCode);
|
|
124
|
+
try {
|
|
125
|
+
const response = await apiGet(`/${storeCode}/webhook/event`);
|
|
126
|
+
return response;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
|
130
|
+
throw new OpenLoyaltyError({
|
|
131
|
+
code: "STORE_NOT_FOUND",
|
|
132
|
+
message: "Cannot retrieve webhook events - store not found",
|
|
133
|
+
hint: "Use ol_store_list() to verify the store code is correct.",
|
|
134
|
+
relatedTool: "ol_webhook_events",
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (axios.isAxiosError(error) && error.response?.status === 403) {
|
|
138
|
+
throw new OpenLoyaltyError({
|
|
139
|
+
code: "WEBHOOK_PERMISSION_DENIED",
|
|
140
|
+
message: "You don't have permission to view webhook events",
|
|
141
|
+
hint: "Webhook management requires the WEBHOOK:VIEW permission. Use ol_admin_get_permissions() to check your access.",
|
|
142
|
+
relatedTool: "ol_webhook_events",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
throw formatApiError(error, "ol_webhook_events");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export { WebhookListInputSchema, WebhookCreateInputSchema, WebhookGetInputSchema, WebhookUpdateInputSchema, WebhookDeleteInputSchema, WebhookEventsInputSchema, } from "./schemas.js";
|
|
2
|
+
export type { WebhookHeader, WebhookSubscription, WebhookSubscriptionListResponse, WebhookEventTypesResponse, } from "./schemas.js";
|
|
3
|
+
export { webhookList, webhookCreate, webhookGet, webhookUpdate, webhookDelete, webhookEvents, } from "./handlers.js";
|
|
4
|
+
import { webhookList, webhookCreate, webhookGet, webhookUpdate, webhookDelete, webhookEvents } from "./handlers.js";
|
|
5
|
+
export declare const webhookToolDefinitions: readonly [{
|
|
6
|
+
readonly name: "ol_webhook_list";
|
|
7
|
+
readonly title: "List Webhook Subscriptions";
|
|
8
|
+
readonly description: "List webhook subscriptions with optional filtering. Returns paginated list of subscriptions with webhookSubscriptionId, eventName, url, and createdAt.";
|
|
9
|
+
readonly readOnly: true;
|
|
10
|
+
readonly idempotent: true;
|
|
11
|
+
readonly inputSchema: {
|
|
12
|
+
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
13
|
+
page: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
14
|
+
perPage: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
15
|
+
eventName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
16
|
+
url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
|
+
};
|
|
18
|
+
readonly handler: typeof webhookList;
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "ol_webhook_create";
|
|
21
|
+
readonly title: "Create Webhook Subscription";
|
|
22
|
+
readonly description: "Create a new webhook subscription to receive event notifications. Returns webhookSubscriptionId on success. Use webhook_events to discover available event types before creating subscriptions.";
|
|
23
|
+
readonly readOnly: false;
|
|
24
|
+
readonly idempotent: false;
|
|
25
|
+
readonly inputSchema: {
|
|
26
|
+
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
27
|
+
eventName: import("zod").ZodString;
|
|
28
|
+
url: import("zod").ZodEffects<import("zod").ZodString, string, string>;
|
|
29
|
+
headers: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
30
|
+
headerName: import("zod").ZodString;
|
|
31
|
+
headerValue: import("zod").ZodString;
|
|
32
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
33
|
+
headerName: string;
|
|
34
|
+
headerValue: string;
|
|
35
|
+
}, {
|
|
36
|
+
headerName: string;
|
|
37
|
+
headerValue: string;
|
|
38
|
+
}>, "many">>;
|
|
39
|
+
};
|
|
40
|
+
readonly handler: typeof webhookCreate;
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "ol_webhook_get";
|
|
43
|
+
readonly title: "Get Webhook Subscription Details";
|
|
44
|
+
readonly description: "Get full webhook subscription details including headers configuration.";
|
|
45
|
+
readonly readOnly: true;
|
|
46
|
+
readonly idempotent: true;
|
|
47
|
+
readonly inputSchema: {
|
|
48
|
+
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
49
|
+
webhookSubscriptionId: import("zod").ZodString;
|
|
50
|
+
};
|
|
51
|
+
readonly handler: typeof webhookGet;
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "ol_webhook_update";
|
|
54
|
+
readonly title: "Update Webhook Subscription";
|
|
55
|
+
readonly description: "Update a webhook subscription. Can update eventName, url, and headers. Returns void on success (204 No Content).";
|
|
56
|
+
readonly readOnly: false;
|
|
57
|
+
readonly idempotent: true;
|
|
58
|
+
readonly inputSchema: {
|
|
59
|
+
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
60
|
+
webhookSubscriptionId: import("zod").ZodString;
|
|
61
|
+
eventName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
62
|
+
url: import("zod").ZodOptional<import("zod").ZodEffects<import("zod").ZodString, string, string>>;
|
|
63
|
+
headers: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
64
|
+
headerName: import("zod").ZodString;
|
|
65
|
+
headerValue: import("zod").ZodString;
|
|
66
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
67
|
+
headerName: string;
|
|
68
|
+
headerValue: string;
|
|
69
|
+
}, {
|
|
70
|
+
headerName: string;
|
|
71
|
+
headerValue: string;
|
|
72
|
+
}>, "many">>;
|
|
73
|
+
};
|
|
74
|
+
readonly handler: typeof webhookUpdate;
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "ol_webhook_delete";
|
|
77
|
+
readonly title: "Delete Webhook Subscription (Permanent)";
|
|
78
|
+
readonly description: "Delete a webhook subscription. Returns void on success (204 No Content). The subscription will stop receiving events immediately.";
|
|
79
|
+
readonly readOnly: false;
|
|
80
|
+
readonly destructive: true;
|
|
81
|
+
readonly idempotent: true;
|
|
82
|
+
readonly inputSchema: {
|
|
83
|
+
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
84
|
+
webhookSubscriptionId: import("zod").ZodString;
|
|
85
|
+
};
|
|
86
|
+
readonly handler: typeof webhookDelete;
|
|
87
|
+
}, {
|
|
88
|
+
readonly name: "ol_webhook_events";
|
|
89
|
+
readonly title: "List Available Webhook Events";
|
|
90
|
+
readonly description: "Get available webhook event types. Returns list of event names that can be used when creating webhook subscriptions. Use this to discover available events before creating subscriptions.";
|
|
91
|
+
readonly readOnly: true;
|
|
92
|
+
readonly idempotent: true;
|
|
93
|
+
readonly inputSchema: {
|
|
94
|
+
storeCode: import("zod").ZodOptional<import("zod").ZodString>;
|
|
95
|
+
};
|
|
96
|
+
readonly handler: typeof webhookEvents;
|
|
97
|
+
}];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Re-export schemas and types
|
|
2
|
+
export { WebhookListInputSchema, WebhookCreateInputSchema, WebhookGetInputSchema, WebhookUpdateInputSchema, WebhookDeleteInputSchema, WebhookEventsInputSchema, } from "./schemas.js";
|
|
3
|
+
// Re-export handlers
|
|
4
|
+
export { webhookList, webhookCreate, webhookGet, webhookUpdate, webhookDelete, webhookEvents, } from "./handlers.js";
|
|
5
|
+
// Imports for tool definitions
|
|
6
|
+
import { WebhookListInputSchema, WebhookCreateInputSchema, WebhookGetInputSchema, WebhookUpdateInputSchema, WebhookDeleteInputSchema, WebhookEventsInputSchema, } from "./schemas.js";
|
|
7
|
+
import { webhookList, webhookCreate, webhookGet, webhookUpdate, webhookDelete, webhookEvents, } from "./handlers.js";
|
|
8
|
+
// Tool definitions
|
|
9
|
+
export const webhookToolDefinitions = [
|
|
10
|
+
{
|
|
11
|
+
name: "ol_webhook_list",
|
|
12
|
+
title: "List Webhook Subscriptions",
|
|
13
|
+
description: "List webhook subscriptions with optional filtering. Returns paginated list of subscriptions with webhookSubscriptionId, eventName, url, and createdAt.",
|
|
14
|
+
readOnly: true,
|
|
15
|
+
idempotent: true,
|
|
16
|
+
inputSchema: WebhookListInputSchema,
|
|
17
|
+
handler: webhookList,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "ol_webhook_create",
|
|
21
|
+
title: "Create Webhook Subscription",
|
|
22
|
+
description: "Create a new webhook subscription to receive event notifications. Returns webhookSubscriptionId on success. Use webhook_events to discover available event types before creating subscriptions.",
|
|
23
|
+
readOnly: false,
|
|
24
|
+
idempotent: false,
|
|
25
|
+
inputSchema: WebhookCreateInputSchema,
|
|
26
|
+
handler: webhookCreate,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "ol_webhook_get",
|
|
30
|
+
title: "Get Webhook Subscription Details",
|
|
31
|
+
description: "Get full webhook subscription details including headers configuration.",
|
|
32
|
+
readOnly: true,
|
|
33
|
+
idempotent: true,
|
|
34
|
+
inputSchema: WebhookGetInputSchema,
|
|
35
|
+
handler: webhookGet,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "ol_webhook_update",
|
|
39
|
+
title: "Update Webhook Subscription",
|
|
40
|
+
description: "Update a webhook subscription. Can update eventName, url, and headers. Returns void on success (204 No Content).",
|
|
41
|
+
readOnly: false,
|
|
42
|
+
idempotent: true,
|
|
43
|
+
inputSchema: WebhookUpdateInputSchema,
|
|
44
|
+
handler: webhookUpdate,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "ol_webhook_delete",
|
|
48
|
+
title: "Delete Webhook Subscription (Permanent)",
|
|
49
|
+
description: "Delete a webhook subscription. Returns void on success (204 No Content). The subscription will stop receiving events immediately.",
|
|
50
|
+
readOnly: false,
|
|
51
|
+
destructive: true,
|
|
52
|
+
idempotent: true,
|
|
53
|
+
inputSchema: WebhookDeleteInputSchema,
|
|
54
|
+
handler: webhookDelete,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "ol_webhook_events",
|
|
58
|
+
title: "List Available Webhook Events",
|
|
59
|
+
description: "Get available webhook event types. Returns list of event names that can be used when creating webhook subscriptions. Use this to discover available events before creating subscriptions.",
|
|
60
|
+
readOnly: true,
|
|
61
|
+
idempotent: true,
|
|
62
|
+
inputSchema: WebhookEventsInputSchema,
|
|
63
|
+
handler: webhookEvents,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export interface WebhookHeader {
|
|
3
|
+
headerName: string;
|
|
4
|
+
headerValue: string;
|
|
5
|
+
}
|
|
6
|
+
export interface WebhookSubscription {
|
|
7
|
+
webhookSubscriptionId: string;
|
|
8
|
+
eventName: string;
|
|
9
|
+
url: string;
|
|
10
|
+
headers?: WebhookHeader[];
|
|
11
|
+
createdAt?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface WebhookSubscriptionListResponse {
|
|
14
|
+
items: WebhookSubscription[];
|
|
15
|
+
total?: {
|
|
16
|
+
all?: number | string;
|
|
17
|
+
filtered?: number | string;
|
|
18
|
+
estimated?: boolean;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface WebhookEventTypesResponse {
|
|
22
|
+
items: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare const WebhookListInputSchema: {
|
|
25
|
+
storeCode: z.ZodOptional<z.ZodString>;
|
|
26
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
perPage: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
eventName: z.ZodOptional<z.ZodString>;
|
|
29
|
+
url: z.ZodOptional<z.ZodString>;
|
|
30
|
+
};
|
|
31
|
+
export declare const WebhookCreateInputSchema: {
|
|
32
|
+
storeCode: z.ZodOptional<z.ZodString>;
|
|
33
|
+
eventName: z.ZodString;
|
|
34
|
+
url: z.ZodEffects<z.ZodString, string, string>;
|
|
35
|
+
headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
36
|
+
headerName: z.ZodString;
|
|
37
|
+
headerValue: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
headerName: string;
|
|
40
|
+
headerValue: string;
|
|
41
|
+
}, {
|
|
42
|
+
headerName: string;
|
|
43
|
+
headerValue: string;
|
|
44
|
+
}>, "many">>;
|
|
45
|
+
};
|
|
46
|
+
export declare const WebhookGetInputSchema: {
|
|
47
|
+
storeCode: z.ZodOptional<z.ZodString>;
|
|
48
|
+
webhookSubscriptionId: z.ZodString;
|
|
49
|
+
};
|
|
50
|
+
export declare const WebhookUpdateInputSchema: {
|
|
51
|
+
storeCode: z.ZodOptional<z.ZodString>;
|
|
52
|
+
webhookSubscriptionId: z.ZodString;
|
|
53
|
+
eventName: z.ZodOptional<z.ZodString>;
|
|
54
|
+
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
55
|
+
headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
56
|
+
headerName: z.ZodString;
|
|
57
|
+
headerValue: z.ZodString;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
headerName: string;
|
|
60
|
+
headerValue: string;
|
|
61
|
+
}, {
|
|
62
|
+
headerName: string;
|
|
63
|
+
headerValue: string;
|
|
64
|
+
}>, "many">>;
|
|
65
|
+
};
|
|
66
|
+
export declare const WebhookDeleteInputSchema: {
|
|
67
|
+
storeCode: z.ZodOptional<z.ZodString>;
|
|
68
|
+
webhookSubscriptionId: z.ZodString;
|
|
69
|
+
};
|
|
70
|
+
export declare const WebhookEventsInputSchema: {
|
|
71
|
+
storeCode: z.ZodOptional<z.ZodString>;
|
|
72
|
+
};
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { isIP } from "net";
|
|
3
|
-
import { apiGet, apiPost, apiPut, apiDelete } from "../client/http.js";
|
|
4
|
-
import { formatApiError } from "../utils/errors.js";
|
|
5
|
-
import { getStoreCode } from "../config.js";
|
|
6
3
|
/**
|
|
7
4
|
* Check if an IP address is private, loopback, link-local, or otherwise internal.
|
|
8
5
|
* Blocks IPv4 and IPv6 private ranges to prevent SSRF attacks.
|
|
@@ -97,7 +94,6 @@ function isValidWebhookUrl(url) {
|
|
|
97
94
|
const webhookUrlSchema = z.string()
|
|
98
95
|
.url("Must be a valid URL")
|
|
99
96
|
.refine(isValidWebhookUrl, "URL must be an external HTTPS endpoint (no localhost, private IPs, or metadata endpoints)");
|
|
100
|
-
// Input Schemas
|
|
101
97
|
export const WebhookListInputSchema = {
|
|
102
98
|
storeCode: z.string().optional().describe("INTERNAL: Auto-configured from server settings. NEVER ask the user for this value. Only set if the user explicitly requests a different store."),
|
|
103
99
|
page: z.number().optional().describe("Page number (default: 1)."),
|
|
@@ -135,139 +131,3 @@ export const WebhookDeleteInputSchema = {
|
|
|
135
131
|
export const WebhookEventsInputSchema = {
|
|
136
132
|
storeCode: z.string().optional().describe("INTERNAL: Auto-configured from server settings. NEVER ask the user for this value. Only set if the user explicitly requests a different store."),
|
|
137
133
|
};
|
|
138
|
-
// Handler functions
|
|
139
|
-
export async function webhookList(input) {
|
|
140
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
141
|
-
const params = new URLSearchParams();
|
|
142
|
-
if (input.page)
|
|
143
|
-
params.append("_page", String(input.page));
|
|
144
|
-
if (input.perPage)
|
|
145
|
-
params.append("_itemsOnPage", String(input.perPage));
|
|
146
|
-
if (input.eventName)
|
|
147
|
-
params.append("eventName", input.eventName);
|
|
148
|
-
if (input.url)
|
|
149
|
-
params.append("url", input.url);
|
|
150
|
-
const queryString = params.toString();
|
|
151
|
-
const url = `/${storeCode}/webhook/subscription${queryString ? `?${queryString}` : ""}`;
|
|
152
|
-
try {
|
|
153
|
-
const response = await apiGet(url);
|
|
154
|
-
return response;
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
throw formatApiError(error, "ol_webhook_list");
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export async function webhookCreate(input) {
|
|
161
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
162
|
-
const payload = {
|
|
163
|
-
eventName: input.eventName,
|
|
164
|
-
url: input.url,
|
|
165
|
-
};
|
|
166
|
-
if (input.headers) {
|
|
167
|
-
payload.headers = input.headers;
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
const response = await apiPost(`/${storeCode}/webhook/subscription`, { webhookSubscription: payload });
|
|
171
|
-
return response;
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
throw formatApiError(error, "ol_webhook_create");
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
export async function webhookGet(input) {
|
|
178
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
179
|
-
try {
|
|
180
|
-
const response = await apiGet(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`);
|
|
181
|
-
return response;
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
throw formatApiError(error, "ol_webhook_get");
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
export async function webhookUpdate(input) {
|
|
188
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
189
|
-
const payload = {};
|
|
190
|
-
if (input.eventName)
|
|
191
|
-
payload.eventName = input.eventName;
|
|
192
|
-
if (input.url)
|
|
193
|
-
payload.url = input.url;
|
|
194
|
-
if (input.headers)
|
|
195
|
-
payload.headers = input.headers;
|
|
196
|
-
try {
|
|
197
|
-
await apiPut(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`, { webhookSubscription: payload });
|
|
198
|
-
}
|
|
199
|
-
catch (error) {
|
|
200
|
-
throw formatApiError(error, "ol_webhook_update");
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
export async function webhookDelete(input) {
|
|
204
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
205
|
-
try {
|
|
206
|
-
await apiDelete(`/${storeCode}/webhook/subscription/${input.webhookSubscriptionId}`);
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
throw formatApiError(error, "ol_webhook_delete");
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
export async function webhookEvents(input) {
|
|
213
|
-
const storeCode = getStoreCode(input.storeCode);
|
|
214
|
-
try {
|
|
215
|
-
const response = await apiGet(`/${storeCode}/webhook/event`);
|
|
216
|
-
return response;
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
throw formatApiError(error, "ol_webhook_events");
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
// Tool definitions
|
|
223
|
-
export const webhookToolDefinitions = [
|
|
224
|
-
{
|
|
225
|
-
name: "ol_webhook_list",
|
|
226
|
-
title: "List Webhook Subscriptions",
|
|
227
|
-
description: "List webhook subscriptions with optional filtering. Returns paginated list of subscriptions with webhookSubscriptionId, eventName, url, and createdAt.",
|
|
228
|
-
readOnly: true,
|
|
229
|
-
inputSchema: WebhookListInputSchema,
|
|
230
|
-
handler: webhookList,
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
name: "ol_webhook_create",
|
|
234
|
-
title: "Create Webhook Subscription",
|
|
235
|
-
description: "Create a new webhook subscription to receive event notifications. Returns webhookSubscriptionId on success. Use webhook_events to discover available event types before creating subscriptions.",
|
|
236
|
-
readOnly: false,
|
|
237
|
-
inputSchema: WebhookCreateInputSchema,
|
|
238
|
-
handler: webhookCreate,
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: "ol_webhook_get",
|
|
242
|
-
title: "Get Webhook Subscription Details",
|
|
243
|
-
description: "Get full webhook subscription details including headers configuration.",
|
|
244
|
-
readOnly: true,
|
|
245
|
-
inputSchema: WebhookGetInputSchema,
|
|
246
|
-
handler: webhookGet,
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
name: "ol_webhook_update",
|
|
250
|
-
title: "Update Webhook Subscription",
|
|
251
|
-
description: "Update a webhook subscription. Can update eventName, url, and headers. Returns void on success (204 No Content).",
|
|
252
|
-
readOnly: false,
|
|
253
|
-
inputSchema: WebhookUpdateInputSchema,
|
|
254
|
-
handler: webhookUpdate,
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
name: "ol_webhook_delete",
|
|
258
|
-
title: "Delete Webhook Subscription (Permanent)",
|
|
259
|
-
description: "Delete a webhook subscription. Returns void on success (204 No Content). The subscription will stop receiving events immediately.",
|
|
260
|
-
readOnly: false,
|
|
261
|
-
destructive: true,
|
|
262
|
-
inputSchema: WebhookDeleteInputSchema,
|
|
263
|
-
handler: webhookDelete,
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
name: "ol_webhook_events",
|
|
267
|
-
title: "List Available Webhook Events",
|
|
268
|
-
description: "Get available webhook event types. Returns list of event names that can be used when creating webhook subscriptions. Use this to discover available events before creating subscriptions.",
|
|
269
|
-
readOnly: true,
|
|
270
|
-
inputSchema: WebhookEventsInputSchema,
|
|
271
|
-
handler: webhookEvents,
|
|
272
|
-
},
|
|
273
|
-
];
|
|
@@ -58,4 +58,6 @@ export const TierSetListResponseSchema = z.object({
|
|
|
58
58
|
items: z.array(TierSetListItemSchema),
|
|
59
59
|
total: TotalSchema,
|
|
60
60
|
});
|
|
61
|
-
export const DowngradeModeEnum = z.enum(["none", "automatic", "x_days"])
|
|
61
|
+
export const DowngradeModeEnum = z.enum(["none", "automatic", "x_days"]).describe("Downgrade mode: 'none' = members never lose tier status, " +
|
|
62
|
+
"'automatic' = immediate downgrade when conditions are no longer met, " +
|
|
63
|
+
"'x_days' = downgrade after a grace period (set days in downgrade.days).");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-loyalty/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP server for Open Loyalty API - enables AI agents to manage loyalty programs, members, points, rewards, and transactions",
|
|
6
6
|
"author": "Marcin Dyguda <md@openloyalty.io>",
|