@messegy/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.
Files changed (77) hide show
  1. package/README.md +133 -0
  2. package/api/index.js +3 -0
  3. package/dist/api-client.d.ts +10 -0
  4. package/dist/api-client.js +100 -0
  5. package/dist/api-client.js.map +1 -0
  6. package/dist/cli-setup.d.ts +1 -0
  7. package/dist/cli-setup.js +74 -0
  8. package/dist/cli-setup.js.map +1 -0
  9. package/dist/config.d.ts +18 -0
  10. package/dist/config.js +88 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +56 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/lib/quota-guard.d.ts +19 -0
  16. package/dist/lib/quota-guard.js +101 -0
  17. package/dist/lib/quota-guard.js.map +1 -0
  18. package/dist/resources/index.d.ts +2 -0
  19. package/dist/resources/index.js +62 -0
  20. package/dist/resources/index.js.map +1 -0
  21. package/dist/server.d.ts +10 -0
  22. package/dist/server.js +364 -0
  23. package/dist/server.js.map +1 -0
  24. package/dist/tools/analytics.d.ts +2 -0
  25. package/dist/tools/analytics.js +42 -0
  26. package/dist/tools/analytics.js.map +1 -0
  27. package/dist/tools/auth.d.ts +2 -0
  28. package/dist/tools/auth.js +113 -0
  29. package/dist/tools/auth.js.map +1 -0
  30. package/dist/tools/auto-replies.d.ts +2 -0
  31. package/dist/tools/auto-replies.js +117 -0
  32. package/dist/tools/auto-replies.js.map +1 -0
  33. package/dist/tools/broadcasts.d.ts +2 -0
  34. package/dist/tools/broadcasts.js +58 -0
  35. package/dist/tools/broadcasts.js.map +1 -0
  36. package/dist/tools/chats.d.ts +2 -0
  37. package/dist/tools/chats.js +77 -0
  38. package/dist/tools/chats.js.map +1 -0
  39. package/dist/tools/contacts.d.ts +2 -0
  40. package/dist/tools/contacts.js +79 -0
  41. package/dist/tools/contacts.js.map +1 -0
  42. package/dist/tools/flows.d.ts +2 -0
  43. package/dist/tools/flows.js +148 -0
  44. package/dist/tools/flows.js.map +1 -0
  45. package/dist/tools/messages.d.ts +2 -0
  46. package/dist/tools/messages.js +149 -0
  47. package/dist/tools/messages.js.map +1 -0
  48. package/dist/tools/shopify.d.ts +2 -0
  49. package/dist/tools/shopify.js +66 -0
  50. package/dist/tools/shopify.js.map +1 -0
  51. package/dist/tools/templates.d.ts +2 -0
  52. package/dist/tools/templates.js +160 -0
  53. package/dist/tools/templates.js.map +1 -0
  54. package/dist/web-app.d.ts +1 -0
  55. package/dist/web-app.js +845 -0
  56. package/dist/web-app.js.map +1 -0
  57. package/package.json +42 -0
  58. package/src/api-client.ts +112 -0
  59. package/src/cli-setup.ts +87 -0
  60. package/src/config.ts +111 -0
  61. package/src/index.ts +66 -0
  62. package/src/lib/quota-guard.ts +138 -0
  63. package/src/resources/index.ts +70 -0
  64. package/src/server.ts +408 -0
  65. package/src/tools/analytics.ts +58 -0
  66. package/src/tools/auth.ts +136 -0
  67. package/src/tools/auto-replies.ts +144 -0
  68. package/src/tools/broadcasts.ts +73 -0
  69. package/src/tools/chats.ts +100 -0
  70. package/src/tools/contacts.ts +99 -0
  71. package/src/tools/flows.ts +192 -0
  72. package/src/tools/messages.ts +177 -0
  73. package/src/tools/shopify.ts +80 -0
  74. package/src/tools/templates.ts +193 -0
  75. package/src/web-app.ts +844 -0
  76. package/tsconfig.json +18 -0
  77. package/vercel.json +10 -0
