epicmerch-mcp 1.0.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.
@@ -0,0 +1,352 @@
1
+ // src/tools/_examples.js
2
+ //
3
+ // Sample prompts seeded into each MCP tool's `description` at registration time.
4
+ // This is how Claude/ChatGPT learn which prompts should auto-route to which tool.
5
+ //
6
+ // Add a new entry whenever a new merchant_* tool is added.
7
+
8
+ export const TOOL_EXAMPLES = {
9
+ // --- Setup & diagnosis ---
10
+ merchant_quick_setup: [
11
+ 'Set up an EpicMerch store for me',
12
+ 'I want to start selling online',
13
+ 'Create a store and import from Shopify',
14
+ ],
15
+ merchant_diagnose: [
16
+ 'Is my store ready to launch?',
17
+ "What's still missing from my setup?",
18
+ 'Check my store health',
19
+ ],
20
+
21
+ // --- Products ---
22
+ merchant_list_products: [
23
+ 'Show me my products',
24
+ 'List products in the Apparel category',
25
+ 'How many products do I have?',
26
+ ],
27
+ merchant_get_product: [
28
+ 'Show me product details for Blue Tee',
29
+ 'Get product 123',
30
+ ],
31
+ merchant_create_product: [
32
+ 'Add a new product called Blue Tee for $25',
33
+ 'Create a product',
34
+ ],
35
+ merchant_update_product: [
36
+ 'Change the price of Blue Tee to $30',
37
+ 'Update product stock',
38
+ ],
39
+ merchant_delete_product: [
40
+ 'Delete the product called Old Tee',
41
+ 'Remove product 456',
42
+ ],
43
+ merchant_generate_product_description: [
44
+ 'Generate a description for my new hoodie',
45
+ 'Write product copy for the Red Hoodie',
46
+ ],
47
+ merchant_get_product_recommendations: [
48
+ 'Recommend related products',
49
+ 'What products should I show together?',
50
+ ],
51
+
52
+ // --- Categories ---
53
+ merchant_list_categories: [
54
+ 'Show me my product categories',
55
+ 'List all categories',
56
+ ],
57
+ merchant_create_category: [
58
+ 'Create a category called Winter Collection',
59
+ 'Add a new category',
60
+ ],
61
+ merchant_update_category: [
62
+ 'Rename my Winter category',
63
+ 'Update category visibility',
64
+ ],
65
+ merchant_delete_category: [
66
+ 'Delete the Winter category',
67
+ 'Remove category 789',
68
+ ],
69
+ merchant_toggle_category_visibility: [
70
+ 'Hide the Sale category',
71
+ 'Make the Featured category visible',
72
+ ],
73
+
74
+ // --- Orders ---
75
+ merchant_list_orders: [
76
+ 'Show recent orders',
77
+ 'Which orders are pending?',
78
+ 'List shipped orders',
79
+ ],
80
+ merchant_get_order: [
81
+ 'Show me order #123',
82
+ 'Get details for order ord_abc',
83
+ ],
84
+ merchant_update_order_status: [
85
+ 'Mark order #123 as shipped',
86
+ 'Cancel order #456',
87
+ ],
88
+ merchant_update_payment_status: [
89
+ 'Mark order #123 as paid',
90
+ 'Set order payment to unpaid',
91
+ ],
92
+
93
+ // --- Customers ---
94
+ merchant_list_customers: [
95
+ 'Show me my customers',
96
+ 'List all users',
97
+ ],
98
+ merchant_get_customer: [
99
+ 'Show me customer details for John',
100
+ 'Get customer 456',
101
+ ],
102
+ merchant_delete_customer: [
103
+ 'Delete customer 456',
104
+ 'Remove a user account',
105
+ ],
106
+
107
+ // --- Analytics ---
108
+ merchant_get_analytics_stats: [
109
+ 'How are my sales this week?',
110
+ "What's my revenue today?",
111
+ 'Show me overall store stats',
112
+ ],
113
+ merchant_get_sales_trend: [
114
+ 'How are sales trending over the last month?',
115
+ 'Show the sales chart',
116
+ ],
117
+ merchant_get_top_products: [
118
+ 'What are my best-selling products?',
119
+ 'Top products this month',
120
+ ],
121
+ merchant_get_traffic: [
122
+ 'How much storefront traffic did I get?',
123
+ 'Show me visitor stats',
124
+ ],
125
+ merchant_get_revenue_by_category: [
126
+ 'Which category makes me the most money?',
127
+ 'Revenue breakdown by category',
128
+ ],
129
+ merchant_get_cart_abandonment: [
130
+ "What's my cart abandonment rate?",
131
+ 'How many carts were abandoned?',
132
+ ],
133
+ merchant_get_order_status_distribution: [
134
+ 'How are my orders distributed by status?',
135
+ 'Order status breakdown',
136
+ ],
137
+ merchant_get_peak_hours: [
138
+ 'When do I get the most orders?',
139
+ 'Peak shopping hours',
140
+ ],
141
+ merchant_get_geographic_distribution: [
142
+ 'Where are my customers from?',
143
+ 'Show me orders by region',
144
+ ],
145
+ merchant_get_period_comparison: [
146
+ 'How does this month compare to last month?',
147
+ 'Compare current vs previous period',
148
+ ],
149
+ merchant_get_ai_insights: [
150
+ 'Give me AI insights on my store',
151
+ "What's the AI noticing about my sales?",
152
+ ],
153
+
154
+ // --- Notifications ---
155
+ merchant_list_subscribers: [
156
+ 'Show my newsletter subscribers',
157
+ 'How many people subscribe?',
158
+ ],
159
+ merchant_send_notification: [
160
+ 'Send a promo email to my customers',
161
+ 'Send a notification',
162
+ ],
163
+ merchant_get_abandoned_carts: [
164
+ 'Show me abandoned carts from the last 24 hours',
165
+ 'Who has abandoned a cart?',
166
+ ],
167
+ merchant_send_to_user: [
168
+ 'Send a notification to customer 456',
169
+ 'Message a specific user',
170
+ ],
171
+ merchant_get_notification_history: [
172
+ 'Show my notification history',
173
+ 'What notifications did I send?',
174
+ ],
175
+ merchant_get_notification_stats: [
176
+ 'How are my notifications performing?',
177
+ 'Notification open rates',
178
+ ],
179
+
180
+ // --- Settings ---
181
+ merchant_get_settings: [
182
+ 'Show me my store settings',
183
+ 'What are my current settings?',
184
+ ],
185
+ merchant_update_currency: [
186
+ 'Change my store currency to USD',
187
+ 'Set currency to EUR',
188
+ ],
189
+ merchant_get_checkout_settings: [
190
+ 'Show me my checkout configuration',
191
+ 'Is my payment configured?',
192
+ ],
193
+ merchant_update_checkout_settings: [
194
+ 'Update my Razorpay keys',
195
+ 'Change my checkout type',
196
+ ],
197
+ merchant_get_email_settings: [
198
+ 'Show me my email settings',
199
+ 'How is email configured?',
200
+ ],
201
+ merchant_update_email_settings: [
202
+ 'Update my SMTP settings',
203
+ 'Change email sender address',
204
+ ],
205
+ merchant_get_logistics_settings: [
206
+ 'Show my shipping configuration',
207
+ 'Is Shiprocket connected?',
208
+ ],
209
+ merchant_update_logistics_settings: [
210
+ 'Update my Shiprocket credentials',
211
+ 'Change logistics settings',
212
+ ],
213
+ merchant_get_security_settings: [
214
+ 'Show my security settings',
215
+ 'What domains are allowed?',
216
+ ],
217
+ merchant_add_allowed_domain: [
218
+ 'Allow mystore.com to access my API',
219
+ 'Add a CORS domain',
220
+ ],
221
+ merchant_remove_allowed_domain: [
222
+ 'Remove olddomain.com from allowed list',
223
+ 'Block a domain',
224
+ ],
225
+
226
+ // --- API Keys ---
227
+ merchant_list_api_keys: [
228
+ 'Show me my API keys',
229
+ 'List my API keys',
230
+ ],
231
+ merchant_generate_api_key: [
232
+ 'Generate a new API key called Mobile App',
233
+ 'Create an API key',
234
+ ],
235
+ merchant_delete_api_key: [
236
+ 'Revoke the Mobile App API key',
237
+ 'Delete API key abc123',
238
+ ],
239
+
240
+ // --- Storefront generation ---
241
+ merchant_list_storefront_templates: [
242
+ 'Show me storefront templates',
243
+ 'What storefront designs are available?',
244
+ ],
245
+ merchant_generate_storefront_from_prompt: [
246
+ 'Build me a storefront for a streetwear brand',
247
+ 'Generate a storefront from this prompt',
248
+ ],
249
+ merchant_get_deploy_options: [
250
+ 'How can I deploy my storefront?',
251
+ 'Show deployment options',
252
+ ],
253
+
254
+ // --- GitHub ---
255
+ merchant_get_github_status: [
256
+ 'Is GitHub connected?',
257
+ 'Show my GitHub status',
258
+ ],
259
+ merchant_list_github_repos: [
260
+ 'List my GitHub repositories',
261
+ 'Show my connected repos',
262
+ ],
263
+ merchant_push_to_github: [
264
+ 'Push my storefront to GitHub',
265
+ 'Deploy code to my repo',
266
+ ],
267
+
268
+ // --- Logistics ---
269
+ merchant_get_shipping_rates: [
270
+ 'What are shipping rates for an order?',
271
+ 'Calculate shipping cost',
272
+ ],
273
+ merchant_create_shipment: [
274
+ 'Create a shipment for order 123',
275
+ 'Ship this order',
276
+ ],
277
+ merchant_track_shipment: [
278
+ 'Track shipment ABC123',
279
+ "Where's my package?",
280
+ ],
281
+
282
+ // --- Finance ---
283
+ merchant_get_consolidation_report: [
284
+ 'Show my financial consolidation',
285
+ 'Get the reconciliation report',
286
+ ],
287
+
288
+ // --- Shiprocket ---
289
+ merchant_list_sr_orders: [
290
+ 'Show Shiprocket orders',
291
+ 'List SR Checkout orders',
292
+ ],
293
+ merchant_initiate_refund: [
294
+ 'Refund order 123 for $50',
295
+ 'Initiate a Shiprocket refund',
296
+ ],
297
+ merchant_sync_product_to_sr: [
298
+ 'Sync product 789 to Shiprocket',
299
+ 'Push a product to SR catalog',
300
+ ],
301
+
302
+ // --- Shopify migration ---
303
+ merchant_shopify_migrate: [
304
+ 'Migrate my Shopify store',
305
+ 'Import products from mystore.myshopify.com',
306
+ 'Move my Shopify catalog to EpicMerch',
307
+ ],
308
+
309
+ // --- Stripe ---
310
+ merchant_configure_stripe: [
311
+ 'Set up Stripe for my store',
312
+ 'Configure my Stripe payment keys',
313
+ 'Add Stripe to my EpicMerch store',
314
+ ],
315
+ merchant_test_stripe_connection: [
316
+ 'Test my Stripe connection',
317
+ 'Is Stripe configured correctly?',
318
+ 'Verify my Stripe keys work',
319
+ ],
320
+ merchant_set_checkout_type: [
321
+ 'Switch my checkout to Stripe',
322
+ 'Change checkout to Razorpay',
323
+ 'Use Shiprocket Checkout',
324
+ ],
325
+ };
326
+
327
+ /**
328
+ * Returns a new array of tool definitions with example prompts appended to each
329
+ * description (when the tool name has an entry in TOOL_EXAMPLES).
330
+ *
331
+ * Does not mutate the input. Tools without an entry pass through unchanged.
332
+ * A malformed entry (non-array) is silently skipped — the tool registers with
333
+ * its base description so a typo in TOOL_EXAMPLES can never break server startup.
334
+ *
335
+ * @param {Array<{name: string, description: string, schema: object}>} defs
336
+ * @returns {Array<{name: string, description: string, schema: object}>}
337
+ */
338
+ export function withExamples(defs) {
339
+ return defs.map((def) => {
340
+ const examples = TOOL_EXAMPLES[def.name];
341
+ if (!Array.isArray(examples) || examples.length === 0) return { ...def };
342
+
343
+ const block = [
344
+ '',
345
+ '',
346
+ 'Example prompts that should trigger this tool:',
347
+ ...examples.map((e) => `- "${e}"`),
348
+ ].join('\n');
349
+
350
+ return { ...def, description: (def.description ?? '') + block };
351
+ });
352
+ }
@@ -0,0 +1,65 @@
1
+ // src/tools/developer.js
2
+ import { readFileSync } from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+
6
+ const __dir = dirname(fileURLToPath(import.meta.url));
7
+ const readExample = (name) =>
8
+ readFileSync(join(__dir, '../resources/examples', `${name}.md`), 'utf-8');
9
+
10
+ export function developerTools(client) {
11
+ return {
12
+ async store_get_config(_args) {
13
+ const data = await client.get('/customer/config');
14
+ return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
15
+ },
16
+
17
+ async store_list_products({ category, keyword, sort, page, limit } = {}) {
18
+ const p = new URLSearchParams();
19
+ if (category) p.set('type', category);
20
+ if (keyword) p.set('keyword', keyword);
21
+ if (sort) p.set('sort', sort);
22
+ if (page) p.set('page', page);
23
+ if (limit) p.set('limit', limit);
24
+ const qs = p.toString();
25
+ const data = await client.get(`/products/public${qs ? `?${qs}` : ''}`);
26
+ return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
27
+ },
28
+
29
+ async store_get_product({ id }) {
30
+ const data = await client.get(`/products/public/${id}`);
31
+ return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
32
+ },
33
+
34
+ async store_search_products({ query, category, page, limit } = {}) {
35
+ const p = new URLSearchParams({ keyword: query });
36
+ if (category) p.set('type', category);
37
+ if (page) p.set('page', page);
38
+ if (limit) p.set('limit', limit);
39
+ const data = await client.get(`/products/public?${p.toString()}`);
40
+ return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
41
+ },
42
+
43
+ async store_list_categories(_args) {
44
+ const data = await client.get('/categories/visible');
45
+ return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
46
+ },
47
+
48
+ async store_get_integration_guide({ module }) {
49
+ const valid = ['auth', 'products', 'orders', 'payments'];
50
+ if (!valid.includes(module)) {
51
+ return { isError: true, content: [{ type: 'text', text: `module must be one of: ${valid.join(', ')}` }] };
52
+ }
53
+ return { content: [{ type: 'text', text: readExample(module) }] };
54
+ },
55
+ };
56
+ }
57
+
58
+ export const developerToolDefs = [
59
+ { name: 'store_get_config', description: 'Fetch the active store config (merchant name, currency, checkout type).', schema: {} },
60
+ { name: 'store_list_products', description: 'List products from the active store.', schema: { category: { type: 'string' }, keyword: { type: 'string' }, sort: { type: 'string' }, page: { type: 'number' }, limit: { type: 'number' } } },
61
+ { name: 'store_get_product', description: 'Get a single product by ID.', schema: { id: { type: 'string' } } },
62
+ { name: 'store_search_products', description: 'Search products by keyword.', schema: { query: { type: 'string' }, category: { type: 'string' }, page: { type: 'number' }, limit: { type: 'number' } } },
63
+ { name: 'store_list_categories', description: 'List all visible product categories.', schema: {} },
64
+ { name: 'store_get_integration_guide', description: 'Get code examples for integrating a specific EpicMerch module. module: auth | products | orders | payments', schema: { module: { type: 'string' } } },
65
+ ];