@open-loyalty/mcp-server 1.0.3 → 1.3.1

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 (142) hide show
  1. package/README.md +180 -177
  2. package/dist/auth/provider.js +2 -14
  3. package/dist/auth/storage.js +22 -0
  4. package/dist/client/http.d.ts +5 -0
  5. package/dist/client/http.js +62 -3
  6. package/dist/config.d.ts +6 -5
  7. package/dist/config.js +15 -11
  8. package/dist/http.js +170 -65
  9. package/dist/instructions.d.ts +5 -0
  10. package/dist/instructions.js +420 -0
  11. package/dist/prompts/fan-engagement-setup.d.ts +107 -0
  12. package/dist/prompts/fan-engagement-setup.js +492 -0
  13. package/dist/server.d.ts +1 -1
  14. package/dist/server.js +68 -278
  15. package/dist/tools/achievement/handlers.d.ts +117 -0
  16. package/dist/tools/achievement/handlers.js +161 -0
  17. package/dist/tools/achievement/index.d.ts +479 -0
  18. package/dist/tools/achievement/index.js +74 -0
  19. package/dist/tools/achievement/schemas.d.ts +433 -0
  20. package/dist/tools/achievement/schemas.js +142 -0
  21. package/dist/tools/achievement.d.ts +155 -121
  22. package/dist/tools/achievement.js +82 -39
  23. package/dist/tools/admin.d.ts +18 -6
  24. package/dist/tools/admin.js +24 -12
  25. package/dist/tools/analytics.d.ts +29 -11
  26. package/dist/tools/analytics.js +58 -48
  27. package/dist/tools/apikey.d.ts +10 -3
  28. package/dist/tools/apikey.js +13 -6
  29. package/dist/tools/audit.d.ts +6 -2
  30. package/dist/tools/audit.js +8 -4
  31. package/dist/tools/badge.d.ts +14 -6
  32. package/dist/tools/badge.js +36 -27
  33. package/dist/tools/campaign/handlers.d.ts +42 -0
  34. package/dist/tools/campaign/handlers.js +223 -0
  35. package/dist/tools/campaign/index.d.ts +783 -0
  36. package/dist/tools/campaign/index.js +112 -0
  37. package/dist/tools/campaign/member-handlers.d.ts +60 -0
  38. package/dist/tools/campaign/member-handlers.js +159 -0
  39. package/dist/tools/campaign/schemas.d.ts +704 -0
  40. package/dist/tools/campaign/schemas.js +259 -0
  41. package/dist/tools/campaign/types.d.ts +161 -0
  42. package/dist/tools/campaign/types.js +2 -0
  43. package/dist/tools/campaign.d.ts +41 -16
  44. package/dist/tools/campaign.js +38 -25
  45. package/dist/tools/custom-event.d.ts +315 -0
  46. package/dist/tools/custom-event.js +270 -0
  47. package/dist/tools/export.d.ts +12 -4
  48. package/dist/tools/export.js +25 -20
  49. package/dist/tools/import.d.ts +9 -3
  50. package/dist/tools/import.js +33 -21
  51. package/dist/tools/index.d.ts +3 -11
  52. package/dist/tools/index.js +17 -475
  53. package/dist/tools/member/handlers.d.ts +111 -0
  54. package/dist/tools/member/handlers.js +206 -0
  55. package/dist/tools/member/index.d.ts +169 -0
  56. package/dist/tools/member/index.js +92 -0
  57. package/dist/tools/member/schemas.d.ts +89 -0
  58. package/dist/tools/member/schemas.js +65 -0
  59. package/dist/tools/member.d.ts +21 -0
  60. package/dist/tools/member.js +56 -62
  61. package/dist/tools/points.d.ts +19 -6
  62. package/dist/tools/points.js +51 -49
  63. package/dist/tools/referral/handlers.d.ts +47 -0
  64. package/dist/tools/referral/handlers.js +115 -0
  65. package/dist/tools/referral/index.d.ts +44 -0
  66. package/dist/tools/referral/index.js +44 -0
  67. package/dist/tools/referral/schemas.d.ts +34 -0
  68. package/dist/tools/referral/schemas.js +52 -0
  69. package/dist/tools/reward/handlers.d.ts +110 -0
  70. package/dist/tools/reward/handlers.js +289 -0
  71. package/dist/tools/reward/index.d.ts +177 -0
  72. package/dist/tools/reward/index.js +90 -0
  73. package/dist/tools/reward/schemas.d.ts +116 -0
  74. package/dist/tools/reward/schemas.js +91 -0
  75. package/dist/tools/reward.d.ts +18 -0
  76. package/dist/tools/reward.js +56 -66
  77. package/dist/tools/role.d.ts +26 -7
  78. package/dist/tools/role.js +25 -12
  79. package/dist/tools/segment/handlers.d.ts +87 -0
  80. package/dist/tools/segment/handlers.js +174 -0
  81. package/dist/tools/segment/index.d.ts +395 -0
  82. package/dist/tools/segment/index.js +87 -0
  83. package/dist/tools/segment/schemas.d.ts +337 -0
  84. package/dist/tools/segment/schemas.js +79 -0
  85. package/dist/tools/segment.d.ts +29 -10
  86. package/dist/tools/segment.js +84 -50
  87. package/dist/tools/store.d.ts +12 -4
  88. package/dist/tools/store.js +16 -8
  89. package/dist/tools/tierset.d.ts +19 -7
  90. package/dist/tools/tierset.js +44 -35
  91. package/dist/tools/transaction.d.ts +16 -8
  92. package/dist/tools/transaction.js +25 -21
  93. package/dist/tools/wallet-type.d.ts +7 -3
  94. package/dist/tools/wallet-type.js +14 -12
  95. package/dist/tools/webhook.d.ts +23 -10
  96. package/dist/tools/webhook.js +135 -33
  97. package/dist/types/schemas/achievement.d.ts +12 -309
  98. package/dist/types/schemas/achievement.js +0 -13
  99. package/dist/types/schemas/admin.d.ts +10 -97
  100. package/dist/types/schemas/admin.js +0 -38
  101. package/dist/types/schemas/badge.d.ts +0 -37
  102. package/dist/types/schemas/badge.js +0 -11
  103. package/dist/types/schemas/campaign.d.ts +64 -832
  104. package/dist/types/schemas/campaign.js +2 -25
  105. package/dist/types/schemas/common.d.ts +5 -0
  106. package/dist/types/schemas/common.js +5 -0
  107. package/dist/types/schemas/export.d.ts +0 -17
  108. package/dist/types/schemas/export.js +0 -7
  109. package/dist/types/schemas/member.d.ts +37 -176
  110. package/dist/types/schemas/member.js +0 -27
  111. package/dist/types/schemas/points.d.ts +0 -63
  112. package/dist/types/schemas/points.js +0 -22
  113. package/dist/types/schemas/reward.d.ts +71 -68
  114. package/dist/types/schemas/reward.js +8 -28
  115. package/dist/types/schemas/role.d.ts +0 -100
  116. package/dist/types/schemas/role.js +0 -29
  117. package/dist/types/schemas/segment.d.ts +0 -58
  118. package/dist/types/schemas/segment.js +0 -17
  119. package/dist/types/schemas/tierset.d.ts +0 -176
  120. package/dist/types/schemas/tierset.js +0 -27
  121. package/dist/types/schemas/transaction.d.ts +23 -254
  122. package/dist/types/schemas/transaction.js +0 -7
  123. package/dist/types/schemas/wallet-type.d.ts +8 -8
  124. package/dist/types/schemas/wallet-type.js +1 -1
  125. package/dist/types/schemas/webhook.d.ts +0 -58
  126. package/dist/types/schemas/webhook.js +0 -12
  127. package/dist/utils/errors.js +30 -3
  128. package/dist/utils/payload.d.ts +12 -0
  129. package/dist/utils/payload.js +14 -0
  130. package/dist/workflows/app-login-streak.d.ts +39 -0
  131. package/dist/workflows/app-login-streak.js +298 -0
  132. package/dist/workflows/early-arrival.d.ts +33 -0
  133. package/dist/workflows/early-arrival.js +148 -0
  134. package/dist/workflows/index.d.ts +101 -0
  135. package/dist/workflows/index.js +208 -0
  136. package/dist/workflows/match-attendance.d.ts +45 -0
  137. package/dist/workflows/match-attendance.js +308 -0
  138. package/dist/workflows/sportsbar-visit.d.ts +41 -0
  139. package/dist/workflows/sportsbar-visit.js +284 -0
  140. package/dist/workflows/vod-watching.d.ts +43 -0
  141. package/dist/workflows/vod-watching.js +326 -0
  142. package/package.json +10 -2
