@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
@@ -1,42 +1,42 @@
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
- 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 AnalyticsMembersInputSchema = {
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
  withTransaction: z.boolean().optional().describe("Filter: true for members with transactions, false for members without, omit for all."),
12
12
  };
13
13
  export const AnalyticsPointsInputSchema = {
14
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
14
+ 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."),
15
15
  };
16
16
  export const AnalyticsTransactionsInputSchema = {
17
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
17
+ 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."),
18
18
  };
19
19
  export const AnalyticsReferralsInputSchema = {
20
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
20
+ 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."),
21
21
  };
22
22
  export const AnalyticsCampaignsInputSchema = {
23
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
23
+ 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."),
24
24
  page: z.number().optional().describe("Page number (default: 1)."),
25
25
  perPage: z.number().optional().describe("Items per page (default: 25)."),
26
26
  executedAt: z.string().optional().describe("Filter by execution date (ISO format)."),
27
27
  };
28
28
  export const AnalyticsDashboardInputSchema = {
29
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
29
+ 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."),
30
30
  dataType: z.enum([
31
31
  "registeredMembers", "activeMembers", "revenue", "avgSpending",
32
32
  "transactions", "avgTransactionValue", "avgNumberOfTransactions"
33
- ]).optional().describe("Type of data to retrieve."),
33
+ ]).describe("REQUIRED: Type of data to retrieve. Options: registeredMembers, activeMembers, revenue, avgSpending, transactions, avgTransactionValue, avgNumberOfTransactions."),
34
34
  aggregationType: z.enum(["day", "week", "month"]).optional().describe("Aggregation granularity."),
35
35
  intervalStartDate: z.string().optional().describe("Start date (YYYY-MM-DD format)."),
36
36
  intervalEndDate: z.string().optional().describe("End date (YYYY-MM-DD format)."),
37
37
  };
38
38
  export const AnalyticsUnitsInputSchema = {
39
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
39
+ 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."),
40
40
  walletTypeCode: z.string().describe("Wallet type code (e.g., 'default' or 'points')."),
41
41
  dataType: z.enum([
42
42
  "unitsIssued", "unitsSpent", "unitsExpired", "unitsPending", "unitsActive"
@@ -46,24 +46,22 @@ export const AnalyticsUnitsInputSchema = {
46
46
  intervalEndDate: z.string().optional().describe("End date (YYYY-MM-DD format)."),
47
47
  };
48
48
  export const AnalyticsCampaignDetailInputSchema = {
49
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
49
+ 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."),
50
50
  campaignId: z.string().describe("The campaign ID to get analytics for."),
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;
59
58
  }
60
59
  catch (error) {
61
- throw formatApiError(error, "openloyalty_analytics_tiers");
60
+ throw formatApiError(error, "ol_analytics_tiers");
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));
@@ -75,45 +73,41 @@ export async function analyticsMembers(input) {
75
73
  return response;
76
74
  }
77
75
  catch (error) {
78
- throw formatApiError(error, "openloyalty_analytics_members");
76
+ throw formatApiError(error, "ol_analytics_members");
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;
87
84
  }
88
85
  catch (error) {
89
- throw formatApiError(error, "openloyalty_analytics_points");
86
+ throw formatApiError(error, "ol_analytics_points");
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;
98
94
  }
99
95
  catch (error) {
100
- throw formatApiError(error, "openloyalty_analytics_transactions");
96
+ throw formatApiError(error, "ol_analytics_transactions");
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;
109
104
  }
110
105
  catch (error) {
111
- throw formatApiError(error, "openloyalty_analytics_referrals");
106
+ throw formatApiError(error, "ol_analytics_referrals");
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));
@@ -128,12 +122,11 @@ export async function analyticsCampaigns(input) {
128
122
  return response;
129
123
  }
130
124
  catch (error) {
131
- throw formatApiError(error, "openloyalty_analytics_campaigns");
125
+ throw formatApiError(error, "ol_analytics_campaigns");
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);
@@ -150,12 +143,11 @@ export async function analyticsDashboard(input) {
150
143
  return response;
151
144
  }
152
145
  catch (error) {
153
- throw formatApiError(error, "openloyalty_analytics_dashboard");
146
+ throw formatApiError(error, "ol_analytics_dashboard");
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);
@@ -172,73 +164,91 @@ export async function analyticsUnits(input) {
172
164
  return response;
173
165
  }
174
166
  catch (error) {
175
- throw formatApiError(error, "openloyalty_analytics_units");
167
+ throw formatApiError(error, "ol_analytics_units");
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
- const response = await apiGet(`/${storeCode}/analytics/campaign/${input.campaignId}`);
173
+ // API endpoint uses /campaigns (plural) with campaign ID as query param
174
+ const response = await apiGet(`/${storeCode}/analytics/campaigns?campaignId=${input.campaignId}`);
183
175
  return response;
184
176
  }
185
177
  catch (error) {
186
- throw formatApiError(error, "openloyalty_analytics_campaign_detail");
178
+ throw formatApiError(error, "ol_analytics_campaign_detail");
187
179
  }
188
180
  }