package/src/web-app.ts ADDED
@@ -0,0 +1,844 @@
1
+ export function getWebAppHtml(): string {
2
+ return `<!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Messegy AI MCP Hub | Cloud-Hosted Model Context Protocol Server</title>
8
+ <link rel="preconnect" href="https://fonts.googleapis.com">
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
11
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
12
+ <style>
13
+ :root {
14
+ --bg-dark: #070D18;
15
+ --card-bg: rgba(15, 23, 42, 0.75);
16
+ --card-border: rgba(30, 41, 59, 0.9);
17
+ --emerald: #10B981;
18
+ --emerald-glow: rgba(16, 185, 129, 0.25);
19
+ --emerald-dark: #059669;
20
+ --text: #F8FAFC;
21
+ --text-muted: #94A3B8;
22
+ --font-main: 'Plus Jakarta Sans', -apple-system, sans-serif;
23
+ --font-mono: 'JetBrains Mono', monospace;
24
+ }
25
+
26
+ * { box-sizing: border-box; margin: 0; padding: 0; }
27
+ body {
28
+ background-color: var(--bg-dark);
29
+ background-image:
30
+ radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
31
+ radial-gradient(circle at 85% 85%, rgba(59, 130, 246, 0.06) 0%, transparent 40%);
32
+ color: var(--text);
33
+ font-family: var(--font-main);
34
+ min-height: 100vh;
35
+ display: flex;
36
+ flex-direction: column;
37
+ }
38
+
39
+ /* Navbar */
40
+ header {
41
+ border-bottom: 1px solid var(--card-border);
42
+ background: rgba(7, 13, 24, 0.85);
43
+ backdrop-filter: blur(12px);
44
+ position: sticky;
45
+ top: 0;
46
+ z-index: 100;
47
+ padding: 16px 28px;
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: space-between;
51
+ }
52
+ .brand {
53
+ display: flex;
54
+ align-items: center;
55
+ gap: 10px;
56
+ text-decoration: none;
57
+ color: #fff;
58
+ }
59
+ .brand-icon {
60
+ width: 38px;
61
+ height: 38px;
62
+ border-radius: 10px;
63
+ background: linear-gradient(135deg, #10B981, #059669);
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+ box-shadow: 0 0 16px var(--emerald-glow);
68
+ }
69
+ .brand-title {
70
+ font-size: 20px;
71
+ font-weight: 800;
72
+ letter-spacing: -0.5px;
73
+ }
74
+ .brand-badge {
75
+ font-size: 11px;
76
+ background: rgba(16, 185, 129, 0.15);
77
+ color: var(--emerald);
78
+ border: 1px solid rgba(16, 185, 129, 0.3);
79
+ padding: 2px 8px;
80
+ border-radius: 6px;
81
+ font-weight: 700;
82
+ }
83
+
84
+ .nav-links {
85
+ display: flex;
86
+ align-items: center;
87
+ gap: 18px;
88
+ }
89
+ .nav-link {
90
+ color: var(--text-muted);
91
+ text-decoration: none;
92
+ font-size: 14px;
93
+ font-weight: 600;
94
+ transition: color 0.2s;
95
+ }
96
+ .nav-link:hover { color: #fff; }
97
+ .btn-portal {
98
+ background: rgba(255, 255, 255, 0.08);
99
+ border: 1px solid rgba(255, 255, 255, 0.15);
100
+ color: #fff;
101
+ padding: 8px 16px;
102
+ border-radius: 8px;
103
+ font-size: 13px;
104
+ font-weight: 600;
105
+ text-decoration: none;
106
+ display: flex;
107
+ align-items: center;
108
+ gap: 6px;
109
+ transition: all 0.2s;
110
+ }
111
+ .btn-portal:hover {
112
+ background: rgba(255, 255, 255, 0.15);
113
+ }
114
+
115
+ /* Main Container */
116
+ main {
117
+ max-width: 1200px;
118
+ margin: 0 auto;
119
+ padding: 40px 24px;
120
+ flex: 1;
121
+ width: 100%;
122
+ }
123
+
124
+ .hero {
125
+ text-align: center;
126
+ max-width: 780px;
127
+ margin: 0 auto 40px auto;
128
+ }
129
+ .hero-pill {
130
+ display: inline-flex;
131
+ align-items: center;
132
+ gap: 6px;
133
+ background: rgba(16, 185, 129, 0.12);
134
+ border: 1px solid rgba(16, 185, 129, 0.3);
135
+ color: var(--emerald);
136
+ font-size: 12px;
137
+ font-weight: 700;
138
+ padding: 4px 12px;
139
+ border-radius: 20px;
140
+ margin-bottom: 18px;
141
+ }
142
+ .hero h1 {
143
+ font-size: 42px;
144
+ font-weight: 800;
145
+ letter-spacing: -1px;
146
+ line-height: 1.2;
147
+ margin-bottom: 16px;
148
+ }
149
+ .gradient-text {
150
+ background: linear-gradient(135deg, #10B981 0%, #38BDF8 100%);
151
+ -webkit-background-clip: text;
152
+ -webkit-text-fill-color: transparent;
153
+ }
154
+ .hero p {
155
+ font-size: 16px;
156
+ color: var(--text-muted);
157
+ line-height: 1.6;
158
+ }
159
+
160
+ /* Grid Layout */
161
+ .dashboard-grid {
162
+ display: grid;
163
+ grid-template-columns: 1fr 1fr;
164
+ gap: 28px;
165
+ margin-bottom: 40px;
166
+ }
167
+ @media (max-width: 900px) {
168
+ .dashboard-grid { grid-template-columns: 1fr; }
169
+ }
170
+
171
+ .card {
172
+ background: var(--card-bg);
173
+ border: 1px solid var(--card-border);
174
+ border-radius: 20px;
175
+ padding: 28px;
176
+ backdrop-filter: blur(16px);
177
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
178
+ }
179
+
180
+ .card-header {
181
+ display: flex;
182
+ align-items: center;
183
+ justify-content: space-between;
184
+ margin-bottom: 20px;
185
+ }
186
+ .card-title {
187
+ font-size: 18px;
188
+ font-weight: 700;
189
+ display: flex;
190
+ align-items: center;
191
+ gap: 10px;
192
+ }
193
+ .card-icon {
194
+ color: var(--emerald);
195
+ }
196
+
197
+ /* Input & Connect Form */
198
+ .input-group {
199
+ margin-bottom: 18px;
200
+ }
201
+ .input-label {
202
+ display: block;
203
+ font-size: 12px;
204
+ font-weight: 700;
205
+ color: var(--text-muted);
206
+ text-transform: uppercase;
207
+ letter-spacing: 0.5px;
208
+ margin-bottom: 8px;
209
+ }
210
+ .input-field {
211
+ width: 100%;
212
+ background: rgba(2, 6, 23, 0.8);
213
+ border: 1px solid rgba(51, 65, 85, 0.8);
214
+ border-radius: 10px;
215
+ padding: 12px 14px;
216
+ font-family: var(--font-mono);
217
+ font-size: 13px;
218
+ color: #fff;
219
+ outline: none;
220
+ transition: all 0.2s;
221
+ }
222
+ .input-field:focus {
223
+ border-color: var(--emerald);
224
+ box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
225
+ }
226
+
227
+ .btn-connect {
228
+ width: 100%;
229
+ background: linear-gradient(135deg, #10B981, #059669);
230
+ color: #fff;
231
+ border: none;
232
+ padding: 12px;
233
+ border-radius: 10px;
234
+ font-weight: 700;
235
+ font-size: 14px;
236
+ cursor: pointer;
237
+ display: flex;
238
+ align-items: center;
239
+ justify-content: center;
240
+ gap: 8px;
241
+ transition: all 0.2s;
242
+ box-shadow: 0 4px 14px var(--emerald-glow);
243
+ }
244
+ .btn-connect:hover {
245
+ transform: translateY(-1px);
246
+ box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
247
+ }
248
+
249
+ /* Live Quota Badge Cards */
250
+ .quota-box {
251
+ margin-top: 20px;
252
+ padding: 18px;
253
+ background: rgba(2, 6, 23, 0.6);
254
+ border: 1px solid rgba(16, 185, 129, 0.25);
255
+ border-radius: 12px;
256
+ display: none;
257
+ }
258
+ .quota-header {
259
+ display: flex;
260
+ align-items: center;
261
+ justify-content: space-between;
262
+ margin-bottom: 12px;
263
+ }
264
+ .quota-grid {
265
+ display: grid;
266
+ grid-template-columns: repeat(3, 1fr);
267
+ gap: 10px;
268
+ text-align: center;
269
+ }
270
+ .quota-item {
271
+ background: rgba(15, 23, 42, 0.8);
272
+ padding: 10px;
273
+ border-radius: 8px;
274
+ border: 1px solid var(--card-border);
275
+ }
276
+ .quota-val {
277
+ font-size: 16px;
278
+ font-weight: 800;
279
+ color: #fff;
280
+ }
281
+ .quota-lbl {
282
+ font-size: 10px;
283
+ color: var(--text-muted);
284
+ text-transform: uppercase;
285
+ margin-top: 4px;
286
+ }
287
+
288
+ /* Code Box */
289
+ .code-box {
290
+ position: relative;
291
+ background: #020617;
292
+ border: 1px solid rgba(51, 65, 85, 0.8);
293
+ border-radius: 12px;
294
+ padding: 16px;
295
+ margin-top: 14px;
296
+ font-family: var(--font-mono);
297
+ font-size: 12px;
298
+ line-height: 1.6;
299
+ color: #38BDF8;
300
+ overflow-x: auto;
301
+ }
302
+ .btn-copy-code {
303
+ position: absolute;
304
+ top: 10px;
305
+ right: 10px;
306
+ background: rgba(255, 255, 255, 0.1);
307
+ border: 1px solid rgba(255, 255, 255, 0.2);
308
+ color: #fff;
309
+ padding: 4px 10px;
310
+ border-radius: 6px;
311
+ font-size: 11px;
312
+ font-weight: 600;
313
+ cursor: pointer;
314
+ display: flex;
315
+ align-items: center;
316
+ gap: 4px;
317
+ transition: background 0.2s;
318
+ }
319
+ .btn-copy-code:hover { background: rgba(255, 255, 255, 0.2); }
320
+
321
+ /* Interactive Live Tool Sandbox */
322
+ .sandbox-chat {
323
+ display: flex;
324
+ flex-direction: column;
325
+ height: 380px;
326
+ }
327
+ .chat-messages {
328
+ flex: 1;
329
+ overflow-y: auto;
330
+ display: flex;
331
+ flex-direction: column;
332
+ gap: 12px;
333
+ padding: 12px 0;
334
+ }
335
+ .chat-msg {
336
+ max-width: 85%;
337
+ padding: 12px 16px;
338
+ border-radius: 14px;
339
+ font-size: 13px;
340
+ line-height: 1.5;
341
+ }
342
+ .chat-msg.user {
343
+ align-self: flex-end;
344
+ background: #10B981;
345
+ color: #fff;
346
+ border-bottom-right-radius: 4px;
347
+ }
348
+ .chat-msg.bot {
349
+ align-self: flex-start;
350
+ background: #1E293B;
351
+ color: var(--text);
352
+ border-bottom-left-radius: 4px;
353
+ border: 1px solid var(--card-border);
354
+ }
355
+ .chat-input-row {
356
+ display: flex;
357
+ gap: 8px;
358
+ padding-top: 12px;
359
+ border-top: 1px solid var(--card-border);
360
+ }
361
+ .chat-input {
362
+ flex: 1;
363
+ background: #020617;
364
+ border: 1px solid var(--card-border);
365
+ border-radius: 10px;
366
+ padding: 10px 14px;
367
+ color: #fff;
368
+ font-size: 13px;
369
+ outline: none;
370
+ }
371
+ .chat-input:focus { border-color: var(--emerald); }
372
+ .btn-send {
373
+ background: var(--emerald);
374
+ color: #fff;
375
+ border: none;
376
+ border-radius: 10px;
377
+ padding: 0 16px;
378
+ cursor: pointer;
379
+ font-weight: 700;
380
+ }
381
+
382
+ /* Tools Explorer Tabs */
383
+ .tools-section {
384
+ margin-top: 40px;
385
+ }
386
+ .section-title {
387
+ font-size: 24px;
388
+ font-weight: 800;
389
+ margin-bottom: 20px;
390
+ display: flex;
391
+ align-items: center;
392
+ gap: 10px;
393
+ }
394
+ .tools-grid {
395
+ display: grid;
396
+ grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
397
+ gap: 16px;
398
+ }
399
+ .tool-card {
400
+ background: var(--card-bg);
401
+ border: 1px solid var(--card-border);
402
+ border-radius: 14px;
403
+ padding: 18px;
404
+ transition: all 0.2s;
405
+ }
406
+ .tool-card:hover {
407
+ border-color: var(--emerald);
408
+ transform: translateY(-2px);
409
+ }
410
+ .tool-name {
411
+ font-family: var(--font-mono);
412
+ font-size: 13px;
413
+ font-weight: 700;
414
+ color: #38BDF8;
415
+ margin-bottom: 6px;
416
+ }
417
+ .tool-desc {
418
+ font-size: 12px;
419
+ color: var(--text-muted);
420
+ line-height: 1.5;
421
+ }
422
+
423
+ footer {
424
+ border-top: 1px solid var(--card-border);
425
+ padding: 24px;
426
+ text-align: center;
427
+ font-size: 13px;
428
+ color: var(--text-muted);
429
+ }
430
+ </style>
431
+ </head>
432
+ <body>
433
+
434
+ <!-- Navbar -->
435
+ <header>
436
+ <a href="/" class="brand">
437
+ <div class="brand-icon">
438
+ <i class="fa-solid fa-brain" style="color:#fff; font-size:18px;"></i>
439
+ </div>
440
+ <span class="brand-title">Messegy <span class="gradient-text">MCP Hub</span></span>
441
+ <span class="brand-badge">Cloud SSE v1.0</span>
442
+ </a>
443
+
444
+ <div class="nav-links">
445
+ <a href="https://docs.messegy.com?page=mcp-server" class="nav-link" target="_blank"><i class="fa-solid fa-book"></i> Documentation</a>
446
+ <a href="https://app.messegy.com" class="btn-portal" target="_blank"><i class="fa-solid fa-arrow-up-right-from-square"></i> Web Portal</a>
447
+ </div>
448
+ </header>
449
+
450
+ <!-- Main Content -->
451
+ <main>
452
+
453
+ <!-- Hero Banner -->
454
+ <div class="hero">
455
+ <div class="hero-pill"><i class="fa-solid fa-bolt"></i> Remote Model Context Protocol (MCP) Cloud Engine</div>
456
+ <h1>Connect Claude & AI to WhatsApp <span class="gradient-text">In 1 Click</span></h1>
457
+ <p>Control your WhatsApp Business API directly inside Claude Desktop, Cursor IDE, Windsurf, or custom AI Agents. Zero setup, real-time SSE streaming, and built-in Plan Quota Guard.</p>
458
+ </div>
459
+
460
+ <!-- Dashboard Grid -->
461
+ <div class="dashboard-grid">
462
+
463
+ <!-- Card 1: 1-Click Connect & Config Generator -->
464
+ <div class="card">
465
+ <div class="card-header">
466
+ <div class="card-title">
467
+ <i class="fa-solid fa-key card-icon"></i>
468
+ <span>1-Click Cloud Connection</span>
469
+ </div>
470
+ <span class="brand-badge" id="conn-badge">READY</span>
471
+ </div>
472
+
473
+ <div class="input-group">
474
+ <label class="input-label">Messegy API Key</label>
475
+ <input type="password" id="apiKeyInput" class="input-field" placeholder="msg_live_... (from Settings -> API Keys)">
476
+ </div>
477
+
478
+ <div class="input-group">
479
+ <label class="input-label">Project / Workspace Key (Optional)</label>
480
+ <input type="text" id="projectKeyInput" class="input-field" placeholder="proj_... (optional)">
481
+ </div>
482
+
483
+ <button class="btn-connect" onclick="verifyAndGenerate()">
484
+ <i class="fa-solid fa-link"></i> Verify API Key & Unlock 1-Click Setup
485
+ </button>
486
+
487
+ <!-- POST-CONNECT REVEAL CONTAINER (Hidden until key is entered & verified) -->
488
+ <div id="postConnectSection" style="display:none; margin-top:20px; animation: fadeIn 0.4s ease-in-out;">
489
+
490
+ <!-- Active Connections Status Banner -->
491
+ <div id="activeSessionsBanner" style="padding:14px 16px; border-radius:12px; background:rgba(30, 41, 59, 0.7); border:1px solid rgba(16, 185, 129, 0.3); margin-bottom:16px;">
492
+ <div style="display:flex; align-items:center; justify-content:space-between; margin-bottom:6px;">
493
+ <span style="font-size:13px; font-weight:700; color:#fff; display:flex; align-items:center; gap:8px;">
494
+ <i class="fa-solid fa-circle-dot" style="color:#10B981; font-size:10px;"></i>
495
+ <span id="activeSessionsTitle">Account Status</span>
496
+ </span>
497
+ <span id="activeSessionsBadge" style="font-size:10px; font-weight:800; background:rgba(16,185,129,0.15); color:#10B981; border:1px solid rgba(16,185,129,0.3); padding:2px 8px; border-radius:6px;">VERIFIED</span>
498
+ </div>
499
+ <p id="activeSessionsDesc" style="font-size:12px; color:var(--text-muted); line-height:1.4; margin:0;">
500
+ Your API Key is verified. You can download the 1-click installer below to connect Claude Desktop.
501
+ </p>
502
+ <div id="activeSessionsList" style="margin-top:10px; display:flex; flex-direction:column; gap:6px;"></div>
503
+ </div>
504
+
505
+ <!-- Live Quota Status Card -->
506
+ <div class="quota-box" id="quotaBox" style="display:block; margin-top:0; margin-bottom:16px;">
507
+ <div class="quota-header">
508
+ <span style="font-size:13px; font-weight:700; color:#10B981;"><i class="fa-solid fa-circle-check"></i> Connected: <span id="bizName">My Business</span></span>
509
+ <span style="font-size:11px; color:#FBBF24; font-weight:700;" id="planName">PRO PLAN</span>
510
+ </div>
511
+ <div class="quota-grid">
512
+ <div class="quota-item">
513
+ <div class="quota-val" id="creditVal">--</div>
514
+ <div class="quota-lbl">Credits Left</div>
515
+ </div>
516
+ <div class="quota-item">
517
+ <div class="quota-val" id="tierVal">1K/day</div>
518
+ <div class="quota-lbl">Meta Tier</div>
519
+ </div>
520
+ <div class="quota-item">
521
+ <div class="quota-val" id="botsVal">--</div>
522
+ <div class="quota-lbl">Auto-Replies</div>
523
+ </div>
524
+ </div>
525
+ </div>
526
+
527
+ <!-- 1-Click Auto-Installer Download Buttons -->
528
+ <div style="background:rgba(16,185,129,0.08); border:1px solid rgba(16,185,129,0.25); border-radius:14px; padding:16px; margin-bottom:16px;">
529
+ <div style="display:flex; align-items:center; gap:8px; margin-bottom:10px;">
530
+ <i class="fa-solid fa-wand-magic-sparkles" style="color:#10B981; font-size:16px;"></i>
531
+ <span style="font-size:13px; font-weight:800; color:#fff;">1-Click Auto-Setup (No Terminal / No Coding)</span>
532
+ </div>
533
+
534
+ <!-- 1-Line Terminal Quick Paste -->
535
+ <div style="background:#020617; border:1px solid rgba(16,185,129,0.3); border-radius:10px; padding:10px 14px; margin-bottom:12px; display:flex; align-items:center; justify-content:space-between;">
536
+ <code id="curlCommand" style="font-family:var(--font-mono); font-size:11px; color:#10B981; word-break:break-all;">curl -fsSL https://mcp.messegy.com/install.sh | bash</code>
537
+ <button onclick="copyCurl()" style="background:rgba(16,185,129,0.2); border:1px solid #10B981; color:#fff; padding:4px 10px; border-radius:6px; font-size:11px; cursor:pointer; font-weight:700; margin-left:10px; white-space:nowrap;"><i class="fa-regular fa-copy"></i> Copy</button>
538
+ </div>
539
+
540
+ <p style="font-size:12px; color:var(--text-muted); margin-bottom:10px; line-height:1.4;">
541
+ Or download and run the installer file:
542
+ </p>
543
+ <div style="display:grid; grid-template-columns:1fr 1fr; gap:10px;">
544
+ <button onclick="downloadInstaller('mac')" style="background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.2); color:#fff; padding:10px; border-radius:8px; font-size:12px; font-weight:700; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:6px;">
545
+ <i class="fa-brands fa-apple"></i> Mac Installer (.command)
546
+ </button>
547
+ <button onclick="downloadInstaller('windows')" style="background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.2); color:#fff; padding:10px; border-radius:8px; font-size:12px; font-weight:700; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:6px;">
548
+ <i class="fa-brands fa-windows"></i> Windows Installer (.bat)
549
+ </button>
550
+ </div>
551
+ <p style="font-size:11px; color:#94A3B8; margin-top:8px; line-height:1.3;">
552
+ 💡 <strong>Mac Tip:</strong> If double-clicking shows an Apple security prompt, right-click the downloaded file and select <strong>Open</strong>.
553
+ </p>
554
+ </div>
555
+
556
+ <!-- Generated JSON Code Box (For Developers) -->
557
+ <div style="margin-bottom:16px;">
558
+ <div style="display:flex; justify-content:space-between; align-items:center;">
559
+ <label class="input-label" style="margin-bottom:0;">Or Manual Config (For Claude Desktop)</label>
560
+ </div>
561
+ <div class="code-box">
562
+ <button class="btn-copy-code" onclick="copyConfig()"><i class="fa-regular fa-copy"></i> Copy</button>
563
+ <pre id="configSnippet">{\n "mcpServers": {\n "messegy": {\n "command": "npx",\n "args": ["-y", "@messegy/mcp"]\n }\n }\n}</pre>
564
+ </div>
565
+ </div>
566
+
567
+ <!-- Remote SSE URL -->
568
+ <div>
569
+ <label class="input-label">Cloud SSE Remote URL (For Cursor / Web Clients)</label>
570
+ <div class="code-box" style="padding:10px 14px; color:#10B981;" id="sseUrlSnippet">
571
+ https://mcp.messegy.com/sse
572
+ </div>
573
+ </div>
574
+
575
+ </div>
576
+ </div>
577
+
578
+ <!-- Card 2: Interactive In-Browser AI WhatsApp Sandbox -->
579
+ <div class="card">
580
+ <div class="card-header">
581
+ <div class="card-title">
582
+ <i class="fa-solid fa-comments card-icon"></i>
583
+ <span>Live WhatsApp AI Sandbox</span>
584
+ </div>
585
+ <span style="font-size:11px; color:var(--text-muted);"><i class="fa-solid fa-circle" style="color:#10B981; font-size:8px;"></i> Live Tester</span>
586
+ </div>
587
+
588
+ <div class="sandbox-chat">
589
+ <div class="chat-messages" id="chatMessages">
590
+ <div class="chat-msg bot">
591
+ 👋 <strong>Welcome to Messegy MCP Sandbox!</strong><br>
592
+ You can test real WhatsApp tools directly in this browser playground.<br><br>
593
+ 💡 <em>Try typing:</em><br>
594
+ • "Check my account health & plan credits"<br>
595
+ • "List active WhatsApp templates"<br>
596
+ • "List auto-reply rules"
597
+ </div>
598
+ </div>
599
+
600
+ <div class="chat-input-row">
601
+ <input type="text" id="chatInput" class="chat-input" placeholder="Type a command for Messegy WhatsApp AI..." onkeydown="if(event.key==='Enter') sendChat()">
602
+ <button class="btn-send" onclick="sendChat()"><i class="fa-solid fa-paper-plane"></i></button>
603
+ </div>
604
+ </div>
605
+ </div>
606
+
607
+ </div>
608
+
609
+ <!-- Available Tools Grid -->
610
+ <div class="tools-section">
611
+ <div class="section-title">
612
+ <i class="fa-solid fa-toolbox" style="color:var(--emerald);"></i>
613
+ <span>18+ Built-in WhatsApp AI Tools</span>
614
+ </div>
615
+
616
+ <div class="tools-grid">
617
+ <div class="tool-card">
618
+ <div class="tool-name">messegy_send_whatsapp_message</div>
619
+ <div class="tool-desc">Send direct text, image, video, PDF, or audio WhatsApp message to any customer phone.</div>
620
+ </div>
621
+ <div class="tool-card">
622
+ <div class="tool-name">messegy_send_interactive_buttons</div>
623
+ <div class="tool-desc">Send up to 3 clickable quick-reply interactive buttons.</div>
624
+ </div>
625
+ <div class="tool-card">
626
+ <div class="tool-name">messegy_send_list_menu</div>
627
+ <div class="tool-desc">Send structured dropdown list menu with selectable rows and sections.</div>
628
+ </div>
629
+ <div class="tool-card">
630
+ <div class="tool-name">messegy_list_templates</div>
631
+ <div class="tool-desc">List approved, pending, and rejected Meta WhatsApp templates.</div>
632
+ </div>
633
+ <div class="tool-card">
634
+ <div class="tool-name">messegy_send_template_message</div>
635
+ <div class="tool-desc">Send pre-approved templates with dynamic body parameters ({{1}}, {{2}}).</div>
636
+ </div>
637
+ <div class="tool-card">
638
+ <div class="tool-name">messegy_create_template</div>
639
+ <div class="tool-desc">Submit new template directly to Meta for instant review.</div>
640
+ </div>
641
+ <div class="tool-card">
642
+ <div class="tool-name">messegy_list_chats</div>
643
+ <div class="tool-desc">Retrieve active customer WhatsApp threads with unread indicators.</div>
644
+ </div>
645
+ <div class="tool-card">
646
+ <div class="tool-name">messegy_get_chat_history</div>
647
+ <div class="tool-desc">Fetch full chronological conversation message history.</div>
648
+ </div>
649
+ <div class="tool-card">
650
+ <div class="tool-name">messegy_create_broadcast</div>
651
+ <div class="tool-desc">Launch bulk marketing broadcast to segmented tags or recipient lists.</div>
652
+ </div>
653
+ <div class="tool-card">
654
+ <div class="tool-name">messegy_list_auto_replies</div>
655
+ <div class="tool-desc">List all keyword auto-responders and bot trigger rules.</div>
656
+ </div>
657
+ <div class="tool-card">
658
+ <div class="tool-name">messegy_create_auto_reply</div>
659
+ <div class="tool-desc">Create keyword-based auto-replies with text, buttons, or templates.</div>
660
+ </div>
661
+ <div class="tool-card">
662
+ <div class="tool-name">messegy_list_flows</div>
663
+ <div class="tool-desc">List all WhatsApp Flows (native interactive forms & surveys).</div>
664
+ </div>
665
+ <div class="tool-card">
666
+ <div class="tool-name">messegy_send_flow_message</div>
667
+ <div class="tool-desc">Send interactive flow message with native form button to customer.</div>
668
+ </div>
669
+ <div class="tool-card">
670
+ <div class="tool-name">messegy_get_flow_submissions</div>
671
+ <div class="tool-desc">Fetch submitted form responses, lead details, and survey answers.</div>
672
+ </div>
673
+ <div class="tool-card">
674
+ <div class="tool-name">messegy_get_plan_limits_and_usage</div>
675
+ <div class="tool-desc">Inspect active subscription plan quotas, message balance, and rule limits.</div>
676
+ </div>
677
+ <div class="tool-card">
678
+ <div class="tool-name">messegy_trigger_shopify_abandoned_cart</div>
679
+ <div class="tool-desc">Trigger abandoned checkout recovery messages with auto-applied discount links.</div>
680
+ </div>
681
+ </div>
682
+ </div>
683
+
684
+ </main>
685
+
686
+ <!-- Footer -->
687
+ <footer>
688
+ Messegy Model Context Protocol (MCP) Cloud Engine © 2026 Messegy Platform. All rights reserved.
689
+ </footer>
690
+
691
+ <script>
692
+ async function verifyAndGenerate() {
693
+ const apiKey = document.getElementById('apiKeyInput').value.trim();
694
+ const projectKey = document.getElementById('projectKeyInput').value.trim();
695
+
696
+ if (!apiKey) {
697
+ alert('Please enter your Messegy API Key');
698
+ return;
699
+ }
700
+
701
+ const btn = document.querySelector('.btn-connect');
702
+ btn.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Verifying...';
703
+
704
+ try {
705
+ const res = await fetch('/api/verify-key', {
706
+ method: 'POST',
707
+ headers: { 'Content-Type': 'application/json' },
708
+ body: JSON.stringify({ apiKey, projectKey })
709
+ });
710
+ const data = await res.json();
711
+
712
+ if (data.success) {
713
+ // Reveal post-connect download and quota container
714
+ document.getElementById('postConnectSection').style.display = 'block';
715
+
716
+ // Update Active Sessions Banner
717
+ const count = data.activeConnectionsCount || 0;
718
+ if (count > 0) {
719
+ document.getElementById('activeSessionsTitle').innerHTML = '<i class="fa-solid fa-circle-check" style="color:#FBBF24;"></i> Active on ' + count + ' Device' + (count > 1 ? 's' : '');
720
+ document.getElementById('activeSessionsBadge').innerText = count + ' ACTIVE INSTANCE' + (count > 1 ? 'S' : '');
721
+ document.getElementById('activeSessionsBadge').style.background = 'rgba(251, 191, 36, 0.15)';
722
+ document.getElementById('activeSessionsBadge').style.color = '#FBBF24';
723
+ document.getElementById('activeSessionsBadge').style.borderColor = 'rgba(251, 191, 36, 0.3)';
724
+ document.getElementById('activeSessionsDesc').innerHTML = '⚠️ <strong>Already Connected:</strong> Your account is currently running on <strong>' + count + ' active Claude/Cursor session' + (count > 1 ? 's' : '') + '</strong>. You can still download & connect on another computer below (Multi-Instance Supported).';
725
+
726
+ // List connected instances
727
+ const listDiv = document.getElementById('activeSessionsList');
728
+ listDiv.innerHTML = '';
729
+ if (data.activeSessions && data.activeSessions.length > 0) {
730
+ data.activeSessions.forEach(function(s) {
731
+ listDiv.innerHTML += '<div style="font-size:11px; color:#38BDF8; font-family:var(--font-mono); background:rgba(2,6,23,0.5); padding:6px 10px; border-radius:6px; display:flex; justify-content:space-between;"><span>💻 ' + s.client + '</span><span>🕒 ' + s.connectedAt + '</span></div>';
732
+ });
733
+ }
734
+ } else {
735
+ document.getElementById('activeSessionsTitle').innerHTML = '<i class="fa-solid fa-circle-check" style="color:#10B981;"></i> Verified & Ready to Connect';
736
+ document.getElementById('activeSessionsBadge').innerText = '0 ACTIVE SESSIONS';
737
+ document.getElementById('activeSessionsDesc').innerText = 'Your API Key is verified. Download the 1-click installer below to connect Claude Desktop on your computer.';
738
+ document.getElementById('activeSessionsList').innerHTML = '';
739
+ }
740
+
741
+ document.getElementById('bizName').innerText = data.workspaceName || 'Active Workspace';
742
+ document.getElementById('planName').innerText = (data.planName || 'PRO PLAN').toUpperCase();
743
+ document.getElementById('creditVal').innerText = (data.creditsRemaining || 1000).toLocaleString();
744
+ document.getElementById('tierVal').innerText = data.tier || '1K/day';
745
+ document.getElementById('botsVal').innerText = (data.autoRepliesUsed || 0) + '/' + (data.maxAutoReplies || 10);
746
+ document.getElementById('conn-badge').innerText = 'CONNECTED';
747
+ document.getElementById('conn-badge').style.background = 'rgba(16,185,129,0.2)';
748
+ document.getElementById('conn-badge').style.color = '#10B981';
749
+
750
+ // Update Claude Config Snippet
751
+ const config = {
752
+ mcpServers: {
753
+ messegy: {
754
+ command: "npx",
755
+ args: ["-y", "@messegy/mcp"],
756
+ env: {
757
+ MESSEGY_API_KEY: apiKey,
758
+ ...(projectKey ? { MESSEGY_PROJECT_KEY: projectKey } : {})
759
+ }
760
+ }
761
+ }
762
+ };
763
+ document.getElementById('configSnippet').innerText = JSON.stringify(config, null, 2);
764
+
765
+ // Update 1-Line Curl Command
766
+ document.getElementById('curlCommand').innerText = 'curl -fsSL "https://mcp.messegy.com/install.sh?api_key=' + apiKey + '" | bash';
767
+
768
+ // Update SSE URL
769
+ const currentOrigin = window.location.origin;
770
+ document.getElementById('sseUrlSnippet').innerText = currentOrigin + '/sse?api_key=' + apiKey + (projectKey ? '&project_key=' + projectKey : '');
771
+ } else {
772
+ alert('Verification notice: ' + (data.message || 'Please check your API key.'));
773
+ }
774
+ } catch (err) {
775
+ alert('Could not verify with server: ' + err.message);
776
+ } finally {
777
+ btn.innerHTML = '<i class="fa-solid fa-link"></i> Re-verify / Refresh Status';
778
+ }
779
+ }
780
+
781
+ function copyCurl() {
782
+ const text = document.getElementById('curlCommand').innerText;
783
+ navigator.clipboard.writeText(text);
784
+ alert('1-Line Installer command copied! Just open Terminal and paste (Cmd + V) to connect instantly.');
785
+ }
786
+
787
+ function downloadInstaller(target) {
788
+ const apiKey = document.getElementById('apiKeyInput').value.trim();
789
+ const url = '/download/' + target + (apiKey ? '?api_key=' + encodeURIComponent(apiKey) : '');
790
+ window.location.href = url;
791
+ }
792
+
793
+ function copyConfig() {
794
+ const text = document.getElementById('configSnippet').innerText;
795
+ navigator.clipboard.writeText(text);
796
+ alert('Claude Desktop configuration copied to clipboard!');
797
+ }
798
+
799
+ async function sendChat() {
800
+ const input = document.getElementById('chatInput');
801
+ const text = input.value.trim();
802
+ if (!text) return;
803
+
804
+ const apiKey = document.getElementById('apiKeyInput').value.trim();
805
+ const projectKey = document.getElementById('projectKeyInput').value.trim();
806
+
807
+ const messagesDiv = document.getElementById('chatMessages');
808
+ messagesDiv.innerHTML += '<div class="chat-msg user">' + escapeHtml(text) + '</div>';
809
+ input.value = '';
810
+ messagesDiv.scrollTop = messagesDiv.scrollHeight;
811
+
812
+ // Loading bubble
813
+ const loadingId = 'loading-' + Date.now();
814
+ messagesDiv.innerHTML += '<div class="chat-msg bot" id="' + loadingId + '"><i class="fa-solid fa-spinner fa-spin"></i> Querying Messegy WhatsApp Engine...</div>';
815
+ messagesDiv.scrollTop = messagesDiv.scrollHeight;
816
+
817
+ try {
818
+ const res = await fetch('/api/test-tool', {
819
+ method: 'POST',
820
+ headers: { 'Content-Type': 'application/json' },
821
+ body: JSON.stringify({ query: text, apiKey, projectKey })
822
+ });
823
+ const data = await res.json();
824
+
825
+ const loader = document.getElementById(loadingId);
826
+ if (loader) {
827
+ loader.innerHTML = '<strong>Messegy Response:</strong><br><pre style="white-space:pre-wrap; margin-top:6px; font-family:var(--font-mono); font-size:11px;">' + escapeHtml(data.reply || JSON.stringify(data, null, 2)) + '</pre>';
828
+ }
829
+ } catch (err) {
830
+ const loader = document.getElementById(loadingId);
831
+ if (loader) {
832
+ loader.innerHTML = '❌ Error: ' + err.message;
833
+ }
834
+ }
835
+ messagesDiv.scrollTop = messagesDiv.scrollHeight;
836
+ }
837
+
838
+ function escapeHtml(string) {
839
+ return String(string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
840
+ }
841
+ </script>
842
+ </body>
843
+ </html>`;
844
+ }