@magnetlab/mcp 0.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 (58) hide show
  1. package/README.md +119 -0
  2. package/dist/client.d.ts +465 -0
  3. package/dist/client.js +456 -0
  4. package/dist/constants.d.ts +30 -0
  5. package/dist/constants.js +87 -0
  6. package/dist/handlers/analytics.d.ts +5 -0
  7. package/dist/handlers/analytics.js +11 -0
  8. package/dist/handlers/brand-kit.d.ts +5 -0
  9. package/dist/handlers/brand-kit.js +32 -0
  10. package/dist/handlers/content-pipeline.d.ts +5 -0
  11. package/dist/handlers/content-pipeline.js +127 -0
  12. package/dist/handlers/email-sequences.d.ts +5 -0
  13. package/dist/handlers/email-sequences.js +30 -0
  14. package/dist/handlers/funnels.d.ts +5 -0
  15. package/dist/handlers/funnels.js +65 -0
  16. package/dist/handlers/ideation.d.ts +5 -0
  17. package/dist/handlers/ideation.js +44 -0
  18. package/dist/handlers/index.d.ts +24 -0
  19. package/dist/handlers/index.js +104 -0
  20. package/dist/handlers/lead-magnets.d.ts +5 -0
  21. package/dist/handlers/lead-magnets.js +31 -0
  22. package/dist/handlers/leads.d.ts +5 -0
  23. package/dist/handlers/leads.js +24 -0
  24. package/dist/handlers/libraries.d.ts +5 -0
  25. package/dist/handlers/libraries.js +31 -0
  26. package/dist/handlers/qualification-forms.d.ts +5 -0
  27. package/dist/handlers/qualification-forms.js +21 -0
  28. package/dist/handlers/swipe-file.d.ts +5 -0
  29. package/dist/handlers/swipe-file.js +31 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +58 -0
  32. package/dist/tools/analytics.d.ts +2 -0
  33. package/dist/tools/analytics.js +10 -0
  34. package/dist/tools/brand-kit.d.ts +2 -0
  35. package/dist/tools/brand-kit.js +89 -0
  36. package/dist/tools/content-pipeline.d.ts +2 -0
  37. package/dist/tools/content-pipeline.js +476 -0
  38. package/dist/tools/email-sequences.d.ts +2 -0
  39. package/dist/tools/email-sequences.js +70 -0
  40. package/dist/tools/funnels.d.ts +2 -0
  41. package/dist/tools/funnels.js +153 -0
  42. package/dist/tools/ideation.d.ts +2 -0
  43. package/dist/tools/ideation.js +161 -0
  44. package/dist/tools/index.d.ts +66 -0
  45. package/dist/tools/index.js +52 -0
  46. package/dist/tools/lead-magnets.d.ts +2 -0
  47. package/dist/tools/lead-magnets.js +101 -0
  48. package/dist/tools/leads.d.ts +2 -0
  49. package/dist/tools/leads.js +32 -0
  50. package/dist/tools/libraries.d.ts +2 -0
  51. package/dist/tools/libraries.js +83 -0
  52. package/dist/tools/qualification-forms.d.ts +2 -0
  53. package/dist/tools/qualification-forms.js +71 -0
  54. package/dist/tools/swipe-file.d.ts +2 -0
  55. package/dist/tools/swipe-file.js +46 -0
  56. package/dist/validation.d.ts +476 -0
  57. package/dist/validation.js +236 -0
  58. package/package.json +52 -0
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # @magnetlab/mcp
2
+
3
+ MCP server for [MagnetLab](https://magnetlab.ai) -- control your lead magnets, funnels, content pipeline, and analytics from Claude Code or Claude Desktop.
4
+
5
+ ## Quick Setup
6
+
7
+ ### Claude Code
8
+
9
+ Add to your project's `.mcp.json`:
10
+
11
+ ```json
12
+ {
13
+ "mcpServers": {
14
+ "magnetlab": {
15
+ "command": "npx",
16
+ "args": ["-y", "@magnetlab/mcp", "serve"],
17
+ "env": {
18
+ "MAGNETLAB_API_KEY": "ml_live_your_key_here"
19
+ }
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ ### Claude Desktop
26
+
27
+ Add to your `claude_desktop_config.json`:
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "magnetlab": {
33
+ "command": "npx",
34
+ "args": ["-y", "@magnetlab/mcp", "serve"],
35
+ "env": {
36
+ "MAGNETLAB_API_KEY": "ml_live_your_key_here"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ## Getting Your API Key
44
+
45
+ 1. Log in to [MagnetLab](https://magnetlab.ai)
46
+ 2. Go to **Settings > API Keys**
47
+ 3. Click **Create API Key**
48
+ 4. Copy the key (starts with `ml_live_`)
49
+
50
+ ## Available Tools
51
+
52
+ | Category | Tools | What You Can Do |
53
+ |----------|------:|-----------------|
54
+ | Lead Magnets | 7 | List, create, delete, get stats, analyze competitors and transcripts |
55
+ | Ideation | 6 | Generate lead magnet ideas, extract and generate content, write LinkedIn posts, polish |
56
+ | Funnels | 9 | Create opt-in pages, customize copy/theme, publish/unpublish, AI-generate funnel content |
57
+ | Leads | 2 | List captured leads with filters, export as CSV |
58
+ | Analytics | 1 | Get per-funnel stats (views, leads, conversion rates) |
59
+ | Brand Kit | 3 | Get/update business context, extract context from raw text |
60
+ | Email Sequences | 4 | Generate AI welcome sequences, edit emails, activate drip campaigns |
61
+ | Content Pipeline | 34 | Transcripts, AI Brain knowledge base, content ideas, pipeline posts, autopilot, writing styles, templates, content planner, business context |
62
+ | Swipe File | 3 | Browse community posts and lead magnets, submit your own |
63
+ | Libraries | 7 | Create content libraries, manage items, gate behind funnels |
64
+ | Qualification Forms | 5 | Create forms with scoring questions, attach to funnels |
65
+ | **Total** | **81** | |
66
+
67
+ ## Environment Variables
68
+
69
+ | Variable | Required | Description |
70
+ |----------|----------|-------------|
71
+ | `MAGNETLAB_API_KEY` | Yes | Your MagnetLab API key (starts with `ml_live_`) |
72
+ | `MAGNETLAB_BASE_URL` | No | Override the API base URL (default: `https://magnetlab.ai`) |
73
+
74
+ ## CLI Usage
75
+
76
+ Start the MCP server (stdio transport):
77
+
78
+ ```bash
79
+ # Using environment variable
80
+ MAGNETLAB_API_KEY=ml_live_xxx npx @magnetlab/mcp serve
81
+
82
+ # Using --api-key flag
83
+ npx @magnetlab/mcp serve --api-key ml_live_xxx
84
+
85
+ # With custom base URL
86
+ npx @magnetlab/mcp serve --base-url http://localhost:3000
87
+ ```
88
+
89
+ ## Example Prompts
90
+
91
+ Once the MCP server is connected, try these in Claude:
92
+
93
+ **Lead magnets:**
94
+ - "List all my lead magnets"
95
+ - "Create a new lead magnet called 'LinkedIn Growth Playbook' with the focused-toolkit archetype"
96
+ - "What are the stats on my best-performing lead magnet?"
97
+
98
+ **Funnels:**
99
+ - "Create an opt-in page for my latest lead magnet with a dark theme"
100
+ - "Generate funnel copy for lead magnet [id]"
101
+ - "Publish my funnel and give me the live URL"
102
+
103
+ **Content pipeline:**
104
+ - "Search my AI Brain for insights about pricing objections"
105
+ - "Write a LinkedIn post about [topic]"
106
+ - "Show me my content buffer and what's scheduled this week"
107
+ - "Trigger autopilot to generate 5 new posts"
108
+
109
+ **Lead management:**
110
+ - "How many leads did I capture this month?"
111
+ - "Export all qualified leads as CSV"
112
+
113
+ **Brand kit:**
114
+ - "Extract my business context from this offer document: [paste text]"
115
+ - "Update my brand kit with these pain points: ..."
116
+
117
+ ## License
118
+
119
+ MIT
@@ -0,0 +1,465 @@
1
+ import type { Archetype, LeadMagnetStatus, FunnelTheme, BackgroundStyle, FunnelTargetType, IdeaStatus, ContentPillar, ContentType, KnowledgeCategory, PipelinePostStatus, ExtractContentType } from './constants.js';
2
+ export interface MagnetLabClientOptions {
3
+ baseUrl?: string;
4
+ }
5
+ export declare class MagnetLabClient {
6
+ private apiKey;
7
+ private baseUrl;
8
+ constructor(apiKey: string, options?: MagnetLabClientOptions);
9
+ request<T>(method: string, path: string, body?: unknown): Promise<T>;
10
+ listLeadMagnets(params?: {
11
+ status?: LeadMagnetStatus;
12
+ limit?: number;
13
+ offset?: number;
14
+ }): Promise<{
15
+ leadMagnets: unknown[];
16
+ total: number;
17
+ }>;
18
+ getLeadMagnet(id: string): Promise<unknown>;
19
+ createLeadMagnet(params: {
20
+ title: string;
21
+ archetype: Archetype;
22
+ concept?: unknown;
23
+ extractedContent?: unknown;
24
+ linkedinPost?: string;
25
+ postVariations?: unknown;
26
+ dmTemplate?: string;
27
+ ctaWord?: string;
28
+ }): Promise<unknown>;
29
+ deleteLeadMagnet(id: string): Promise<{
30
+ success: boolean;
31
+ }>;
32
+ ideateLeadMagnets(params: {
33
+ businessDescription: string;
34
+ businessType: string;
35
+ credibilityMarkers?: string[];
36
+ urgentPains?: string[];
37
+ templates?: string[];
38
+ processes?: string[];
39
+ tools?: string[];
40
+ frequentQuestions?: string[];
41
+ results?: string[];
42
+ successExample?: string;
43
+ }): Promise<{
44
+ jobId: string;
45
+ status: string;
46
+ }>;
47
+ extractContent(leadMagnetId: string, params: {
48
+ archetype: Archetype;
49
+ concept: unknown;
50
+ answers: Record<string, string>;
51
+ }): Promise<unknown>;
52
+ generateContent(leadMagnetId: string, params: {
53
+ archetype: Archetype;
54
+ concept: unknown;
55
+ answers: Record<string, string>;
56
+ }): Promise<unknown>;
57
+ writeLinkedInPosts(leadMagnetId: string, params: {
58
+ leadMagnetTitle: string;
59
+ contents: string;
60
+ problemSolved: string;
61
+ }): Promise<unknown>;
62
+ polishLeadMagnetContent(leadMagnetId: string): Promise<unknown>;
63
+ getLeadMagnetStats(leadMagnetId: string): Promise<{
64
+ success: boolean;
65
+ data: {
66
+ leadMagnetId: string;
67
+ views: number;
68
+ leads: number;
69
+ conversionRate: number;
70
+ };
71
+ }>;
72
+ importLeadMagnet(data: unknown): Promise<unknown>;
73
+ analyzeCompetitor(params: {
74
+ url: string;
75
+ }): Promise<unknown>;
76
+ analyzeTranscript(params: {
77
+ transcript: string;
78
+ }): Promise<unknown>;
79
+ listFunnels(): Promise<{
80
+ funnels: unknown[];
81
+ }>;
82
+ getFunnel(id: string): Promise<{
83
+ funnel: unknown;
84
+ }>;
85
+ getFunnelByTarget(params: {
86
+ leadMagnetId?: string;
87
+ libraryId?: string;
88
+ externalResourceId?: string;
89
+ }): Promise<{
90
+ funnel: unknown | null;
91
+ }>;
92
+ createFunnel(params: {
93
+ leadMagnetId?: string;
94
+ libraryId?: string;
95
+ externalResourceId?: string;
96
+ targetType?: FunnelTargetType;
97
+ slug: string;
98
+ optinHeadline?: string;
99
+ optinSubline?: string;
100
+ optinButtonText?: string;
101
+ optinSocialProof?: string;
102
+ thankyouHeadline?: string;
103
+ thankyouSubline?: string;
104
+ vslUrl?: string;
105
+ calendlyUrl?: string;
106
+ theme?: FunnelTheme;
107
+ primaryColor?: string;
108
+ backgroundStyle?: BackgroundStyle;
109
+ logoUrl?: string;
110
+ qualificationFormId?: string;
111
+ }): Promise<{
112
+ funnel: unknown;
113
+ }>;
114
+ updateFunnel(id: string, params: {
115
+ slug?: string;
116
+ optinHeadline?: string;
117
+ optinSubline?: string;
118
+ optinButtonText?: string;
119
+ optinSocialProof?: string;
120
+ thankyouHeadline?: string;
121
+ thankyouSubline?: string;
122
+ vslUrl?: string;
123
+ calendlyUrl?: string;
124
+ theme?: FunnelTheme;
125
+ primaryColor?: string;
126
+ backgroundStyle?: BackgroundStyle;
127
+ logoUrl?: string;
128
+ qualificationFormId?: string | null;
129
+ }): Promise<{
130
+ funnel: unknown;
131
+ }>;
132
+ deleteFunnel(id: string): Promise<{
133
+ success: boolean;
134
+ }>;
135
+ publishFunnel(id: string): Promise<{
136
+ funnel: unknown;
137
+ publicUrl: string | null;
138
+ }>;
139
+ unpublishFunnel(id: string): Promise<{
140
+ funnel: unknown;
141
+ }>;
142
+ getFunnelStats(): Promise<{
143
+ stats: Record<string, unknown>;
144
+ }>;
145
+ generateFunnelContent(params: {
146
+ leadMagnetId: string;
147
+ }): Promise<unknown>;
148
+ listLeads(params?: {
149
+ funnelId?: string;
150
+ leadMagnetId?: string;
151
+ qualified?: boolean;
152
+ search?: string;
153
+ limit?: number;
154
+ offset?: number;
155
+ }): Promise<{
156
+ leads: unknown[];
157
+ total: number;
158
+ }>;
159
+ exportLeads(params?: {
160
+ funnelId?: string;
161
+ leadMagnetId?: string;
162
+ qualified?: boolean;
163
+ }): Promise<{
164
+ csv: string;
165
+ }>;
166
+ getBrandKit(): Promise<{
167
+ brandKit: unknown | null;
168
+ savedIdeation: unknown | null;
169
+ ideationGeneratedAt: string | null;
170
+ }>;
171
+ updateBrandKit(params: {
172
+ businessDescription?: string;
173
+ businessType?: string;
174
+ credibilityMarkers?: string[];
175
+ urgentPains?: string[];
176
+ templates?: string[];
177
+ processes?: string[];
178
+ tools?: string[];
179
+ frequentQuestions?: string[];
180
+ results?: string[];
181
+ successExample?: string;
182
+ audienceTools?: string[];
183
+ preferredTone?: string;
184
+ styleProfile?: unknown;
185
+ }): Promise<unknown>;
186
+ extractBusinessContext(params: {
187
+ content: string;
188
+ contentType?: ExtractContentType;
189
+ }): Promise<unknown>;
190
+ getEmailSequence(leadMagnetId: string): Promise<{
191
+ emailSequence: unknown | null;
192
+ }>;
193
+ generateEmailSequence(params: {
194
+ leadMagnetId: string;
195
+ useAI?: boolean;
196
+ }): Promise<{
197
+ emailSequence: unknown;
198
+ generated: boolean;
199
+ }>;
200
+ updateEmailSequence(leadMagnetId: string, params: {
201
+ emails?: Array<{
202
+ day: number;
203
+ subject: string;
204
+ body: string;
205
+ replyTrigger: string;
206
+ }>;
207
+ status?: 'draft' | 'synced' | 'active';
208
+ }): Promise<{
209
+ emailSequence: unknown;
210
+ }>;
211
+ activateEmailSequence(leadMagnetId: string): Promise<unknown>;
212
+ listTranscripts(): Promise<{
213
+ transcripts: unknown[];
214
+ }>;
215
+ submitTranscript(params: {
216
+ transcript: string;
217
+ title?: string;
218
+ }): Promise<{
219
+ success: boolean;
220
+ transcript_id: string;
221
+ }>;
222
+ deleteTranscript(id: string): Promise<{
223
+ success: boolean;
224
+ }>;
225
+ searchKnowledge(params: {
226
+ query?: string;
227
+ category?: KnowledgeCategory;
228
+ view?: 'tags';
229
+ }): Promise<{
230
+ entries?: unknown[];
231
+ tags?: unknown[];
232
+ total_count?: number;
233
+ }>;
234
+ getKnowledgeClusters(): Promise<{
235
+ clusters: unknown[];
236
+ }>;
237
+ listIdeas(params?: {
238
+ status?: IdeaStatus;
239
+ pillar?: ContentPillar;
240
+ contentType?: ContentType;
241
+ limit?: number;
242
+ }): Promise<{
243
+ ideas: unknown[];
244
+ }>;
245
+ updateIdeaStatus(ideaId: string, status: IdeaStatus): Promise<{
246
+ idea: unknown;
247
+ }>;
248
+ getIdea(id: string): Promise<{
249
+ idea: unknown;
250
+ }>;
251
+ deleteIdea(id: string): Promise<{
252
+ success: boolean;
253
+ }>;
254
+ writePostFromIdea(ideaId: string): Promise<unknown>;
255
+ listPosts(params?: {
256
+ status?: PipelinePostStatus;
257
+ isBuffer?: boolean;
258
+ limit?: number;
259
+ }): Promise<{
260
+ posts: unknown[];
261
+ }>;
262
+ getPost(id: string): Promise<{
263
+ post: unknown;
264
+ }>;
265
+ updatePost(id: string, params: Record<string, unknown>): Promise<{
266
+ post: unknown;
267
+ }>;
268
+ deletePost(id: string): Promise<{
269
+ success: boolean;
270
+ }>;
271
+ polishPost(id: string): Promise<{
272
+ success: boolean;
273
+ polishResult: unknown;
274
+ }>;
275
+ publishPost(id: string): Promise<unknown>;
276
+ schedulePost(params: {
277
+ postId: string;
278
+ scheduledTime: string;
279
+ }): Promise<unknown>;
280
+ getPostsByDateRange(params: {
281
+ startDate: string;
282
+ endDate: string;
283
+ }): Promise<{
284
+ posts: unknown[];
285
+ }>;
286
+ quickWritePost(params: {
287
+ topic: string;
288
+ style?: string;
289
+ template?: string;
290
+ }): Promise<unknown>;
291
+ listPostingSlots(): Promise<{
292
+ slots: unknown[];
293
+ }>;
294
+ createPostingSlot(params: {
295
+ dayOfWeek: number;
296
+ time: string;
297
+ }): Promise<{
298
+ slot: unknown;
299
+ }>;
300
+ updatePostingSlot(id: string, params: {
301
+ dayOfWeek?: number;
302
+ time?: string;
303
+ }): Promise<{
304
+ slot: unknown;
305
+ }>;
306
+ deletePostingSlot(id: string): Promise<{
307
+ success: boolean;
308
+ }>;
309
+ getAutopilotStatus(): Promise<{
310
+ bufferSize: number;
311
+ nextScheduledSlot: string;
312
+ pillarCounts: Record<string, number>;
313
+ }>;
314
+ triggerAutopilot(params?: {
315
+ postsPerBatch?: number;
316
+ bufferTarget?: number;
317
+ autoPublish?: boolean;
318
+ }): Promise<{
319
+ triggered: boolean;
320
+ runId: string;
321
+ }>;
322
+ getBuffer(): Promise<{
323
+ posts: unknown[];
324
+ }>;
325
+ listWritingStyles(): Promise<{
326
+ styles: unknown[];
327
+ }>;
328
+ extractWritingStyle(params: {
329
+ linkedinUrl: string;
330
+ }): Promise<unknown>;
331
+ getWritingStyle(id: string): Promise<{
332
+ style: unknown;
333
+ }>;
334
+ listTemplates(params?: {
335
+ limit?: number;
336
+ }): Promise<{
337
+ templates: unknown[];
338
+ }>;
339
+ getTemplate(id: string): Promise<{
340
+ template: unknown;
341
+ }>;
342
+ matchTemplate(params: {
343
+ ideaId: string;
344
+ }): Promise<{
345
+ matches: unknown[];
346
+ }>;
347
+ getPlan(): Promise<{
348
+ plan: unknown;
349
+ }>;
350
+ generatePlan(params?: {
351
+ weekCount?: number;
352
+ }): Promise<unknown>;
353
+ approvePlan(params: {
354
+ planId: string;
355
+ }): Promise<unknown>;
356
+ updatePlanItem(id: string, params: Record<string, unknown>): Promise<unknown>;
357
+ getBusinessContext(): Promise<{
358
+ businessContext: unknown;
359
+ }>;
360
+ updateBusinessContext(params: Record<string, unknown>): Promise<unknown>;
361
+ browseSwipeFilePosts(params?: {
362
+ niche?: string;
363
+ type?: string;
364
+ featured?: boolean;
365
+ limit?: number;
366
+ offset?: number;
367
+ }): Promise<{
368
+ posts: unknown[];
369
+ total: number;
370
+ }>;
371
+ browseSwipeFileLeadMagnets(params?: {
372
+ niche?: string;
373
+ format?: string;
374
+ featured?: boolean;
375
+ limit?: number;
376
+ offset?: number;
377
+ }): Promise<{
378
+ leadMagnets: unknown[];
379
+ total: number;
380
+ }>;
381
+ submitToSwipeFile(params: {
382
+ content: string;
383
+ type: string;
384
+ niche: string;
385
+ }): Promise<unknown>;
386
+ getFunnelAnalytics(): Promise<{
387
+ stats: Record<string, unknown>;
388
+ }>;
389
+ getLeadMagnetAnalytics(leadMagnetId: string): Promise<{
390
+ success: boolean;
391
+ data: {
392
+ leadMagnetId: string;
393
+ views: number;
394
+ leads: number;
395
+ conversionRate: number;
396
+ };
397
+ }>;
398
+ listLibraries(): Promise<{
399
+ libraries: unknown[];
400
+ }>;
401
+ getLibrary(id: string): Promise<{
402
+ library: unknown;
403
+ }>;
404
+ createLibrary(params: {
405
+ name: string;
406
+ description?: string;
407
+ }): Promise<{
408
+ library: unknown;
409
+ }>;
410
+ updateLibrary(id: string, params: {
411
+ name?: string;
412
+ description?: string;
413
+ }): Promise<{
414
+ library: unknown;
415
+ }>;
416
+ deleteLibrary(id: string): Promise<{
417
+ success: boolean;
418
+ }>;
419
+ listLibraryItems(libraryId: string): Promise<{
420
+ items: unknown[];
421
+ }>;
422
+ createLibraryItem(libraryId: string, params: Record<string, unknown>): Promise<{
423
+ item: unknown;
424
+ }>;
425
+ listExternalResources(): Promise<{
426
+ resources: unknown[];
427
+ }>;
428
+ getExternalResource(id: string): Promise<{
429
+ resource: unknown;
430
+ }>;
431
+ createExternalResource(params: {
432
+ title: string;
433
+ url: string;
434
+ description?: string;
435
+ }): Promise<{
436
+ resource: unknown;
437
+ }>;
438
+ listQualificationForms(): Promise<{
439
+ forms: unknown[];
440
+ }>;
441
+ getQualificationForm(id: string): Promise<{
442
+ form: unknown;
443
+ }>;
444
+ createQualificationForm(params: {
445
+ name: string;
446
+ }): Promise<{
447
+ form: unknown;
448
+ }>;
449
+ listQuestions(formId: string): Promise<{
450
+ questions: unknown[];
451
+ }>;
452
+ createQuestion(formId: string, params: Record<string, unknown>): Promise<{
453
+ question: unknown;
454
+ }>;
455
+ listIntegrations(): Promise<{
456
+ integrations: unknown[];
457
+ }>;
458
+ verifyIntegration(params: {
459
+ provider: string;
460
+ apiKey: string;
461
+ }): Promise<{
462
+ valid: boolean;
463
+ }>;
464
+ getJobStatus(id: string): Promise<unknown>;
465
+ }