@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
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { apiGet, apiPost, apiPut, apiPatch } 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
  // Input Schemas
6
6
  export const AchievementListInputSchema = {
7
7
  storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
@@ -114,8 +114,7 @@ export const AchievementListMemberAchievementsInputSchema = {
114
114
  };
115
115
  // Handler functions
116
116
  export async function achievementList(input) {
117
- const config = getConfig();
118
- const storeCode = input.storeCode || config.defaultStoreCode;
117
+ const storeCode = getStoreCode(input.storeCode);
119
118
  const params = new URLSearchParams();
120
119
  if (input.page)
121
120
  params.append("_page", String(input.page));
@@ -150,8 +149,7 @@ export async function achievementList(input) {
150
149
  }
151
150
  }
152
151
  export async function achievementCreate(input) {
153
- const config = getConfig();
154
- const storeCode = input.storeCode || config.defaultStoreCode;
152
+ const storeCode = getStoreCode(input.storeCode);
155
153
  const achievementPayload = {
156
154
  translations: input.translations,
157
155
  rules: input.rules,
@@ -174,8 +172,7 @@ export async function achievementCreate(input) {
174
172
  }
175
173
  }
176
174
  export async function achievementGet(input) {
177
- const config = getConfig();
178
- const storeCode = input.storeCode || config.defaultStoreCode;
175
+ const storeCode = getStoreCode(input.storeCode);
179
176
  try {
180
177
  const response = await apiGet(`/${storeCode}/achievement/${input.achievementId}`);
181
178
  return response;
@@ -185,8 +182,7 @@ export async function achievementGet(input) {
185
182
  }
186
183
  }
187
184
  export async function achievementUpdate(input) {
188
- const config = getConfig();
189
- const storeCode = input.storeCode || config.defaultStoreCode;
185
+ const storeCode = getStoreCode(input.storeCode);
190
186
  const achievementPayload = {
191
187
  translations: input.translations,
192
188
  rules: input.rules,
@@ -208,8 +204,7 @@ export async function achievementUpdate(input) {
208
204
  }
209
205
  }
210
206
  export async function achievementPatch(input) {
211
- const config = getConfig();
212
- const storeCode = input.storeCode || config.defaultStoreCode;
207
+ const storeCode = getStoreCode(input.storeCode);
213
208
  const achievementPayload = {};
214
209
  if (input.active !== undefined)
215
210
  achievementPayload.active = input.active;
@@ -224,8 +219,7 @@ export async function achievementPatch(input) {
224
219
  }
225
220
  }
226
221
  export async function achievementGetMemberProgress(input) {
227
- const config = getConfig();
228
- const storeCode = input.storeCode || config.defaultStoreCode;
222
+ const storeCode = getStoreCode(input.storeCode);
229
223
  try {
230
224
  const response = await apiGet(`/${storeCode}/member/${input.memberId}/achievement/${input.achievementId}`);
231
225
  return response;
@@ -235,8 +229,7 @@ export async function achievementGetMemberProgress(input) {
235
229
  }
236
230
  }
237
231
  export async function achievementListMemberAchievements(input) {
238
- const config = getConfig();
239
- const storeCode = input.storeCode || config.defaultStoreCode;
232
+ const storeCode = getStoreCode(input.storeCode);
240
233
  const params = new URLSearchParams();
241
234
  if (input.page)
242
235
  params.append("_page", String(input.page));
@@ -268,43 +261,57 @@ export async function achievementListMemberAchievements(input) {
268
261
  export const achievementToolDefinitions = [
269
262
  {
270
263
  name: "openloyalty_achievement_list",
264
+ title: "List Achievements",
271
265
  description: "List achievements. Achievements gamify member behavior by setting goals (e.g., 'Make 5 purchases this month'). Returns achievementId, name, active status, and associated badge. Use achievement_get for full rules and configuration.",
266
+ readOnly: true,
272
267
  inputSchema: AchievementListInputSchema,
273
268
  handler: achievementList,
274
269
  },
275
270
  {
276
271
  name: "openloyalty_achievement_create",
272
+ title: "Create Achievement",
277
273
  description: "Create achievement with rules that track member progress. Triggers: transaction (purchases), custom_event (custom actions), points_transfer, referral, etc. CompleteRule sets the goal: periodGoal (target value) with optional period (consecutive periods). Example - '5 purchases/month': rules: [{ trigger: 'transaction', completeRule: { periodGoal: 5, period: { value: 1, consecutive: 1 } } }]",
274
+ readOnly: false,
278
275
  inputSchema: AchievementCreateInputSchema,
279
276
  handler: achievementCreate,
280
277
  },
281
278
  {
282
279
  name: "openloyalty_achievement_get",
280
+ title: "Get Achievement Details",
283
281
  description: "Get achievement details including all rules, conditions, activity period, limits, and completions count.",
282
+ readOnly: true,
284
283
  inputSchema: AchievementGetInputSchema,
285
284
  handler: achievementGet,
286
285
  },
287
286
  {
288
287
  name: "openloyalty_achievement_update",
288
+ title: "Update Achievement",
289
289
  description: "Update achievement configuration. Requires full achievement object (translations, rules). Use achievement_get first to retrieve current configuration.",
290
+ readOnly: false,
290
291
  inputSchema: AchievementUpdateInputSchema,
291
292
  handler: achievementUpdate,
292
293
  },
293
294
  {
294
295
  name: "openloyalty_achievement_patch",
296
+ title: "Patch Achievement",
295
297
  description: "Partial update of achievement. Use for simple changes like activating/deactivating or updating translations without providing full rules.",
298
+ readOnly: false,
296
299
  inputSchema: AchievementPatchInputSchema,
297
300
  handler: achievementPatch,
298
301
  },
299
302
  {
300
303
  name: "openloyalty_achievement_get_member_progress",
304
+ title: "Get Member Achievement Progress",
301
305
  description: "Get member's progress on a specific achievement. Returns completedCount, and for each rule: periodGoal, currentPeriodValue, and consecutive period tracking.",
306
+ readOnly: true,
302
307
  inputSchema: AchievementGetMemberProgressInputSchema,
303
308
  handler: achievementGetMemberProgress,
304
309
  },
305
310
  {
306
311
  name: "openloyalty_achievement_list_member_achievements",
312
+ title: "List Member Achievements",
307
313
  description: "List all achievements with member's progress. Returns each achievement's status, completion count, and per-rule progress. Use for displaying gamification dashboard.",
314
+ readOnly: true,
308
315
  inputSchema: AchievementListMemberAchievementsInputSchema,
309
316
  handler: achievementListMemberAchievements,
310
317
  },
@@ -88,7 +88,9 @@ export declare function adminChangePassword(input: {
88
88
  export declare function adminGetPermissions(): Promise<AdminPermission>;
89
89
  export declare const adminToolDefinitions: readonly [{
90
90
  readonly name: "openloyalty_admin_list";
91
+ readonly title: "List Admin Users";
91
92
  readonly description: "List admin users with optional filtering. Returns paginated list of admin users with id, email, firstName, lastName, isActive, createdAt.";
93
+ readonly readOnly: true;
92
94
  readonly inputSchema: {
93
95
  page: z.ZodOptional<z.ZodNumber>;
94
96
  perPage: z.ZodOptional<z.ZodNumber>;
@@ -101,7 +103,9 @@ export declare const adminToolDefinitions: readonly [{
101
103
  readonly handler: typeof adminList;
102
104
  }, {
103
105
  readonly name: "openloyalty_admin_create";
106
+ readonly title: "Create Admin User";
104
107
  readonly description: "Create a new admin user. Requires email and password. Optionally assign roles, set active status, and configure notifications. Returns adminId.";
108
+ readonly readOnly: false;
105
109
  readonly inputSchema: {
106
110
  email: z.ZodString;
107
111
  password: z.ZodString;
@@ -116,14 +120,18 @@ export declare const adminToolDefinitions: readonly [{
116
120
  readonly handler: typeof adminCreate;
117
121
  }, {
118
122
  readonly name: "openloyalty_admin_get";
123
+ readonly title: "Get Admin User Details";
119
124
  readonly description: "Get full admin user details by ID. Returns profile including email, name, roles, settings, active status, and creation date.";
125
+ readonly readOnly: true;
120
126
  readonly inputSchema: {
121
127
  adminId: z.ZodString;
122
128
  };
123
129
  readonly handler: typeof adminGet;
124
130
  }, {
125
131
  readonly name: "openloyalty_admin_update";
132
+ readonly title: "Update Admin User";
126
133
  readonly description: "Update admin user profile. Can update email, name, phone, roles, active status, and password. Returns adminId on success.";
134
+ readonly readOnly: false;
127
135
  readonly inputSchema: {
128
136
  adminId: z.ZodString;
129
137
  email: z.ZodOptional<z.ZodString>;
@@ -139,7 +147,9 @@ export declare const adminToolDefinitions: readonly [{
139
147
  readonly handler: typeof adminUpdate;
140
148
  }, {
141
149
  readonly name: "openloyalty_admin_change_password";
150
+ readonly title: "Change Admin Password";
142
151
  readonly description: "Change the currently logged-in admin's password. Requires current password for verification. Returns void on success.";
152
+ readonly readOnly: false;
143
153
  readonly inputSchema: {
144
154
  currentPassword: z.ZodString;
145
155
  newPassword: z.ZodString;
@@ -147,7 +157,9 @@ export declare const adminToolDefinitions: readonly [{
147
157
  readonly handler: typeof adminChangePassword;
148
158
  }, {
149
159
  readonly name: "openloyalty_admin_get_permissions";
160
+ readonly title: "Get Admin Permissions";
150
161
  readonly description: "Get the current admin user's permissions. Returns superAdmin flag, list of roles, and list of permission strings. Use to check what actions are available.";
162
+ readonly readOnly: true;
151
163
  readonly inputSchema: {};
152
164
  readonly handler: typeof adminGetPermissions;
153
165
  }];
@@ -156,37 +156,49 @@ export async function adminGetPermissions() {
156
156
  export const adminToolDefinitions = [
157
157
  {
158
158
  name: "openloyalty_admin_list",
159
+ title: "List Admin Users",
159
160
  description: "List admin users with optional filtering. Returns paginated list of admin users with id, email, firstName, lastName, isActive, createdAt.",
161
+ readOnly: true,
160
162
  inputSchema: AdminListInputSchema,
161
163
  handler: adminList,
162
164
  },
163
165
  {
164
166
  name: "openloyalty_admin_create",
167
+ title: "Create Admin User",
165
168
  description: "Create a new admin user. Requires email and password. Optionally assign roles, set active status, and configure notifications. Returns adminId.",
169
+ readOnly: false,
166
170
  inputSchema: AdminCreateInputSchema,
167
171
  handler: adminCreate,
168
172
  },
169
173
  {
170
174
  name: "openloyalty_admin_get",
175
+ title: "Get Admin User Details",
171
176
  description: "Get full admin user details by ID. Returns profile including email, name, roles, settings, active status, and creation date.",
177
+ readOnly: true,
172
178
  inputSchema: AdminGetInputSchema,
173
179
  handler: adminGet,
174
180
  },
175
181
  {
176
182
  name: "openloyalty_admin_update",
183
+ title: "Update Admin User",
177
184
  description: "Update admin user profile. Can update email, name, phone, roles, active status, and password. Returns adminId on success.",
185
+ readOnly: false,
178
186
  inputSchema: AdminUpdateInputSchema,
179
187
  handler: adminUpdate,
180
188
  },
181
189
  {
182
190
  name: "openloyalty_admin_change_password",
191
+ title: "Change Admin Password",
183
192
  description: "Change the currently logged-in admin's password. Requires current password for verification. Returns void on success.",
193
+ readOnly: false,
184
194
  inputSchema: AdminChangePasswordInputSchema,
185
195
  handler: adminChangePassword,
186
196
  },
187
197
  {
188
198
  name: "openloyalty_admin_get_permissions",
199
+ title: "Get Admin Permissions",
189
200
  description: "Get the current admin user's permissions. Returns superAdmin flag, list of roles, and list of permission strings. Use to check what actions are available.",
201
+ readOnly: true,
190
202
  inputSchema: {},
191
203
  handler: adminGetPermissions,
192
204
  },
@@ -84,14 +84,18 @@ export declare function analyticsCampaignDetail(input: {
84
84
  }): Promise<Record<string, unknown>>;
85
85
  export declare const analyticsToolDefinitions: readonly [{
86
86
  readonly name: "openloyalty_analytics_tiers";
87
+ readonly title: "Get Tier Analytics";
87
88
  readonly description: "Get tier (level) analytics showing member distribution across tiers. Returns tier IDs, names, and member counts for each tier level.";
89
+ readonly readOnly: true;
88
90
  readonly inputSchema: {
89
91
  storeCode: z.ZodOptional<z.ZodString>;
90
92
  };
91
93
  readonly handler: typeof analyticsTiers;
92
94
  }, {
93
95
  readonly name: "openloyalty_analytics_members";
96
+ readonly title: "Get Member Analytics";
94
97
  readonly description: "Get member analytics showing registration trends. Returns member counts by time intervals (1 day, 7 days, 30 days, 365 days). Filter by transaction status to see engaged vs unengaged members.";
98
+ readonly readOnly: true;
95
99
  readonly inputSchema: {
96
100
  storeCode: z.ZodOptional<z.ZodString>;
97
101
  withTransaction: z.ZodOptional<z.ZodBoolean>;
@@ -99,28 +103,36 @@ export declare const analyticsToolDefinitions: readonly [{
99
103
  readonly handler: typeof analyticsMembers;
100
104
  }, {
101
105
  readonly name: "openloyalty_analytics_points";
106
+ readonly title: "Get Points Analytics";
102
107
  readonly description: "Get points analytics showing program health. Returns total active points, points spent, points issued, expired points, and pending points. Use to monitor points economy.";
108
+ readonly readOnly: true;
103
109
  readonly inputSchema: {
104
110
  storeCode: z.ZodOptional<z.ZodString>;
105
111
  };
106
112
  readonly handler: typeof analyticsPoints;
107
113
  }, {
108
114
  readonly name: "openloyalty_analytics_transactions";
115
+ readonly title: "Get Transaction Analytics";
109
116
  readonly description: "Get transaction analytics showing purchase trends. Returns transaction counts by intervals, total count, total amount, and average values. Use to monitor sales performance.";
117
+ readonly readOnly: true;
110
118
  readonly inputSchema: {
111
119
  storeCode: z.ZodOptional<z.ZodString>;
112
120
  };
113
121
  readonly handler: typeof analyticsTransactions;
114
122
  }, {
115
123
  readonly name: "openloyalty_analytics_referrals";
124
+ readonly title: "Get Referral Analytics";
116
125
  readonly description: "Get referral program analytics showing referral activity. Returns total referral count. Use to monitor referral program performance.";
126
+ readonly readOnly: true;
117
127
  readonly inputSchema: {
118
128
  storeCode: z.ZodOptional<z.ZodString>;
119
129
  };
120
130
  readonly handler: typeof analyticsReferrals;
121
131
  }, {
122
132
  readonly name: "openloyalty_analytics_campaigns";
133
+ readonly title: "Get Campaign Analytics";
123
134
  readonly description: "Get campaign analytics showing execution counts per campaign. Returns list of campaigns with their execution counts. Use to identify most successful campaigns.";
135
+ readonly readOnly: true;
124
136
  readonly inputSchema: {
125
137
  storeCode: z.ZodOptional<z.ZodString>;
126
138
  page: z.ZodOptional<z.ZodNumber>;
@@ -130,7 +142,9 @@ export declare const analyticsToolDefinitions: readonly [{
130
142
  readonly handler: typeof analyticsCampaigns;
131
143
  }, {
132
144
  readonly name: "openloyalty_analytics_dashboard";
145
+ readonly title: "Get Dashboard Overview";
133
146
  readonly description: "Get dashboard overview metrics with time-series data. Returns key metrics (registered members, active members, revenue, avg spending, transactions) with optional date range and aggregation. Use for high-level program dashboards.";
147
+ readonly readOnly: true;
134
148
  readonly inputSchema: {
135
149
  storeCode: z.ZodOptional<z.ZodString>;
136
150
  dataType: z.ZodOptional<z.ZodEnum<["registeredMembers", "activeMembers", "revenue", "avgSpending", "transactions", "avgTransactionValue", "avgNumberOfTransactions"]>>;
@@ -141,7 +155,9 @@ export declare const analyticsToolDefinitions: readonly [{
141
155
  readonly handler: typeof analyticsDashboard;
142
156
  }, {
143
157
  readonly name: "openloyalty_analytics_units";
158
+ readonly title: "Get Units Overview";
144
159
  readonly description: "Get wallet-specific analytics (units overview). Returns units issued, spent, expired, pending, active, plus redemption and breakage rates. Requires walletTypeCode parameter. Use for detailed points economy analysis.";
160
+ readonly readOnly: true;
145
161
  readonly inputSchema: {
146
162
  storeCode: z.ZodOptional<z.ZodString>;
147
163
  walletTypeCode: z.ZodString;
@@ -153,7 +169,9 @@ export declare const analyticsToolDefinitions: readonly [{
153
169
  readonly handler: typeof analyticsUnits;
154
170
  }, {
155
171
  readonly name: "openloyalty_analytics_campaign_detail";
172
+ readonly title: "Get Campaign Detail Analytics";
156
173
  readonly description: "Get detailed analytics for a specific campaign. Returns campaign-specific performance metrics. Use after analytics_campaigns to drill into individual campaign performance.";
174
+ readonly readOnly: true;
157
175
  readonly inputSchema: {
158
176
  storeCode: z.ZodOptional<z.ZodString>;
159
177
  campaignId: z.ZodString;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { apiGet } 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
  // Input Schemas
6
6
  export const AnalyticsTiersInputSchema = {
7
7
  storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
@@ -51,8 +51,7 @@ export const AnalyticsCampaignDetailInputSchema = {
51
51
  };
52
52
  // Handler functions
53
53
  export async function analyticsTiers(input) {
54
- const config = getConfig();
55
- const storeCode = input.storeCode || config.defaultStoreCode;
54
+ const storeCode = getStoreCode(input.storeCode);
56
55
  try {
57
56
  const response = await apiGet(`/${storeCode}/analytics/levels`);
58
57
  return response;
@@ -62,8 +61,7 @@ export async function analyticsTiers(input) {
62
61
  }
63
62
  }
64
63
  export async function analyticsMembers(input) {
65
- const config = getConfig();
66
- const storeCode = input.storeCode || config.defaultStoreCode;
64
+ const storeCode = getStoreCode(input.storeCode);
67
65
  const params = new URLSearchParams();
68
66
  if (input.withTransaction !== undefined) {
69
67
  params.append("withTransaction", String(input.withTransaction));
@@ -79,8 +77,7 @@ export async function analyticsMembers(input) {
79
77
  }
80
78
  }
81
79
  export async function analyticsPoints(input) {
82
- const config = getConfig();
83
- const storeCode = input.storeCode || config.defaultStoreCode;
80
+ const storeCode = getStoreCode(input.storeCode);
84
81
  try {
85
82
  const response = await apiGet(`/${storeCode}/analytics/points`);
86
83
  return response;
@@ -90,8 +87,7 @@ export async function analyticsPoints(input) {
90
87
  }
91
88
  }
92
89
  export async function analyticsTransactions(input) {
93
- const config = getConfig();
94
- const storeCode = input.storeCode || config.defaultStoreCode;
90
+ const storeCode = getStoreCode(input.storeCode);
95
91
  try {
96
92
  const response = await apiGet(`/${storeCode}/analytics/transactions`);
97
93
  return response;
@@ -101,8 +97,7 @@ export async function analyticsTransactions(input) {
101
97
  }
102
98
  }
103
99
  export async function analyticsReferrals(input) {
104
- const config = getConfig();
105
- const storeCode = input.storeCode || config.defaultStoreCode;
100
+ const storeCode = getStoreCode(input.storeCode);
106
101
  try {
107
102
  const response = await apiGet(`/${storeCode}/analytics/referrals`);
108
103
  return response;
@@ -112,8 +107,7 @@ export async function analyticsReferrals(input) {
112
107
  }
113
108
  }
114
109
  export async function analyticsCampaigns(input) {
115
- const config = getConfig();
116
- const storeCode = input.storeCode || config.defaultStoreCode;
110
+ const storeCode = getStoreCode(input.storeCode);
117
111
  const params = new URLSearchParams();
118
112
  if (input.page)
119
113
  params.append("_page", String(input.page));
@@ -132,8 +126,7 @@ export async function analyticsCampaigns(input) {
132
126
  }
133
127
  }
134
128
  export async function analyticsDashboard(input) {
135
- const config = getConfig();
136
- const storeCode = input.storeCode || config.defaultStoreCode;
129
+ const storeCode = getStoreCode(input.storeCode);
137
130
  const params = new URLSearchParams();
138
131
  if (input.dataType)
139
132
  params.append("dataType", input.dataType);
@@ -154,8 +147,7 @@ export async function analyticsDashboard(input) {
154
147
  }
155
148
  }
156
149
  export async function analyticsUnits(input) {
157
- const config = getConfig();
158
- const storeCode = input.storeCode || config.defaultStoreCode;
150
+ const storeCode = getStoreCode(input.storeCode);
159
151
  const params = new URLSearchParams();
160
152
  if (input.dataType)
161
153
  params.append("dataType", input.dataType);
@@ -176,8 +168,7 @@ export async function analyticsUnits(input) {
176
168
  }
177
169
  }
178
170
  export async function analyticsCampaignDetail(input) {
179
- const config = getConfig();
180
- const storeCode = input.storeCode || config.defaultStoreCode;
171
+ const storeCode = getStoreCode(input.storeCode);
181
172
  try {
182
173
  const response = await apiGet(`/${storeCode}/analytics/campaign/${input.campaignId}`);
183
174
  return response;
@@ -190,55 +181,73 @@ export async function analyticsCampaignDetail(input) {
190
181
  export const analyticsToolDefinitions = [
191
182
  {
192
183
  name: "openloyalty_analytics_tiers",
184
+ title: "Get Tier Analytics",
193
185
  description: "Get tier (level) analytics showing member distribution across tiers. Returns tier IDs, names, and member counts for each tier level.",
186
+ readOnly: true,
194
187
  inputSchema: AnalyticsTiersInputSchema,
195
188
  handler: analyticsTiers,
196
189
  },
197
190
  {
198
191
  name: "openloyalty_analytics_members",
192
+ title: "Get Member Analytics",
199
193
  description: "Get member analytics showing registration trends. Returns member counts by time intervals (1 day, 7 days, 30 days, 365 days). Filter by transaction status to see engaged vs unengaged members.",
194
+ readOnly: true,
200
195
  inputSchema: AnalyticsMembersInputSchema,
201
196
  handler: analyticsMembers,
202
197
  },
203
198
  {
204
199
  name: "openloyalty_analytics_points",
200
+ title: "Get Points Analytics",
205
201
  description: "Get points analytics showing program health. Returns total active points, points spent, points issued, expired points, and pending points. Use to monitor points economy.",
202
+ readOnly: true,
206
203
  inputSchema: AnalyticsPointsInputSchema,
207
204
  handler: analyticsPoints,
208
205
  },
209
206
  {
210
207
  name: "openloyalty_analytics_transactions",
208
+ title: "Get Transaction Analytics",
211
209
  description: "Get transaction analytics showing purchase trends. Returns transaction counts by intervals, total count, total amount, and average values. Use to monitor sales performance.",
210
+ readOnly: true,
212
211
  inputSchema: AnalyticsTransactionsInputSchema,
213
212
  handler: analyticsTransactions,
214
213
  },
215
214
  {
216
215
  name: "openloyalty_analytics_referrals",
216
+ title: "Get Referral Analytics",
217
217
  description: "Get referral program analytics showing referral activity. Returns total referral count. Use to monitor referral program performance.",
218
+ readOnly: true,
218
219
  inputSchema: AnalyticsReferralsInputSchema,
219
220
  handler: analyticsReferrals,
220
221
  },
221
222
  {
222
223
  name: "openloyalty_analytics_campaigns",
224
+ title: "Get Campaign Analytics",
223
225
  description: "Get campaign analytics showing execution counts per campaign. Returns list of campaigns with their execution counts. Use to identify most successful campaigns.",
226
+ readOnly: true,
224
227
  inputSchema: AnalyticsCampaignsInputSchema,
225
228
  handler: analyticsCampaigns,
226
229
  },
227
230
  {
228
231
  name: "openloyalty_analytics_dashboard",
232
+ title: "Get Dashboard Overview",
229
233
  description: "Get dashboard overview metrics with time-series data. Returns key metrics (registered members, active members, revenue, avg spending, transactions) with optional date range and aggregation. Use for high-level program dashboards.",
234
+ readOnly: true,
230
235
  inputSchema: AnalyticsDashboardInputSchema,
231
236
  handler: analyticsDashboard,
232
237
  },
233
238
  {
234
239
  name: "openloyalty_analytics_units",
240
+ title: "Get Units Overview",
235
241
  description: "Get wallet-specific analytics (units overview). Returns units issued, spent, expired, pending, active, plus redemption and breakage rates. Requires walletTypeCode parameter. Use for detailed points economy analysis.",
242
+ readOnly: true,
236
243
  inputSchema: AnalyticsUnitsInputSchema,
237
244
  handler: analyticsUnits,
238
245
  },
239
246
  {
240
247
  name: "openloyalty_analytics_campaign_detail",
248
+ title: "Get Campaign Detail Analytics",
241
249
  description: "Get detailed analytics for a specific campaign. Returns campaign-specific performance metrics. Use after analytics_campaigns to drill into individual campaign performance.",
250
+ readOnly: true,
242
251
  inputSchema: AnalyticsCampaignDetailInputSchema,
243
252
  handler: analyticsCampaignDetail,
244
253
  },
@@ -45,7 +45,9 @@ export declare function apiKeyDelete(input: {
45
45
  }): Promise<void>;
46
46
  export declare const apiKeyToolDefinitions: readonly [{
47
47
  readonly name: "openloyalty_apikey_create";
48
+ readonly title: "Create API Key";
48
49
  readonly description: "Create a new API key for an admin user. CRITICAL: The API token is ONLY returned at creation time. Store it securely immediately - it cannot be retrieved later. Returns apiKeyId, token, adminId, name, and expirationDate.";
50
+ readonly readOnly: false;
49
51
  readonly inputSchema: {
50
52
  adminId: z.ZodString;
51
53
  name: z.ZodOptional<z.ZodString>;
@@ -54,7 +56,9 @@ export declare const apiKeyToolDefinitions: readonly [{
54
56
  readonly handler: typeof apiKeyCreate;
55
57
  }, {
56
58
  readonly name: "openloyalty_apikey_list";
59
+ readonly title: "List API Keys";
57
60
  readonly description: "List API keys for an admin user. Returns list of API keys with apiKeyId, adminId, name, and expirationDate. Note: tokens are not returned in list responses for security.";
61
+ readonly readOnly: true;
58
62
  readonly inputSchema: {
59
63
  adminId: z.ZodString;
60
64
  page: z.ZodOptional<z.ZodNumber>;
@@ -63,7 +67,10 @@ export declare const apiKeyToolDefinitions: readonly [{
63
67
  readonly handler: typeof apiKeyList;
64
68
  }, {
65
69
  readonly name: "openloyalty_apikey_delete";
70
+ readonly title: "Delete API Key (Permanent)";
66
71
  readonly description: "Delete an API key. Returns void on success (204 No Content). The API key will be immediately invalidated.";
72
+ readonly readOnly: false;
73
+ readonly destructive: true;
67
74
  readonly inputSchema: {
68
75
  adminId: z.ZodString;
69
76
  apiKeyId: z.ZodString;
@@ -59,19 +59,26 @@ export async function apiKeyDelete(input) {
59
59
  export const apiKeyToolDefinitions = [
60
60
  {
61
61
  name: "openloyalty_apikey_create",
62
+ title: "Create API Key",
62
63
  description: "Create a new API key for an admin user. CRITICAL: The API token is ONLY returned at creation time. Store it securely immediately - it cannot be retrieved later. Returns apiKeyId, token, adminId, name, and expirationDate.",
64
+ readOnly: false,
63
65
  inputSchema: ApiKeyCreateInputSchema,
64
66
  handler: apiKeyCreate,
65
67
  },
66
68
  {
67
69
  name: "openloyalty_apikey_list",
70
+ title: "List API Keys",
68
71
  description: "List API keys for an admin user. Returns list of API keys with apiKeyId, adminId, name, and expirationDate. Note: tokens are not returned in list responses for security.",
72
+ readOnly: true,
69
73
  inputSchema: ApiKeyListInputSchema,
70
74
  handler: apiKeyList,
71
75
  },
72
76
  {
73
77
  name: "openloyalty_apikey_delete",
78
+ title: "Delete API Key (Permanent)",
74
79
  description: "Delete an API key. Returns void on success (204 No Content). The API key will be immediately invalidated.",
80
+ readOnly: false,
81
+ destructive: true,
75
82
  inputSchema: ApiKeyDeleteInputSchema,
76
83
  handler: apiKeyDelete,
77
84
  },
@@ -81,7 +81,9 @@ export declare function auditExport(input: {
81
81
  }>;
82
82
  export declare const auditToolDefinitions: readonly [{
83
83
  readonly name: "openloyalty_audit_list";
84
+ readonly title: "List Audit Logs";
84
85
  readonly description: "List audit log entries with optional filtering. Returns paginated list of audit entries with auditLogId, eventType, entityType, entityId, username, timestamp, and details. Audit logs track all administrative actions. Use for compliance and troubleshooting.";
86
+ readonly readOnly: true;
85
87
  readonly inputSchema: {
86
88
  page: z.ZodOptional<z.ZodNumber>;
87
89
  perPage: z.ZodOptional<z.ZodNumber>;
@@ -96,7 +98,9 @@ export declare const auditToolDefinitions: readonly [{
96
98
  readonly handler: typeof auditList;
97
99
  }, {
98
100
  readonly name: "openloyalty_audit_export";
101
+ readonly title: "Export Audit Logs";
99
102
  readonly description: "Create an export of system logs. Returns exportId that can be used to track export status. The export will be processed asynchronously. Use date filters to scope the export range.";
103
+ readonly readOnly: false;
100
104
  readonly inputSchema: {
101
105
  dateFrom: z.ZodOptional<z.ZodString>;
102
106
  dateTo: z.ZodOptional<z.ZodString>;
@@ -77,13 +77,17 @@ export async function auditExport(input) {
77
77
  export const auditToolDefinitions = [
78
78
  {
79
79
  name: "openloyalty_audit_list",
80
+ title: "List Audit Logs",
80
81
  description: "List audit log entries with optional filtering. Returns paginated list of audit entries with auditLogId, eventType, entityType, entityId, username, timestamp, and details. Audit logs track all administrative actions. Use for compliance and troubleshooting.",
82
+ readOnly: true,
81
83
  inputSchema: AuditListInputSchema,
82
84
  handler: auditList,
83
85
  },
84
86
  {
85
87
  name: "openloyalty_audit_export",
88
+ title: "Export Audit Logs",
86
89
  description: "Create an export of system logs. Returns exportId that can be used to track export status. The export will be processed asynchronously. Use date filters to scope the export range.",
90
+ readOnly: false,
87
91
  inputSchema: AuditExportInputSchema,
88
92
  handler: auditExport,
89
93
  },
@@ -81,7 +81,9 @@ export declare function badgeGetMemberBadges(input: {
81
81
  }>;
82
82
  export declare const badgeToolDefinitions: readonly [{
83
83
  readonly name: "openloyalty_badge_list";
84
+ readonly title: "List Badges";
84
85
  readonly description: "List badge types. Badges are visual rewards linked to achievements. When a member completes an achievement with a badgeTypeId, they earn that badge. Use for displaying available badges.";
86
+ readonly readOnly: true;
85
87
  readonly inputSchema: {
86
88
  storeCode: z.ZodOptional<z.ZodString>;
87
89
  page: z.ZodOptional<z.ZodNumber>;
@@ -92,7 +94,9 @@ export declare const badgeToolDefinitions: readonly [{
92
94
  readonly handler: typeof badgeList;
93
95
  }, {
94
96
  readonly name: "openloyalty_badge_get";
97
+ readonly title: "Get Badge Details";
95
98
  readonly description: "Get badge type details including name, image URL, and linked achievements count.";
99
+ readonly readOnly: true;
96
100
  readonly inputSchema: {
97
101
  storeCode: z.ZodOptional<z.ZodString>;
98
102
  badgeTypeId: z.ZodString;
@@ -100,7 +104,9 @@ export declare const badgeToolDefinitions: readonly [{
100
104
  readonly handler: typeof badgeGet;
101
105
  }, {
102
106
  readonly name: "openloyalty_badge_update";
107
+ readonly title: "Update Badge";
103
108
  readonly description: "Update badge type configuration. Badge types are created automatically when referenced by achievements. Use this to update name, image, or translations.";
109
+ readonly readOnly: false;
104
110
  readonly inputSchema: {
105
111
  storeCode: z.ZodOptional<z.ZodString>;
106
112
  badgeTypeId: z.ZodString;
@@ -121,7 +127,9 @@ export declare const badgeToolDefinitions: readonly [{
121
127
  readonly handler: typeof badgeUpdate;
122
128
  }, {
123
129
  readonly name: "openloyalty_badge_get_member_badges";
130
+ readonly title: "Get Member Badges";
124
131
  readonly description: "Get badges earned by a member. Returns each badge with completedCount showing how many times it was earned. Use for displaying member's badge collection.";
132
+ readonly readOnly: true;
125
133
  readonly inputSchema: {
126
134
  storeCode: z.ZodOptional<z.ZodString>;
127
135
  memberId: z.ZodString;