@open-loyalty/mcp-server 1.0.2 → 1.1.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.
Files changed (75) hide show
  1. package/dist/client/http.d.ts +5 -0
  2. package/dist/client/http.js +52 -3
  3. package/dist/config.d.ts +16 -2
  4. package/dist/config.js +28 -10
  5. package/dist/http.js +135 -62
  6. package/dist/server.js +8 -5
  7. package/dist/tools/achievement.d.ts +14 -0
  8. package/dist/tools/achievement.js +22 -15
  9. package/dist/tools/admin.d.ts +12 -0
  10. package/dist/tools/admin.js +12 -0
  11. package/dist/tools/analytics.d.ts +18 -0
  12. package/dist/tools/analytics.js +28 -19
  13. package/dist/tools/apikey.d.ts +7 -0
  14. package/dist/tools/apikey.js +7 -0
  15. package/dist/tools/audit.d.ts +4 -0
  16. package/dist/tools/audit.js +4 -0
  17. package/dist/tools/badge.d.ts +8 -0
  18. package/dist/tools/badge.js +13 -9
  19. package/dist/tools/campaign.d.ts +41 -16
  20. package/dist/tools/campaign.js +38 -25
  21. package/dist/tools/export.d.ts +8 -0
  22. package/dist/tools/export.js +13 -8
  23. package/dist/tools/import.d.ts +6 -0
  24. package/dist/tools/import.js +10 -6
  25. package/dist/tools/index.d.ts +3 -11
  26. package/dist/tools/index.js +4 -470
  27. package/dist/tools/member.d.ts +21 -0
  28. package/dist/tools/member.js +56 -62
  29. package/dist/tools/points.d.ts +12 -0
  30. package/dist/tools/points.js +30 -29
  31. package/dist/tools/reward.d.ts +18 -0
  32. package/dist/tools/reward.js +56 -66
  33. package/dist/tools/role.d.ts +20 -1
  34. package/dist/tools/role.js +13 -0
  35. package/dist/tools/segment.d.ts +19 -0
  36. package/dist/tools/segment.js +29 -19
  37. package/dist/tools/store.d.ts +8 -0
  38. package/dist/tools/store.js +8 -0
  39. package/dist/tools/tierset.d.ts +12 -0
  40. package/dist/tools/tierset.js +19 -13
  41. package/dist/tools/transaction.d.ts +12 -4
  42. package/dist/tools/transaction.js +13 -9
  43. package/dist/tools/wallet-type.d.ts +4 -0
  44. package/dist/tools/wallet-type.js +7 -5
  45. package/dist/tools/webhook.d.ts +17 -4
  46. package/dist/tools/webhook.js +58 -15
  47. package/dist/types/schemas/achievement.d.ts +0 -297
  48. package/dist/types/schemas/achievement.js +0 -13
  49. package/dist/types/schemas/admin.d.ts +10 -97
  50. package/dist/types/schemas/admin.js +0 -38
  51. package/dist/types/schemas/badge.d.ts +0 -37
  52. package/dist/types/schemas/badge.js +0 -11
  53. package/dist/types/schemas/campaign.d.ts +0 -648
  54. package/dist/types/schemas/campaign.js +0 -18
  55. package/dist/types/schemas/export.d.ts +0 -17
  56. package/dist/types/schemas/export.js +0 -7
  57. package/dist/types/schemas/member.d.ts +37 -176
  58. package/dist/types/schemas/member.js +0 -27
  59. package/dist/types/schemas/points.d.ts +0 -63
  60. package/dist/types/schemas/points.js +0 -22
  61. package/dist/types/schemas/reward.d.ts +0 -73
  62. package/dist/types/schemas/reward.js +0 -25
  63. package/dist/types/schemas/role.d.ts +0 -100
  64. package/dist/types/schemas/role.js +0 -29
  65. package/dist/types/schemas/segment.d.ts +0 -58
  66. package/dist/types/schemas/segment.js +0 -17
  67. package/dist/types/schemas/tierset.d.ts +0 -176
  68. package/dist/types/schemas/tierset.js +0 -27
  69. package/dist/types/schemas/transaction.d.ts +23 -254
  70. package/dist/types/schemas/transaction.js +0 -7
  71. package/dist/types/schemas/webhook.d.ts +0 -58
  72. package/dist/types/schemas/webhook.js +0 -12
  73. package/dist/utils/payload.d.ts +12 -0
  74. package/dist/utils/payload.js +14 -0
  75. package/package.json +3 -1
@@ -62,7 +62,9 @@ export declare function storeUpdate(input: {
62
62
  }): Promise<void>;