189
181
  // Tool definitions
190
182
  export const analyticsToolDefinitions = [
191
183
  {
192
- name: "openloyalty_analytics_tiers",
184
+ name: "ol_analytics_tiers",
185
+ title: "Get Tier Analytics",
193
186
  description: "Get tier (level) analytics showing member distribution across tiers. Returns tier IDs, names, and member counts for each tier level.",
187
+ readOnly: true,
194
188
  inputSchema: AnalyticsTiersInputSchema,
195
189
  handler: analyticsTiers,
196
190
  },
197
191
  {
198
- name: "openloyalty_analytics_members",
192
+ name: "ol_analytics_members",
193
+ title: "Get Member Analytics",
199
194
  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.",
195
+ readOnly: true,
200
196
  inputSchema: AnalyticsMembersInputSchema,
201
197
  handler: analyticsMembers,
202
198
  },
203
199
  {
204
- name: "openloyalty_analytics_points",
200
+ name: "ol_analytics_points",
201
+ title: "Get Points Analytics",
205
202
  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.",
203
+ readOnly: true,
206
204
  inputSchema: AnalyticsPointsInputSchema,
207
205
  handler: analyticsPoints,
208
206
  },
209
207
  {
210
- name: "openloyalty_analytics_transactions",
208
+ name: "ol_analytics_transactions",
209
+ title: "Get Transaction Analytics",
211
210
  description: "Get transaction analytics showing purchase trends. Returns transaction counts by intervals, total count, total amount, and average values. Use to monitor sales performance.",
211
+ readOnly: true,
212
212
  inputSchema: AnalyticsTransactionsInputSchema,
213
213
  handler: analyticsTransactions,
214
214
  },
215
215
  {
216
- name: "openloyalty_analytics_referrals",
216
+ name: "ol_analytics_referrals",
217
+ title: "Get Referral Analytics",
217
218
  description: "Get referral program analytics showing referral activity. Returns total referral count. Use to monitor referral program performance.",
219
+ readOnly: true,
218
220
  inputSchema: AnalyticsReferralsInputSchema,
219
221
  handler: analyticsReferrals,
220
222
  },
221
223
  {
222
- name: "openloyalty_analytics_campaigns",
224
+ name: "ol_analytics_campaigns",
225
+ title: "Get Campaign Analytics",
223
226
  description: "Get campaign analytics showing execution counts per campaign. Returns list of campaigns with their execution counts. Use to identify most successful campaigns.",
227
+ readOnly: true,
224
228
  inputSchema: AnalyticsCampaignsInputSchema,
225
229
  handler: analyticsCampaigns,
226
230
  },
227
231
  {
228
- name: "openloyalty_analytics_dashboard",
232
+ name: "ol_analytics_dashboard",
233
+ title: "Get Dashboard Overview",
229
234
  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.",
235
+ readOnly: true,
230
236
  inputSchema: AnalyticsDashboardInputSchema,
231
237
  handler: analyticsDashboard,
232
238
  },
233
239
  {
234
- name: "openloyalty_analytics_units",
240
+ name: "ol_analytics_units",
241
+ title: "Get Units Overview",
235
242
  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.",
243
+ readOnly: true,
236
244
  inputSchema: AnalyticsUnitsInputSchema,
237
245
  handler: analyticsUnits,
238
246
  },
239
247
  {
240
- name: "openloyalty_analytics_campaign_detail",
248
+ name: "ol_analytics_campaign_detail",
249
+ title: "Get Campaign Detail Analytics",
241
250
  description: "Get detailed analytics for a specific campaign. Returns campaign-specific performance metrics. Use after analytics_campaigns to drill into individual campaign performance.",
251
+ readOnly: true,
242
252
  inputSchema: AnalyticsCampaignDetailInputSchema,
243
253
  handler: analyticsCampaignDetail,
244
254
  },
@@ -44,8 +44,10 @@ export declare function apiKeyDelete(input: {
44
44
  apiKeyId: string;
45
45
  }): Promise<void>;
46
46
  export declare const apiKeyToolDefinitions: readonly [{
47
- readonly name: "openloyalty_apikey_create";
47
+ readonly name: "ol_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>;
@@ -53,8 +55,10 @@ export declare const apiKeyToolDefinitions: readonly [{
53
55
  };
54
56
  readonly handler: typeof apiKeyCreate;
55
57
  }, {
56
- readonly name: "openloyalty_apikey_list";
58
+ readonly name: "ol_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>;
@@ -62,8 +66,11 @@ export declare const apiKeyToolDefinitions: readonly [{
62
66
  };
63
67
  readonly handler: typeof apiKeyList;
64
68
  }, {
65
- readonly name: "openloyalty_apikey_delete";
69
+ readonly name: "ol_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;
@@ -28,7 +28,7 @@ export async function apiKeyCreate(input) {
28
28
  return response;
29
29
  }
30
30
  catch (error) {
31
- throw formatApiError(error, "openloyalty_apikey_create");
31
+ throw formatApiError(error, "ol_apikey_create");
32
32
  }
33
33
  }
34
34
  export async function apiKeyList(input) {
@@ -44,7 +44,7 @@ export async function apiKeyList(input) {
44
44
  return response;
45
45
  }
46
46
  catch (error) {
47
- throw formatApiError(error, "openloyalty_apikey_list");
47
+ throw formatApiError(error, "ol_apikey_list");
48
48
  }
49
49
  }
50
50
  export async function apiKeyDelete(input) {
@@ -52,26 +52,33 @@ export async function apiKeyDelete(input) {
52
52
  await apiDelete(`/admin/${input.adminId}/api-key/${input.apiKeyId}`);
53
53
  }
54
54
  catch (error) {
55
- throw formatApiError(error, "openloyalty_apikey_delete");
55
+ throw formatApiError(error, "ol_apikey_delete");
56
56
  }
57
57
  }
58
58
  // Tool definitions
59
59
  export const apiKeyToolDefinitions = [
60
60
  {
61
- name: "openloyalty_apikey_create",
61
+ name: "ol_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
- name: "openloyalty_apikey_list",
69
+ name: "ol_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
- name: "openloyalty_apikey_delete",
77
+ name: "ol_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
  },
@@ -80,8 +80,10 @@ export declare function auditExport(input: {
80
80
  exportId: string;
81
81
  }>;
82
82
  export declare const auditToolDefinitions: readonly [{
83
- readonly name: "openloyalty_audit_list";
83
+ readonly name: "ol_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>;
@@ -95,8 +97,10 @@ export declare const auditToolDefinitions: readonly [{
95
97
  };
96
98
  readonly handler: typeof auditList;
97
99
  }, {
98
- readonly name: "openloyalty_audit_export";
100
+ readonly name: "ol_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>;
@@ -47,7 +47,7 @@ export async function auditList(input) {
47
47
  return response;
48
48
  }
49
49
  catch (error) {
50
- throw formatApiError(error, "openloyalty_audit_list");
50
+ throw formatApiError(error, "ol_audit_list");
51
51
  }
52
52
  }
53
53
  export async function auditExport(input) {
@@ -70,20 +70,24 @@ export async function auditExport(input) {
70
70
  return response;
71
71
  }
72
72
  catch (error) {
73
- throw formatApiError(error, "openloyalty_audit_export");
73
+ throw formatApiError(error, "ol_audit_export");
74
74
  }
75
75
  }
76
76
  // Tool definitions
77
77
  export const auditToolDefinitions = [
78
78
  {
79
- name: "openloyalty_audit_list",
79
+ name: "ol_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
- name: "openloyalty_audit_export",
87
+ name: "ol_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
  },
@@ -14,7 +14,7 @@ export declare const BadgeGetInputSchema: {
14
14
  export declare const BadgeUpdateInputSchema: {
15
15
  storeCode: z.ZodOptional<z.ZodString>;
16
16
  badgeTypeId: z.ZodString;
17
- name: z.ZodOptional<z.ZodString>;
17
+ name: z.ZodString;
18
18
  translations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
19
19
  name: z.ZodString;
20
20
  description: z.ZodOptional<z.ZodString>;
@@ -80,8 +80,10 @@ export declare function badgeGetMemberBadges(input: {
80
80
  };
81
81
  }>;
82
82
  export declare const badgeToolDefinitions: readonly [{
83
- readonly name: "openloyalty_badge_list";
83
+ readonly name: "ol_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>;
@@ -91,20 +93,24 @@ export declare const badgeToolDefinitions: readonly [{
91
93
  };
92
94
  readonly handler: typeof badgeList;
93
95
  }, {
94
- readonly name: "openloyalty_badge_get";
96
+ readonly name: "ol_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;
99
103
  };
100
104
  readonly handler: typeof badgeGet;
101
105
  }, {
102
- readonly name: "openloyalty_badge_update";
106
+ readonly name: "ol_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;
107
- name: z.ZodOptional<z.ZodString>;
113
+ name: z.ZodString;
108
114
  translations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
109
115
  name: z.ZodString;
110
116
  description: z.ZodOptional<z.ZodString>;
@@ -120,8 +126,10 @@ export declare const badgeToolDefinitions: readonly [{
120
126
  };
121
127
  readonly handler: typeof badgeUpdate;
122
128
  }, {
123
- readonly name: "openloyalty_badge_get_member_badges";
129
+ readonly name: "ol_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;
@@ -1,32 +1,32 @@
1
1
  import { z } from "zod";
2
2
  import { apiGet, apiPut } 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 BadgeListInputSchema = {
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
  page: z.number().optional().describe("Page number (default: 1)."),
9
9
  perPage: z.number().optional().describe("Items per page (default: 10)."),
10
10
  name: z.string().optional().describe("Filter by badge name."),
11
11
  badgeTypeId: z.string().optional().describe("Filter by specific badge type ID."),
12
12
  };
13
13
  export const BadgeGetInputSchema = {
14
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
14
+ 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."),
15
15
  badgeTypeId: z.string().describe("The badge type ID (UUID) to retrieve."),
16
16
  };
17
17
  export const BadgeUpdateInputSchema = {
18
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
18
+ 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."),
19
19
  badgeTypeId: z.string().describe("The badge type ID (UUID) to update."),
20
- name: z.string().optional().describe("Badge name."),
20
+ name: z.string().describe("Badge name (REQUIRED). API requires name as a direct field."),
21
21
  translations: z.record(z.string(), z.object({
22
22
  name: z.string(),
23
23
  description: z.string().optional(),
24
- })).optional().describe("Badge translations."),
24
+ })).optional().describe("Badge translations (for convenience - will extract name from translations.en.name if name not provided directly)."),
25
25
  imageUrl: z.string().optional().describe("URL to badge image."),
26
26
  active: z.boolean().optional().describe("Whether badge type is active."),
27
27
  };
28
28
  export const BadgeGetMemberBadgesInputSchema = {
29
- storeCode: z.string().optional().describe("Store code. If not provided, uses the default store code from configuration."),
29
+ 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."),
30
30
  memberId: z.string().describe("The member ID (UUID)."),
31
31
  page: z.number().optional().describe("Page number (default: 1)."),
32
32
  perPage: z.number().optional().describe("Items per page (default: 10)."),
@@ -35,8 +35,7 @@ export const BadgeGetMemberBadgesInputSchema = {
35
35
  };
36
36
  // Handler functions
37
37
  export async function badgeList(input) {
38
- const config = getConfig();
39
- const storeCode = input.storeCode || config.defaultStoreCode;
38
+ const storeCode = getStoreCode(input.storeCode);
40
39
  const params = new URLSearchParams();
41
40
  if (input.page)
42
41
  params.append("_page", String(input.page));
@@ -66,28 +65,31 @@ export async function badgeList(input) {
66
65
  };
67
66
  }
68
67
  catch (error) {
69
- throw formatApiError(error, "openloyalty_badge_list");
68
+ throw formatApiError(error, "ol_badge_list");
70
69
  }
71
70
  }
72
71
  export async function badgeGet(input) {
73
- const config = getConfig();
74
- const storeCode = input.storeCode || config.defaultStoreCode;
72
+ const storeCode = getStoreCode(input.storeCode);
75
73
  try {
76
74
  const response = await apiGet(`/${storeCode}/badge-type/${input.badgeTypeId}`);
77
75
  return response;
78
76
  }
79
77
  catch (error) {
80
- throw formatApiError(error, "openloyalty_badge_get");
78
+ throw formatApiError(error, "ol_badge_get");
81
79
  }
82
80
  }
83
81
  export async function badgeUpdate(input) {
84
- const config = getConfig();
85
- const storeCode = input.storeCode || config.defaultStoreCode;
82
+ const storeCode = getStoreCode(input.storeCode);
86
83
  const badgePayload = {};
87
- if (input.name !== undefined)
88
- badgePayload.name = input.name;
89
- if (input.translations)
90
- badgePayload.translations = input.translations;
84
+ // API requires name as direct field, not nested in translations
85
+ // Extract from translations.en.name if name not provided directly
86
+ let badgeName = input.name;
87
+ if (!badgeName && input.translations?.en?.name) {
88
+ badgeName = input.translations.en.name;
89
+ }
90
+ if (badgeName !== undefined)
91
+ badgePayload.name = badgeName;
92
+ // Note: API does not accept nested translations - only direct fields
91
93
  if (input.imageUrl !== undefined)
92
94
  badgePayload.imageUrl = input.imageUrl;
93
95
  if (input.active !== undefined)
@@ -97,12 +99,11 @@ export async function badgeUpdate(input) {
97
99
  await apiPut(`/${storeCode}/badge-type/${input.badgeTypeId}`, { badgeType: badgePayload });
98
100
  }
99
101
  catch (error) {
100
- throw formatApiError(error, "openloyalty_badge_update");
102
+ throw formatApiError(error, "ol_badge_update");
101
103
  }
102
104
  }
103
105
  export async function badgeGetMemberBadges(input) {
104
- const config = getConfig();
105
- const storeCode = input.storeCode || config.defaultStoreCode;
106
+ const storeCode = getStoreCode(input.storeCode);
106
107
  const params = new URLSearchParams();
107
108
  if (input.page)
108
109
  params.append("_page", String(input.page));
@@ -133,32 +134,40 @@ export async function badgeGetMemberBadges(input) {
133
134
  };
134
135
  }
135
136
  catch (error) {
136
- throw formatApiError(error, "openloyalty_badge_get_member_badges");
137
+ throw formatApiError(error, "ol_badge_get_member_badges");
137
138
  }
138
139
  }
139
140
  // Tool definitions
140
141
  export const badgeToolDefinitions = [
141
142
  {
142
- name: "openloyalty_badge_list",
143
+ name: "ol_badge_list",
144
+ title: "List Badges",
143
145
  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.",
146
+ readOnly: true,
144
147
  inputSchema: BadgeListInputSchema,
145
148
  handler: badgeList,
146
149
  },
147
150
  {
148
- name: "openloyalty_badge_get",
151
+ name: "ol_badge_get",
152
+ title: "Get Badge Details",
149
153
  description: "Get badge type details including name, image URL, and linked achievements count.",
154
+ readOnly: true,
150
155
  inputSchema: BadgeGetInputSchema,
151
156
  handler: badgeGet,
152
157
  },
153
158
  {
154
- name: "openloyalty_badge_update",
159
+ name: "ol_badge_update",
160
+ title: "Update Badge",
155
161
  description: "Update badge type configuration. Badge types are created automatically when referenced by achievements. Use this to update name, image, or translations.",
162
+ readOnly: false,
156
163
  inputSchema: BadgeUpdateInputSchema,
157
164
  handler: badgeUpdate,
158
165
  },
159
166
  {
160
- name: "openloyalty_badge_get_member_badges",
167
+ name: "ol_badge_get_member_badges",
168
+ title: "Get Member Badges",
161
169
  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.",
170
+ readOnly: true,
162
171
  inputSchema: BadgeGetMemberBadgesInputSchema,
163
172
  handler: badgeGetMemberBadges,
164
173
  },