@@ -2,21 +2,22 @@ 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
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
8
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
9
9
  page: z.number().optional().describe("Page number for pagination (starts at 1)."),
10
10
  perPage: z.number().optional().describe("Number of items per page."),
11
11
  };
12
12
  export const TierSetCreateInputSchema = {
13
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
13
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
14
14
  name: z.string().describe("Name of the tier set."),
15
15
  description: z.string().optional().describe("Description of the tier set."),
16
16
  conditions: z.array(z.object({
17
- attribute: TierSetAttributeEnum.describe("The attribute to use for this condition."),
18
- walletType: z.string().optional().describe("Wallet type code (required for unit-based attributes like activeUnits). Get this from wallet_type_list."),
19
- })).describe("Array of conditions that define tier progression criteria."),
17
+ attribute: TierSetAttributeEnum.describe("The attribute to use for this condition (use `attribute`, not `type`)."),
18
+ walletType: z.string().optional().describe("Wallet type CODE (not UUID). Required for unit-based attributes like activeUnits. " +
19
+ "Use wallet_type_list to find walletType.code (e.g., 'default')."),
20
+ })).describe("Array of conditions that define tier progression criteria. Each condition uses `attribute` + optional `walletType`."),
20
21
  downgrade: z.object({
21
22
  mode: DowngradeModeEnum.describe("Downgrade mode."),
22
23
  days: z.number().optional().describe("Number of days for x_days mode (required if mode is x_days)."),
@@ -24,11 +25,11 @@ export const TierSetCreateInputSchema = {
24
25
  active: z.boolean().optional().describe("Whether the tier set is active. Defaults to true."),
25
26
  };
26
27
  export const TierSetGetInputSchema = {
27
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
28
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
28
29
  tierSetId: z.string().describe("The tier set ID to retrieve."),
29
30
  };
30
31
  export const TierSetUpdateInputSchema = {
31
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
32
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
32
33
  tierSetId: z.string().describe("The tier set ID to update."),
33
34
  name: z.string().optional().describe("New name for the tier set."),
34
35
  description: z.string().optional().describe("New description for the tier set."),
@@ -39,7 +40,7 @@ export const TierSetUpdateInputSchema = {
39
40
  }).optional().describe("Downgrade configuration."),
40
41
  };
41
42
  export const TierSetUpdateTiersInputSchema = {
42
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
43
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
43
44
  tierSetId: z.string().describe("The tier set ID to update tiers for."),
44
45
  tiers: z.array(z.object({
45
46
  levelId: z.string().optional().describe("Existing level ID (for updates). Omit for new tiers."),
@@ -53,12 +54,11 @@ export const TierSetUpdateTiersInputSchema = {
53
54
  })).describe("Array of tier definitions."),
54
55
  };
55
56
  export const TierSetGetTiersInputSchema = {
56
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
57
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
57
58
  tierSetId: z.string().describe("The tier set ID to get tiers for."),
58
59
  };
59
60
  export async function tiersetList(input) {
60
- const config = getConfig();
61
- const storeCode = input.storeCode || config.defaultStoreCode;
61
+ const storeCode = getStoreCode(input.storeCode);
62
62
  const query = buildPaginationQuery({
63
63
  page: input.page,
64
64
  perPage: input.perPage,
@@ -80,12 +80,11 @@ export async function tiersetList(input) {
80
80
  };
81
81
  }
82
82
  catch (error) {
83
- throw formatApiError(error, "openloyalty_tierset_list");
83
+ throw formatApiError(error, "ol_tierset_list");
84
84
  }
85
85
  }
86
86
  export async function tiersetCreate(input) {
87
- const config = getConfig();
88
- const storeCode = input.storeCode || config.defaultStoreCode;
87
+ const storeCode = getStoreCode(input.storeCode);
89
88
  // API requires tierSet wrapper with translations (at least en is required)
90
89
  const payload = {
91
90
  tierSet: {
@@ -112,24 +111,22 @@ export async function tiersetCreate(input) {
112
111
  };
113
112
  }
114
113
  catch (error) {
115
- throw formatApiError(error, "openloyalty_tierset_create");
114
+ throw formatApiError(error, "ol_tierset_create");
116
115
  }
117
116
  }
118
117
  export async function tiersetGet(input) {
119
- const config = getConfig();
120
- const storeCode = input.storeCode || config.defaultStoreCode;
118
+ const storeCode = getStoreCode(input.storeCode);
121
119
  try {
122
120
  const response = await apiGet(`/${storeCode}/tierSet/${input.tierSetId}`);
123
121
  const validated = TierSetSchema.parse(response);
124
122
  return validated;
125
123
  }
126
124
  catch (error) {
127
- throw formatApiError(error, "openloyalty_tierset_get");
125
+ throw formatApiError(error, "ol_tierset_get");
128
126
  }
129
127
  }
130
128
  export async function tiersetUpdate(input) {
131
- const config = getConfig();
132
- const storeCode = input.storeCode || config.defaultStoreCode;
129
+ const storeCode = getStoreCode(input.storeCode);
133
130
  // API requires tierSet wrapper with translations (at least en is required)
134
131
  const tierSetPayload = {};
135
132
  // If name or description is provided, wrap in translations
@@ -149,12 +146,11 @@ export async function tiersetUpdate(input) {
149
146
  await apiPut(`/${storeCode}/tierSet/${input.tierSetId}`, { tierSet: tierSetPayload });
150
147
  }
151
148
  catch (error) {
152
- throw formatApiError(error, "openloyalty_tierset_update");
149
+ throw formatApiError(error, "ol_tierset_update");
153
150
  }
154
151
  }
155
152
  export async function tiersetUpdateTiers(input) {
156
- const config = getConfig();
157
- const storeCode = input.storeCode || config.defaultStoreCode;
153
+ const storeCode = getStoreCode(input.storeCode);
158
154
  // API requires translations (at least en is required)
159
155
  const payload = {
160
156
  tiers: input.tiers.map((tier) => ({
@@ -176,12 +172,11 @@ export async function tiersetUpdateTiers(input) {
176
172
  await apiPut(`/${storeCode}/tierSet/${input.tierSetId}/tiers`, payload);
177
173
  }
178
174
  catch (error) {
179
- throw formatApiError(error, "openloyalty_tierset_update_tiers");
175
+ throw formatApiError(error, "ol_tierset_update_tiers");
180
176
  }
181
177
  }
182
178
  export async function tiersetGetTiers(input) {
183
- const config = getConfig();
184
- const storeCode = input.storeCode || config.defaultStoreCode;
179
+ const storeCode = getStoreCode(input.storeCode);
185
180
  try {
186
181
  const response = await apiGet(`/${storeCode}/tierSet/${input.tierSetId}/tiers`);
187
182
  const validated = TierListResponseSchema.parse(response);
@@ -194,36 +189,47 @@ export async function tiersetGetTiers(input) {
194
189
  };
195
190
  }
196
191
  catch (error) {
197
- throw formatApiError(error, "openloyalty_tierset_get_tiers");
192
+ throw formatApiError(error, "ol_tierset_get_tiers");
198
193
  }
199
194
  }
200
195
  export const tiersetToolDefinitions = [
201
196
  {
202
- name: "openloyalty_tierset_list",
197
+ name: "ol_tierset_list",
198
+ title: "List Loyalty Programs",
203
199
  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.",
200
+ readOnly: true,
204
201
  inputSchema: TierSetListInputSchema,
205
202
  handler: tiersetList,
206
203
  },
207
204
  {
208
- name: "openloyalty_tierset_create",
209
- 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).",
205
+ name: "ol_tierset_create",
206
+ title: "Create Loyalty Program",
207
+ 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. " +
208
+ "Conditions define what metrics are used for tier progression (e.g., activeUnits for points balance). " +
209
+ "IMPORTANT: conditions use `attribute` (not `type`). For unit-based attributes, set `walletType` to the wallet CODE (e.g., 'default'), not the UUID.",
210
+ readOnly: false,
210
211
  inputSchema: TierSetCreateInputSchema,
211
212
  handler: tiersetCreate,
212
213
  },
213
214
  {
214
- name: "openloyalty_tierset_get",
215
+ name: "ol_tierset_get",
216
+ title: "Get Loyalty Program Details",
215
217
  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.",
218
+ readOnly: true,
216
219
  inputSchema: TierSetGetInputSchema,
217
220
  handler: tiersetGet,
218
221
  },
219
222
  {
220
- name: "openloyalty_tierset_update",
223
+ name: "ol_tierset_update",
224
+ title: "Update Loyalty Program",
221
225
  description: "Update tier set metadata (name, description, active status, downgrade settings). Does not modify tiers - use tierset_update_tiers for that.",
226
+ readOnly: false,
222
227
  inputSchema: TierSetUpdateInputSchema,
223
228
  handler: tiersetUpdate,
224
229
  },
225
230
  {
226
- name: "openloyalty_tierset_update_tiers",
231
+ name: "ol_tierset_update_tiers",
232
+ title: "Configure Tier Thresholds",
227
233
  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
234
 
229
235
  Example for a 3-tier program with points-based progression:
@@ -232,12 +238,15 @@ Example for a 3-tier program with points-based progression:
232
238
  - Gold tier: conditions: [{ conditionId: "xxx", value: 1200 }]
233
239
 
234
240
  The conditionId must match one from tierset_get response.`,
241
+ readOnly: false,
235
242
  inputSchema: TierSetUpdateTiersInputSchema,
236
243
  handler: tiersetUpdateTiers,
237
244
  },
238
245
  {
239
- name: "openloyalty_tierset_get_tiers",
246
+ name: "ol_tierset_get_tiers",
247
+ title: "Get Tier Configuration",
240
248
  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.",
249
+ readOnly: true,
241
250
  inputSchema: TierSetGetTiersInputSchema,
242
251
  handler: tiersetGetTiers,
243
252
  },
@@ -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
  };
@@ -214,8 +214,10 @@ export declare function transactionAssignMember(input: {
214
214
  pointsEarned?: number;
215
215
  }>;
216
216
  export declare const transactionToolDefinitions: readonly [{
217
- readonly name: "openloyalty_transaction_create";
217
+ readonly name: "ol_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,31 +307,35 @@ 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
- readonly name: "openloyalty_transaction_get";
325
+ readonly name: "ol_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;
328
332
  };
329
333
  readonly handler: typeof transactionGet;
330
334
  }, {
331
- readonly name: "openloyalty_transaction_list";
335
+ readonly name: "ol_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>;
@@ -344,8 +350,10 @@ export declare const transactionToolDefinitions: readonly [{
344
350
  };
345
351
  readonly handler: typeof transactionList;
346
352
  }, {
347
- readonly name: "openloyalty_transaction_assign_member";
353
+ readonly name: "ol_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({
@@ -34,17 +34,17 @@ const CustomerDataInputSchema = z.object({
34
34
  loyaltyCardNumber: z.string().optional().describe("Loyalty card for auto-matching."),
35
35
  });
36
36
  export const TransactionCreateInputSchema = {
37
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
37
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
38
38
  header: TransactionHeaderInputSchema.describe("Transaction header with document info."),
39
39
  items: z.array(TransactionItemInputSchema).describe("Array of purchased items (at least 1 required)."),
40
40
  customerData: CustomerDataInputSchema.optional().describe("Customer data for auto-matching to member. If provided, triggers point campaigns."),
41
41
  };
42
42
  export const TransactionGetInputSchema = {
43
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
43
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
44
44
  transactionId: z.string().describe("The transaction ID (UUID) to retrieve."),
45
45
  };
46
46
  export const TransactionListInputSchema = {
47
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
47
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
48
48
  cursor: z.string().optional().describe("Pagination cursor from previous response. If provided, page/perPage are ignored."),
49
49
  page: z.number().optional().describe("Page number (default: 1)."),
50
50
  perPage: z.number().max(50).optional().describe("Items per page (default: 10, max: 50). Use 50 for aggregation queries to reduce API calls."),
@@ -56,7 +56,7 @@ export const TransactionListInputSchema = {
56
56
  purchasedAtTo: z.string().optional().describe("Filter transactions purchased on or before this date (ISO format: YYYY-MM-DD or YYYY-MM-DDTHH:mm:ssZ)."),
57
57
  };
58
58
  export const TransactionAssignMemberInputSchema = {
59
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
59
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
60
60
  documentNumber: z.string().describe("Document number of the transaction to assign."),
61
61
  customerId: z.string().optional().describe("Member ID (UUID) to assign."),
62
62
  loyaltyCardNumber: z.string().optional().describe("Loyalty card number to match member."),
@@ -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,
@@ -96,12 +95,11 @@ export async function transactionCreate(input) {
96
95
  };
97
96
  }
98
97
  catch (error) {
99
- throw formatApiError(error, "openloyalty_transaction_create");
98
+ throw formatApiError(error, "ol_transaction_create");
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;
@@ -118,12 +116,11 @@ export async function transactionGet(input) {
118
116
  };
119
117
  }
120
118
  catch (error) {
121
- throw formatApiError(error, "openloyalty_transaction_get");
119
+ throw formatApiError(error, "ol_transaction_get");
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;
@@ -171,12 +168,11 @@ export async function transactionList(input) {
171
168
  };
172
169
  }
173
170
  catch (error) {
174
- throw formatApiError(error, "openloyalty_transaction_list");
171
+ throw formatApiError(error, "ol_transaction_list");
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.");
@@ -200,27 +196,32 @@ export async function transactionAssignMember(input) {
200
196
  };
201
197
  }
202
198
  catch (error) {
203
- throw formatApiError(error, "openloyalty_transaction_assign_member");
199
+ throw formatApiError(error, "ol_transaction_assign_member");
204
200
  }
205
201
  }
206
202
  // Tool definitions
207
203
  export const transactionToolDefinitions = [
208
204
  {
209
- name: "openloyalty_transaction_create",
205
+ name: "ol_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
- name: "openloyalty_transaction_get",
215
+ name: "ol_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
- name: "openloyalty_transaction_list",
223
+ name: "ol_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
- name: "openloyalty_transaction_assign_member",
238
+ name: "ol_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
  },
@@ -15,15 +15,19 @@ export declare function walletTypeGet(input: {
15
15
  walletTypeId: string;
16
16
  }): Promise<WalletType>;
17
17
  export declare const walletTypeToolDefinitions: readonly [{
18
- readonly name: "openloyalty_wallet_type_list";
19
- 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.";
18
+ readonly name: "ol_wallet_type_list";
19
+ readonly title: "List Point Currencies";
20
+ readonly description: "List all available wallet types (point currencies). Use this to find the walletType CODE (e.g., 'default') 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
- readonly name: "openloyalty_wallet_type_get";
27
+ readonly name: "ol_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,17 +2,16 @@ 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
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
7
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
8
8
  };
9
9
  export const WalletTypeGetInputSchema = {
10
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
10
+ storeCode: z.string().optional().describe("Store code for multi-tenant routing. DO NOT pass this parameter - the configured default will be used automatically. Only provide a value if the user explicitly asks to work with a different store."),
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);
@@ -27,31 +26,34 @@ export async function walletTypeList(input) {
27
26
  }));
28
27
  }
29
28
  catch (error) {
30
- throw formatApiError(error, "openloyalty_wallet_type_list");
29
+ throw formatApiError(error, "ol_wallet_type_list");
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);
39
37
  return validated;
40
38
  }
41
39
  catch (error) {
42
- throw formatApiError(error, "openloyalty_wallet_type_get");
40
+ throw formatApiError(error, "ol_wallet_type_get");
43
41
  }
44
42
  }
45
43
  export const walletTypeToolDefinitions = [
46
44
  {
47
- name: "openloyalty_wallet_type_list",
48
- 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.",
45
+ name: "ol_wallet_type_list",
46
+ title: "List Point Currencies",
47
+ description: "List all available wallet types (point currencies). Use this to find the walletType CODE (e.g., 'default') 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
- name: "openloyalty_wallet_type_get",
53
+ name: "ol_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;
@@ -104,8 +104,10 @@ export declare function webhookEvents(input: {
104
104
  storeCode?: string;
105
105
  }): Promise<WebhookEventTypesResponse>;
106
106
  export declare const webhookToolDefinitions: readonly [{
107
- readonly name: "openloyalty_webhook_list";
107
+ readonly name: "ol_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>;
@@ -115,12 +117,14 @@ export declare const webhookToolDefinitions: readonly [{
115
117
  };
116
118
  readonly handler: typeof webhookList;
117
119
  }, {
118
- readonly name: "openloyalty_webhook_create";
120
+ readonly name: "ol_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;
@@ -134,21 +138,25 @@ export declare const webhookToolDefinitions: readonly [{
134
138
  };
135
139
  readonly handler: typeof webhookCreate;
136
140
  }, {
137
- readonly name: "openloyalty_webhook_get";
141
+ readonly name: "ol_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;
142
148
  };
143
149
  readonly handler: typeof webhookGet;
144
150
  }, {
145
- readonly name: "openloyalty_webhook_update";
151
+ readonly name: "ol_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;
@@ -162,16 +170,21 @@ export declare const webhookToolDefinitions: readonly [{
162
170
  };
163
171
  readonly handler: typeof webhookUpdate;
164
172
  }, {
165
- readonly name: "openloyalty_webhook_delete";
173
+ readonly name: "ol_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;
170
181
  };
171
182
  readonly handler: typeof webhookDelete;
172
183
  }, {
173
- readonly name: "openloyalty_webhook_events";
184
+ readonly name: "ol_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
  };