63
63
  export declare const storeToolDefinitions: readonly [{
64
64
  readonly name: "openloyalty_store_list";
65
+ readonly title: "List Stores";
65
66
  readonly description: "List all stores with optional filtering. Returns paginated list of stores with storeId, code, name, currency, and active status. Stores enable multi-tenant loyalty programs. Each store has independent members, campaigns, and settings.";
67
+ readonly readOnly: true;
66
68
  readonly inputSchema: {
67
69
  page: z.ZodOptional<z.ZodNumber>;
68
70
  perPage: z.ZodOptional<z.ZodNumber>;
@@ -73,7 +75,9 @@ export declare const storeToolDefinitions: readonly [{
73
75
  readonly handler: typeof storeList;
74
76
  }, {
75
77
  readonly name: "openloyalty_store_create";
78
+ readonly title: "Create Store";
76
79
  readonly description: "Create a new store for multi-tenant setup. Requires unique code and name. Returns storeId on success.";
80
+ readonly readOnly: false;
77
81
  readonly inputSchema: {
78
82
  code: z.ZodString;
79
83
  name: z.ZodString;
@@ -83,14 +87,18 @@ export declare const storeToolDefinitions: readonly [{
83
87
  readonly handler: typeof storeCreate;
84
88
  }, {
85
89
  readonly name: "openloyalty_store_get";
90
+ readonly title: "Get Store Details";
86
91
  readonly description: "Get full store configuration by ID. Returns storeId, code, name, currency, active status, and timestamps.";
92
+ readonly readOnly: true;
87
93
  readonly inputSchema: {
88
94
  storeId: z.ZodString;
89
95
  };
90
96
  readonly handler: typeof storeGet;
91
97
  }, {
92
98
  readonly name: "openloyalty_store_update";
99
+ readonly title: "Update Store";
93
100
  readonly description: "Update store configuration. Can update name, currency, and active status. Returns void on success (204 No Content).";
101
+ readonly readOnly: false;
94
102
  readonly inputSchema: {
95
103
  storeId: z.ZodString;
96
104
  name: z.ZodOptional<z.ZodString>;
@@ -92,25 +92,33 @@ export async function storeUpdate(input) {
92
92
  export const storeToolDefinitions = [
93
93
  {
94
94
  name: "openloyalty_store_list",
95
+ title: "List Stores",
95
96
  description: "List all stores with optional filtering. Returns paginated list of stores with storeId, code, name, currency, and active status. Stores enable multi-tenant loyalty programs. Each store has independent members, campaigns, and settings.",
97
+ readOnly: true,
96
98
  inputSchema: StoreListInputSchema,
97
99
  handler: storeList,
98
100
  },
99
101
  {
100
102
  name: "openloyalty_store_create",
103
+ title: "Create Store",
101
104
  description: "Create a new store for multi-tenant setup. Requires unique code and name. Returns storeId on success.",
105
+ readOnly: false,
102
106
  inputSchema: StoreCreateInputSchema,
103
107
  handler: storeCreate,
104
108
  },
105
109
  {
106
110
  name: "openloyalty_store_get",
111
+ title: "Get Store Details",
107
112
  description: "Get full store configuration by ID. Returns storeId, code, name, currency, active status, and timestamps.",
113
+ readOnly: true,
108
114
  inputSchema: StoreGetInputSchema,
109
115
  handler: storeGet,
110
116
  },
111
117
  {
112
118
  name: "openloyalty_store_update",
119
+ title: "Update Store",
113
120
  description: "Update store configuration. Can update name, currency, and active status. Returns void on success (204 No Content).",
121
+ readOnly: false,
114
122
  inputSchema: StoreUpdateInputSchema,
115
123
  handler: storeUpdate,
116
124
  },
@@ -168,7 +168,9 @@ export declare function tiersetGetTiers(input: TierSetGetInput): Promise<{
168
168
  }>;
169
169
  export declare const tiersetToolDefinitions: readonly [{
170
170
  readonly name: "openloyalty_tierset_list";
171
+ readonly title: "List Loyalty Programs";
171
172
  readonly description: "List all tier sets. Use tierset_get to fetch conditions needed for defining tiers. Returns tierSetId, name, active status, and tier count for each tier set.";
173
+ readonly readOnly: true;
172
174
  readonly inputSchema: {
173
175
  storeCode: z.ZodOptional<z.ZodString>;
174
176
  page: z.ZodOptional<z.ZodNumber>;
@@ -177,7 +179,9 @@ export declare const tiersetToolDefinitions: readonly [{
177
179
  readonly handler: typeof tiersetList;
178
180
  }, {
179
181
  readonly name: "openloyalty_tierset_create";
182
+ readonly title: "Create Loyalty Program";
180
183
  readonly description: "Create a new tier set (loyalty program structure). After creation, call tierset_get to obtain conditionId values, then tierset_update_tiers to define tier thresholds. Conditions define what metrics are used for tier progression (e.g., activeUnits for points balance).";
184
+ readonly readOnly: false;
181
185
  readonly inputSchema: {
182
186
  storeCode: z.ZodOptional<z.ZodString>;
183
187
  name: z.ZodString;
@@ -207,7 +211,9 @@ export declare const tiersetToolDefinitions: readonly [{
207
211
  readonly handler: typeof tiersetCreate;
208
212
  }, {
209
213
  readonly name: "openloyalty_tierset_get";
214
+ readonly title: "Get Loyalty Program Details";
210
215
  readonly description: "Get tier set details including conditionId values needed for tierset_update_tiers. Returns the full tier set with conditions array containing conditionId for each condition.";
216
+ readonly readOnly: true;
211
217
  readonly inputSchema: {
212
218
  storeCode: z.ZodOptional<z.ZodString>;
213
219
  tierSetId: z.ZodString;
@@ -215,7 +221,9 @@ export declare const tiersetToolDefinitions: readonly [{
215
221
  readonly handler: typeof tiersetGet;
216
222
  }, {
217
223
  readonly name: "openloyalty_tierset_update";
224
+ readonly title: "Update Loyalty Program";
218
225
  readonly description: "Update tier set metadata (name, description, active status, downgrade settings). Does not modify tiers - use tierset_update_tiers for that.";
226
+ readonly readOnly: false;
219
227
  readonly inputSchema: {
220
228
  storeCode: z.ZodOptional<z.ZodString>;
221
229
  tierSetId: z.ZodString;
@@ -236,7 +244,9 @@ export declare const tiersetToolDefinitions: readonly [{
236
244
  readonly handler: typeof tiersetUpdate;
237
245
  }, {
238
246
  readonly name: "openloyalty_tierset_update_tiers";
247
+ readonly title: "Configure Tier Thresholds";
239
248
  readonly description: "Define tier thresholds for a tier set. PREREQUISITE: Call tierset_get first to obtain conditionId values. Each tier's conditions array uses conditionId from the parent tier set plus a threshold value.\n\nExample for a 3-tier program with points-based progression:\n- Bronze tier: conditions: [{ conditionId: \"xxx\", value: 400 }]\n- Silver tier: conditions: [{ conditionId: \"xxx\", value: 800 }]\n- Gold tier: conditions: [{ conditionId: \"xxx\", value: 1200 }]\n\nThe conditionId must match one from tierset_get response.";
249
+ readonly readOnly: false;
240
250
  readonly inputSchema: {
241
251
  storeCode: z.ZodOptional<z.ZodString>;
242
252
  tierSetId: z.ZodString;
@@ -278,7 +288,9 @@ export declare const tiersetToolDefinitions: readonly [{
278
288
  readonly handler: typeof tiersetUpdateTiers;
279
289
  }, {
280
290
  readonly name: "openloyalty_tierset_get_tiers";
291
+ readonly title: "Get Tier Configuration";
281
292
  readonly description: "Get all tiers in a tier set. Returns levelId values that can be used for campaign targeting. Includes each tier's name and condition thresholds.";
293
+ readonly readOnly: true;
282
294
  readonly inputSchema: {
283
295
  storeCode: z.ZodOptional<z.ZodString>;
284
296
  tierSetId: z.ZodString;
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { apiGet, apiPost, apiPut } from "../client/http.js";
3
3
  import { TierSetSchema, TierSetListResponseSchema, TierListResponseSchema, TierSetAttributeEnum, DowngradeModeEnum, } from "../types/schemas/tierset.js";
4
4
  import { formatApiError } from "../utils/errors.js";
5
- import { getConfig } from "../config.js";
5
+ import { getStoreCode } from "../config.js";
6
6
  import { buildPaginationQuery } from "../utils/pagination.js";
7
7
  export const TierSetListInputSchema = {
8
8
  storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
@@ -57,8 +57,7 @@ export const TierSetGetTiersInputSchema = {
57
57
  tierSetId: z.string().describe("The tier set ID to get tiers for."),
58
58
  };
59
59
  export async function tiersetList(input) {
60
- const config = getConfig();
61
- const storeCode = input.storeCode || config.defaultStoreCode;
60
+ const storeCode = getStoreCode(input.storeCode);
62
61
  const query = buildPaginationQuery({
63
62
  page: input.page,
64
63
  perPage: input.perPage,
@@ -84,8 +83,7 @@ export async function tiersetList(input) {
84
83
  }
85
84
  }
86
85
  export async function tiersetCreate(input) {
87
- const config = getConfig();
88
- const storeCode = input.storeCode || config.defaultStoreCode;
86
+ const storeCode = getStoreCode(input.storeCode);
89
87
  // API requires tierSet wrapper with translations (at least en is required)
90
88
  const payload = {
91
89
  tierSet: {
@@ -116,8 +114,7 @@ export async function tiersetCreate(input) {
116
114
  }
117
115
  }
118
116
  export async function tiersetGet(input) {
119
- const config = getConfig();
120
- const storeCode = input.storeCode || config.defaultStoreCode;
117
+ const storeCode = getStoreCode(input.storeCode);
121
118
  try {
122
119
  const response = await apiGet(`/${storeCode}/tierSet/${input.tierSetId}`);
123
120
  const validated = TierSetSchema.parse(response);
@@ -128,8 +125,7 @@ export async function tiersetGet(input) {
128
125
  }
129
126
  }
130
127
  export async function tiersetUpdate(input) {
131
- const config = getConfig();
132
- const storeCode = input.storeCode || config.defaultStoreCode;
128
+ const storeCode = getStoreCode(input.storeCode);
133
129
  // API requires tierSet wrapper with translations (at least en is required)
134
130
  const tierSetPayload = {};
135
131
  // If name or description is provided, wrap in translations
@@ -153,8 +149,7 @@ export async function tiersetUpdate(input) {
153
149
  }
154
150
  }
155
151
  export async function tiersetUpdateTiers(input) {
156
- const config = getConfig();
157
- const storeCode = input.storeCode || config.defaultStoreCode;
152
+ const storeCode = getStoreCode(input.storeCode);
158
153
  // API requires translations (at least en is required)
159
154
  const payload = {
160
155
  tiers: input.tiers.map((tier) => ({
@@ -180,8 +175,7 @@ export async function tiersetUpdateTiers(input) {
180
175
  }
181
176
  }
182
177
  export async function tiersetGetTiers(input) {
183
- const config = getConfig();
184
- const storeCode = input.storeCode || config.defaultStoreCode;
178
+ const storeCode = getStoreCode(input.storeCode);
185
179
  try {
186
180
  const response = await apiGet(`/${storeCode}/tierSet/${input.tierSetId}/tiers`);
187
181
  const validated = TierListResponseSchema.parse(response);
@@ -200,30 +194,39 @@ export async function tiersetGetTiers(input) {
200
194
  export const tiersetToolDefinitions = [
201
195
  {
202
196
  name: "openloyalty_tierset_list",
197
+ title: "List Loyalty Programs",
203
198
  description: "List all tier sets. Use tierset_get to fetch conditions needed for defining tiers. Returns tierSetId, name, active status, and tier count for each tier set.",
199
+ readOnly: true,
204
200
  inputSchema: TierSetListInputSchema,
205
201
  handler: tiersetList,
206
202
  },
207
203
  {
208
204
  name: "openloyalty_tierset_create",
205
+ title: "Create Loyalty Program",
209
206
  description: "Create a new tier set (loyalty program structure). After creation, call tierset_get to obtain conditionId values, then tierset_update_tiers to define tier thresholds. Conditions define what metrics are used for tier progression (e.g., activeUnits for points balance).",
207
+ readOnly: false,
210
208
  inputSchema: TierSetCreateInputSchema,
211
209
  handler: tiersetCreate,
212
210
  },
213
211
  {
214
212
  name: "openloyalty_tierset_get",
213
+ title: "Get Loyalty Program Details",
215
214
  description: "Get tier set details including conditionId values needed for tierset_update_tiers. Returns the full tier set with conditions array containing conditionId for each condition.",
215
+ readOnly: true,
216
216
  inputSchema: TierSetGetInputSchema,
217
217
  handler: tiersetGet,
218
218
  },
219
219
  {
220
220
  name: "openloyalty_tierset_update",
221
+ title: "Update Loyalty Program",
221
222
  description: "Update tier set metadata (name, description, active status, downgrade settings). Does not modify tiers - use tierset_update_tiers for that.",
223
+ readOnly: false,
222
224
  inputSchema: TierSetUpdateInputSchema,
223
225
  handler: tiersetUpdate,
224
226
  },
225
227
  {
226
228
  name: "openloyalty_tierset_update_tiers",
229
+ title: "Configure Tier Thresholds",
227
230
  description: `Define tier thresholds for a tier set. PREREQUISITE: Call tierset_get first to obtain conditionId values. Each tier's conditions array uses conditionId from the parent tier set plus a threshold value.
228
231
 
229
232
  Example for a 3-tier program with points-based progression:
@@ -232,12 +235,15 @@ Example for a 3-tier program with points-based progression:
232
235
  - Gold tier: conditions: [{ conditionId: "xxx", value: 1200 }]
233
236
 
234
237
  The conditionId must match one from tierset_get response.`,
238
+ readOnly: false,
235
239
  inputSchema: TierSetUpdateTiersInputSchema,
236
240
  handler: tiersetUpdateTiers,
237
241
  },
238
242
  {
239
243
  name: "openloyalty_tierset_get_tiers",
244
+ title: "Get Tier Configuration",
240
245
  description: "Get all tiers in a tier set. Returns levelId values that can be used for campaign targeting. Includes each tier's name and condition thresholds.",
246
+ readOnly: true,
241
247
  inputSchema: TierSetGetTiersInputSchema,
242
248
  handler: tiersetGetTiers,
243
249
  },
@@ -88,16 +88,16 @@ export declare const TransactionCreateInputSchema: {
88
88
  phone: z.ZodOptional<z.ZodString>;
89
89
  loyaltyCardNumber: z.ZodOptional<z.ZodString>;
90
90
  }, "strip", z.ZodTypeAny, {
91
- name?: string | undefined;
92
91
  email?: string | undefined;
93
92
  phone?: string | undefined;
94
93
  loyaltyCardNumber?: string | undefined;
94
+ name?: string | undefined;
95
95
  customerId?: string | undefined;
96
96
  }, {
97
- name?: string | undefined;
98
97
  email?: string | undefined;
99
98
  phone?: string | undefined;
100
99
  loyaltyCardNumber?: string | undefined;
100
+ name?: string | undefined;
101
101
  customerId?: string | undefined;
102
102
  }>>;
103
103
  };
@@ -215,7 +215,9 @@ export declare function transactionAssignMember(input: {
215
215
  }>;
216
216
  export declare const transactionToolDefinitions: readonly [{
217
217
  readonly name: "openloyalty_transaction_create";
218
+ readonly title: "Record Purchase";
218
219
  readonly description: string;
220
+ readonly readOnly: false;
219
221
  readonly inputSchema: {
220
222
  storeCode: z.ZodOptional<z.ZodString>;
221
223
  header: z.ZodObject<{
@@ -305,23 +307,25 @@ export declare const transactionToolDefinitions: readonly [{
305
307
  phone: z.ZodOptional<z.ZodString>;
306
308
  loyaltyCardNumber: z.ZodOptional<z.ZodString>;
307
309
  }, "strip", z.ZodTypeAny, {
308
- name?: string | undefined;
309
310
  email?: string | undefined;
310
311
  phone?: string | undefined;
311
312
  loyaltyCardNumber?: string | undefined;
313
+ name?: string | undefined;
312
314
  customerId?: string | undefined;
313
315
  }, {
314
- name?: string | undefined;
315
316
  email?: string | undefined;
316
317
  phone?: string | undefined;
317
318
  loyaltyCardNumber?: string | undefined;
319
+ name?: string | undefined;
318
320
  customerId?: string | undefined;
319
321
  }>>;
320
322
  };
321
323
  readonly handler: typeof transactionCreate;
322
324
  }, {
323
325
  readonly name: "openloyalty_transaction_get";
326
+ readonly title: "Get Transaction Details";
324
327
  readonly description: "Get transaction details including items, customerData, matched status, and pointsEarned.";
328
+ readonly readOnly: true;
325
329
  readonly inputSchema: {
326
330
  storeCode: z.ZodOptional<z.ZodString>;
327
331
  transactionId: z.ZodString;
@@ -329,7 +333,9 @@ export declare const transactionToolDefinitions: readonly [{
329
333
  readonly handler: typeof transactionGet;
330
334
  }, {
331
335
  readonly name: "openloyalty_transaction_list";
336
+ readonly title: "Search Transactions";
332
337
  readonly description: string;
338
+ readonly readOnly: true;
333
339
  readonly inputSchema: {
334
340
  storeCode: z.ZodOptional<z.ZodString>;
335
341
  cursor: z.ZodOptional<z.ZodString>;
@@ -345,7 +351,9 @@ export declare const transactionToolDefinitions: readonly [{
345
351
  readonly handler: typeof transactionList;
346
352
  }, {
347
353
  readonly name: "openloyalty_transaction_assign_member";
354
+ readonly title: "Link Transaction to Member";
348
355
  readonly description: string;
356
+ readonly readOnly: false;
349
357
  readonly inputSchema: {
350
358
  storeCode: z.ZodOptional<z.ZodString>;
351
359
  documentNumber: z.ZodString;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { apiGet, apiPost } from "../client/http.js";
3
3
  import { formatApiError } from "../utils/errors.js";
4
- import { getConfig } from "../config.js";
4
+ import { getStoreCode } from "../config.js";
5
5
  import { buildPaginationParams, normalizeDateToISO } from "../utils/pagination.js";
6
6
  // Input Schemas
7
7
  const LabelInputSchema = z.object({
@@ -64,8 +64,7 @@ export const TransactionAssignMemberInputSchema = {
64
64
  };
65
65
  // Handler functions
66
66
  export async function transactionCreate(input) {
67
- const config = getConfig();
68
- const storeCode = input.storeCode || config.defaultStoreCode;
67
+ const storeCode = getStoreCode(input.storeCode);
69
68
  const transactionPayload = {
70
69
  header: {
71
70
  documentNumber: input.header.documentNumber,
@@ -100,8 +99,7 @@ export async function transactionCreate(input) {
100
99
  }
101
100
  }
102
101
  export async function transactionGet(input) {
103
- const config = getConfig();
104
- const storeCode = input.storeCode || config.defaultStoreCode;
102
+ const storeCode = getStoreCode(input.storeCode);
105
103
  try {
106
104
  const response = await apiGet(`/${storeCode}/transaction/${input.transactionId}`);
107
105
  const header = response.header;
@@ -122,8 +120,7 @@ export async function transactionGet(input) {
122
120
  }
123
121
  }
124
122
  export async function transactionList(input) {
125
- const config = getConfig();
126
- const storeCode = input.storeCode || config.defaultStoreCode;
123
+ const storeCode = getStoreCode(input.storeCode);
127
124
  const params = new URLSearchParams();
128
125
  // Enforce max perPage of 50 (API limit)
129
126
  const perPage = input.perPage ? Math.min(input.perPage, 50) : undefined;
@@ -175,8 +172,7 @@ export async function transactionList(input) {
175
172
  }
176
173
  }
177
174
  export async function transactionAssignMember(input) {
178
- const config = getConfig();
179
- const storeCode = input.storeCode || config.defaultStoreCode;
175
+ const storeCode = getStoreCode(input.storeCode);
180
176
  // At least one identifier required
181
177
  if (!input.customerId && !input.loyaltyCardNumber && !input.phone) {
182
178
  throw new Error("At least one member identifier required: customerId, loyaltyCardNumber, or phone.");
@@ -207,20 +203,25 @@ export async function transactionAssignMember(input) {
207
203
  export const transactionToolDefinitions = [
208
204
  {
209
205
  name: "openloyalty_transaction_create",
206
+ title: "Record Purchase",
210
207
  description: "Record a purchase transaction. If customerData provided, auto-matches to member and triggers point campaigns. " +
211
208
  "For returns, set documentType='return' and provide linkedDocumentNumber referencing original sale. " +
212
209
  "Returns transactionId and pointsEarned if campaigns triggered.",
210
+ readOnly: false,
213
211
  inputSchema: TransactionCreateInputSchema,
214
212
  handler: transactionCreate,
215
213
  },
216
214
  {
217
215
  name: "openloyalty_transaction_get",
216
+ title: "Get Transaction Details",
218
217
  description: "Get transaction details including items, customerData, matched status, and pointsEarned.",
218
+ readOnly: true,
219
219
  inputSchema: TransactionGetInputSchema,
220
220
  handler: transactionGet,
221
221
  },
222
222
  {
223
223
  name: "openloyalty_transaction_list",
224
+ title: "Search Transactions",
224
225
  description: "List transactions with optional filters. Filter by customerId, documentNumber, documentType, matched status, or date range (purchasedAtFrom/purchasedAtTo). " +
225
226
  "Use ISO date format for date filters (e.g., '2025-07-01' or '2025-07-01T00:00:00Z'). " +
226
227
  "Supports cursor pagination: provide 'cursor' from previous response to get next page. " +
@@ -229,13 +230,16 @@ export const transactionToolDefinitions = [
229
230
  "Do NOT try to optimize or find shortcuts - the cursor approach is the correct and only way to get accurate results. " +
230
231
  "Start with cursor='' (empty string), then use returned cursor for subsequent requests until no more data. " +
231
232
  "Use perPage=50 to minimize API calls. Aggregate by customerId in your code, then use member_get for names.",
233
+ readOnly: true,
232
234
  inputSchema: TransactionListInputSchema,
233
235
  handler: transactionList,
234
236
  },
235
237
  {
236
238
  name: "openloyalty_transaction_assign_member",
239
+ title: "Link Transaction to Member",
237
240
  description: "Assign unmatched transaction to member by ID, card number, or phone. Triggers point campaigns. " +
238
241
  "Use this to link a transaction that wasn't matched at creation time. Returns transactionId, customerId, and pointsEarned.",
242
+ readOnly: false,
239
243
  inputSchema: TransactionAssignMemberInputSchema,
240
244
  handler: transactionAssignMember,
241
245
  },
@@ -16,14 +16,18 @@ export declare function walletTypeGet(input: {
16
16
  }): Promise<WalletType>;
17
17
  export declare const walletTypeToolDefinitions: readonly [{
18
18
  readonly name: "openloyalty_wallet_type_list";
19
+ readonly title: "List Point Currencies";
19
20
  readonly description: "List all available wallet types (point currencies). Use this to find walletCode values for tier conditions. Returns walletTypeId, code, and name for each wallet type.";
21
+ readonly readOnly: true;
20
22
  readonly inputSchema: {
21
23
  storeCode: z.ZodOptional<z.ZodString>;
22
24
  };
23
25
  readonly handler: typeof walletTypeList;
24
26
  }, {
25
27
  readonly name: "openloyalty_wallet_type_get";
28
+ readonly title: "Get Point Currency Details";
26
29
  readonly description: "Get details for a specific wallet type by ID. Returns the full wallet type configuration including currency names.";
30
+ readonly readOnly: true;
27
31
  readonly inputSchema: {
28
32
  storeCode: z.ZodOptional<z.ZodString>;
29
33
  walletTypeId: z.ZodString;
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { apiGet } from "../client/http.js";
3
3
  import { WalletTypeSchema, WalletTypeListResponseSchema, } from "../types/schemas/wallet-type.js";
4
4
  import { formatApiError } from "../utils/errors.js";
5
- import { getConfig } from "../config.js";
5
+ import { getStoreCode } from "../config.js";
6
6
  export const WalletTypeListInputSchema = {
7
7
  storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
8
8
  };
@@ -11,8 +11,7 @@ export const WalletTypeGetInputSchema = {
11
11
  walletTypeId: z.string().describe("The wallet type ID to retrieve."),
12
12
  };
13
13
  export async function walletTypeList(input) {
14
- const config = getConfig();
15
- const storeCode = input.storeCode || config.defaultStoreCode;
14
+ const storeCode = getStoreCode(input.storeCode);
16
15
  try {
17
16
  const response = await apiGet(`/${storeCode}/walletType`);
18
17
  const validated = WalletTypeListResponseSchema.parse(response);
@@ -31,8 +30,7 @@ export async function walletTypeList(input) {
31
30
  }
32
31
  }
33
32
  export async function walletTypeGet(input) {
34
- const config = getConfig();
35
- const storeCode = input.storeCode || config.defaultStoreCode;
33
+ const storeCode = getStoreCode(input.storeCode);
36
34
  try {
37
35
  const response = await apiGet(`/${storeCode}/walletType/${input.walletTypeId}`);
38
36
  const validated = WalletTypeSchema.parse(response);
@@ -45,13 +43,17 @@ export async function walletTypeGet(input) {
45
43
  export const walletTypeToolDefinitions = [
46
44
  {
47
45
  name: "openloyalty_wallet_type_list",
46
+ title: "List Point Currencies",
48
47
  description: "List all available wallet types (point currencies). Use this to find walletCode values for tier conditions. Returns walletTypeId, code, and name for each wallet type.",
48
+ readOnly: true,
49
49
  inputSchema: WalletTypeListInputSchema,
50
50
  handler: walletTypeList,
51
51
  },
52
52
  {
53
53
  name: "openloyalty_wallet_type_get",
54
+ title: "Get Point Currency Details",
54
55
  description: "Get details for a specific wallet type by ID. Returns the full wallet type configuration including currency names.",
56
+ readOnly: true,
55
57
  inputSchema: WalletTypeGetInputSchema,
56
58
  handler: walletTypeGet,
57
59
  },
@@ -31,7 +31,7 @@ export declare const WebhookListInputSchema: {
31
31
  export declare const WebhookCreateInputSchema: {
32
32
  storeCode: z.ZodOptional<z.ZodString>;
33
33
  eventName: z.ZodString;
34
- url: z.ZodString;
34
+ url: z.ZodEffects<z.ZodString, string, string>;
35
35
  headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
36
36
  headerName: z.ZodString;
37
37
  headerValue: z.ZodString;
@@ -51,7 +51,7 @@ export declare const WebhookUpdateInputSchema: {
51
51
  storeCode: z.ZodOptional<z.ZodString>;
52
52
  webhookSubscriptionId: z.ZodString;
53
53
  eventName: z.ZodOptional<z.ZodString>;
54
- url: z.ZodOptional<z.ZodString>;
54
+ url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
55
55
  headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
56
  headerName: z.ZodString;
57
57
  headerValue: z.ZodString;
@@ -105,7 +105,9 @@ export declare function webhookEvents(input: {
105
105
  }): Promise<WebhookEventTypesResponse>;
106
106
  export declare const webhookToolDefinitions: readonly [{
107
107
  readonly name: "openloyalty_webhook_list";
108
+ readonly title: "List Webhook Subscriptions";
108
109
  readonly description: "List webhook subscriptions with optional filtering. Returns paginated list of subscriptions with webhookSubscriptionId, eventName, url, and createdAt.";
110
+ readonly readOnly: true;
109
111
  readonly inputSchema: {
110
112
  storeCode: z.ZodOptional<z.ZodString>;
111
113
  page: z.ZodOptional<z.ZodNumber>;
@@ -116,11 +118,13 @@ export declare const webhookToolDefinitions: readonly [{
116
118
  readonly handler: typeof webhookList;
117
119
  }, {
118
120
  readonly name: "openloyalty_webhook_create";
121
+ readonly title: "Create Webhook Subscription";
119
122
  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.";
123
+ readonly readOnly: false;
120
124
  readonly inputSchema: {
121
125
  storeCode: z.ZodOptional<z.ZodString>;
122
126
  eventName: z.ZodString;
123
- url: z.ZodString;
127
+ url: z.ZodEffects<z.ZodString, string, string>;
124
128
  headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
125
129
  headerName: z.ZodString;
126
130
  headerValue: z.ZodString;
@@ -135,7 +139,9 @@ export declare const webhookToolDefinitions: readonly [{
135
139
  readonly handler: typeof webhookCreate;
136
140
  }, {
137
141
  readonly name: "openloyalty_webhook_get";
142
+ readonly title: "Get Webhook Subscription Details";
138
143
  readonly description: "Get full webhook subscription details including headers configuration.";
144
+ readonly readOnly: true;
139
145
  readonly inputSchema: {
140
146
  storeCode: z.ZodOptional<z.ZodString>;
141
147
  webhookSubscriptionId: z.ZodString;
@@ -143,12 +149,14 @@ export declare const webhookToolDefinitions: readonly [{
143
149
  readonly handler: typeof webhookGet;
144
150
  }, {
145
151
  readonly name: "openloyalty_webhook_update";
152
+ readonly title: "Update Webhook Subscription";
146
153
  readonly description: "Update a webhook subscription. Can update eventName, url, and headers. Returns void on success (204 No Content).";
154
+ readonly readOnly: false;
147
155
  readonly inputSchema: {
148
156
  storeCode: z.ZodOptional<z.ZodString>;
149
157
  webhookSubscriptionId: z.ZodString;
150
158
  eventName: z.ZodOptional<z.ZodString>;
151
- url: z.ZodOptional<z.ZodString>;
159
+ url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
152
160
  headers: z.ZodOptional<z.ZodArray<z.ZodObject<{
153
161
  headerName: z.ZodString;
154
162
  headerValue: z.ZodString;
@@ -163,7 +171,10 @@ export declare const webhookToolDefinitions: readonly [{
163
171
  readonly handler: typeof webhookUpdate;
164
172
  }, {
165
173
  readonly name: "openloyalty_webhook_delete";
174
+ readonly title: "Delete Webhook Subscription (Permanent)";
166
175
  readonly description: "Delete a webhook subscription. Returns void on success (204 No Content). The subscription will stop receiving events immediately.";
176
+ readonly readOnly: false;
177
+ readonly destructive: true;
167
178
  readonly inputSchema: {
168
179
  storeCode: z.ZodOptional<z.ZodString>;
169
180
  webhookSubscriptionId: z.ZodString;
@@ -171,7 +182,9 @@ export declare const webhookToolDefinitions: readonly [{
171
182
  readonly handler: typeof webhookDelete;
172
183
  }, {
173
184
  readonly name: "openloyalty_webhook_events";
185
+ readonly title: "List Available Webhook Events";
174
186
  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.";
187
+ readonly readOnly: true;
175
188
  readonly inputSchema: {
176
189
  storeCode: z.ZodOptional<z.ZodString>;
177
190
  };