@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
@@ -0,0 +1,236 @@
1
+ import { z } from 'zod';
2
+ import { ARCHETYPES, IDEA_STATUS, PIPELINE_POST_STATUS, KNOWLEDGE_CATEGORIES, CONTENT_PILLARS, CONTENT_TYPES, EXTRACT_CONTENT_TYPES, } from './constants.js';
3
+ // Convert readonly tuples to mutable arrays for z.enum compatibility
4
+ const archetypeValues = [...ARCHETYPES];
5
+ const ideaStatusValues = [...IDEA_STATUS];
6
+ const postStatusValues = [...PIPELINE_POST_STATUS];
7
+ const knowledgeCategoryValues = [...KNOWLEDGE_CATEGORIES];
8
+ const pillarValues = [...CONTENT_PILLARS];
9
+ const contentTypeValues = [...CONTENT_TYPES];
10
+ const extractContentTypeValues = [...EXTRACT_CONTENT_TYPES];
11
+ // Schemas for tools that require strict argument validation
12
+ export const toolSchemas = {
13
+ // Lead Magnet tools
14
+ magnetlab_get_lead_magnet: z.object({
15
+ id: z.string().min(1, 'id is required'),
16
+ }),
17
+ magnetlab_create_lead_magnet: z.object({
18
+ title: z.string().min(1, 'title is required'),
19
+ archetype: z.enum(archetypeValues, {
20
+ message: `archetype must be one of: ${ARCHETYPES.join(', ')}`,
21
+ }),
22
+ }),
23
+ magnetlab_delete_lead_magnet: z.object({
24
+ id: z.string().min(1, 'id is required'),
25
+ }),
26
+ magnetlab_get_lead_magnet_stats: z.object({
27
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
28
+ }),
29
+ magnetlab_analyze_competitor: z.object({
30
+ url: z.string().url('url must be a valid URL'),
31
+ }),
32
+ magnetlab_analyze_transcript: z.object({
33
+ transcript: z.string().min(50, 'transcript must be at least 50 characters'),
34
+ }),
35
+ // Ideation tools
36
+ magnetlab_ideate_lead_magnets: z.object({
37
+ business_description: z.string().min(1, 'business_description is required'),
38
+ business_type: z.string().min(1, 'business_type is required'),
39
+ }),
40
+ magnetlab_extract_content: z.object({
41
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
42
+ archetype: z.enum(archetypeValues),
43
+ concept: z.record(z.unknown()),
44
+ answers: z.record(z.string()),
45
+ }),
46
+ magnetlab_generate_content: z.object({
47
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
48
+ archetype: z.enum(archetypeValues),
49
+ concept: z.record(z.unknown()),
50
+ answers: z.record(z.string()),
51
+ }),
52
+ magnetlab_write_linkedin_posts: z.object({
53
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
54
+ lead_magnet_title: z.string().min(1, 'lead_magnet_title is required'),
55
+ contents: z.string().min(1, 'contents is required'),
56
+ problem_solved: z.string().min(1, 'problem_solved is required'),
57
+ }),
58
+ magnetlab_polish_lead_magnet: z.object({
59
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
60
+ }),
61
+ magnetlab_get_job_status: z.object({
62
+ job_id: z.string().min(1, 'job_id is required'),
63
+ }),
64
+ // Funnel tools
65
+ magnetlab_get_funnel: z.object({
66
+ id: z.string().min(1, 'id is required'),
67
+ }),
68
+ magnetlab_create_funnel: z.object({
69
+ slug: z.string().min(1, 'slug is required'),
70
+ }),
71
+ magnetlab_update_funnel: z.object({
72
+ id: z.string().min(1, 'id is required'),
73
+ }),
74
+ magnetlab_delete_funnel: z.object({
75
+ id: z.string().min(1, 'id is required'),
76
+ }),
77
+ magnetlab_publish_funnel: z.object({
78
+ id: z.string().min(1, 'id is required'),
79
+ }),
80
+ magnetlab_unpublish_funnel: z.object({
81
+ id: z.string().min(1, 'id is required'),
82
+ }),
83
+ magnetlab_generate_funnel_content: z.object({
84
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
85
+ }),
86
+ // Email sequence tools
87
+ magnetlab_get_email_sequence: z.object({
88
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
89
+ }),
90
+ magnetlab_generate_email_sequence: z.object({
91
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
92
+ }),
93
+ magnetlab_update_email_sequence: z.object({
94
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
95
+ }),
96
+ magnetlab_activate_email_sequence: z.object({
97
+ lead_magnet_id: z.string().min(1, 'lead_magnet_id is required'),
98
+ }),
99
+ // Content pipeline tools
100
+ magnetlab_submit_transcript: z.object({
101
+ transcript: z.string().min(100, 'transcript must be at least 100 characters'),
102
+ }),
103
+ magnetlab_delete_transcript: z.object({
104
+ id: z.string().min(1, 'id is required'),
105
+ }),
106
+ magnetlab_search_knowledge: z.object({
107
+ query: z.string().min(1, 'query is required'),
108
+ }),
109
+ magnetlab_get_idea: z.object({
110
+ id: z.string().min(1, 'id is required'),
111
+ }),
112
+ magnetlab_update_idea_status: z.object({
113
+ idea_id: z.string().min(1, 'idea_id is required'),
114
+ status: z.enum(ideaStatusValues, {
115
+ message: `status must be one of: ${IDEA_STATUS.join(', ')}`,
116
+ }),
117
+ }),
118
+ magnetlab_delete_idea: z.object({
119
+ id: z.string().min(1, 'id is required'),
120
+ }),
121
+ magnetlab_write_post_from_idea: z.object({
122
+ idea_id: z.string().min(1, 'idea_id is required'),
123
+ }),
124
+ magnetlab_get_post: z.object({
125
+ id: z.string().min(1, 'id is required'),
126
+ }),
127
+ magnetlab_update_post: z.object({
128
+ id: z.string().min(1, 'id is required'),
129
+ }),
130
+ magnetlab_delete_post: z.object({
131
+ id: z.string().min(1, 'id is required'),
132
+ }),
133
+ magnetlab_polish_post: z.object({
134
+ id: z.string().min(1, 'id is required'),
135
+ }),
136
+ magnetlab_publish_post: z.object({
137
+ id: z.string().min(1, 'id is required'),
138
+ }),
139
+ magnetlab_schedule_post: z.object({
140
+ post_id: z.string().min(1, 'post_id is required'),
141
+ scheduled_time: z.string().min(1, 'scheduled_time is required'),
142
+ }),
143
+ magnetlab_get_posts_by_date_range: z.object({
144
+ start_date: z.string().min(1, 'start_date is required'),
145
+ end_date: z.string().min(1, 'end_date is required'),
146
+ }),
147
+ magnetlab_quick_write: z.object({
148
+ topic: z.string().min(1, 'topic is required'),
149
+ }),
150
+ magnetlab_create_posting_slot: z.object({
151
+ day_of_week: z.number().min(0).max(6),
152
+ time: z.string().min(1, 'time is required'),
153
+ }),
154
+ magnetlab_delete_posting_slot: z.object({
155
+ id: z.string().min(1, 'id is required'),
156
+ }),
157
+ magnetlab_approve_plan: z.object({
158
+ plan_id: z.string().min(1, 'plan_id is required'),
159
+ }),
160
+ magnetlab_update_business_context: z.object({
161
+ context: z.record(z.unknown()),
162
+ }),
163
+ magnetlab_extract_writing_style: z.object({
164
+ linkedin_url: z.string().url('linkedin_url must be a valid URL'),
165
+ }),
166
+ magnetlab_get_writing_style: z.object({
167
+ id: z.string().min(1, 'id is required'),
168
+ }),
169
+ magnetlab_match_template: z.object({
170
+ idea_id: z.string().min(1, 'idea_id is required'),
171
+ }),
172
+ // Brand kit tools
173
+ magnetlab_extract_business_context: z.object({
174
+ content: z.string().min(50, 'content must be at least 50 characters'),
175
+ }),
176
+ // Swipe file tools
177
+ magnetlab_submit_to_swipe_file: z.object({
178
+ content: z.string().min(1, 'content is required'),
179
+ type: z.string().min(1, 'type is required'),
180
+ niche: z.string().min(1, 'niche is required'),
181
+ }),
182
+ // Library tools
183
+ magnetlab_get_library: z.object({
184
+ id: z.string().min(1, 'id is required'),
185
+ }),
186
+ magnetlab_create_library: z.object({
187
+ name: z.string().min(1, 'name is required'),
188
+ }),
189
+ magnetlab_update_library: z.object({
190
+ id: z.string().min(1, 'id is required'),
191
+ }),
192
+ magnetlab_delete_library: z.object({
193
+ id: z.string().min(1, 'id is required'),
194
+ }),
195
+ magnetlab_list_library_items: z.object({
196
+ library_id: z.string().min(1, 'library_id is required'),
197
+ }),
198
+ magnetlab_create_library_item: z.object({
199
+ library_id: z.string().min(1, 'library_id is required'),
200
+ title: z.string().min(1, 'title is required'),
201
+ }),
202
+ // Qualification form tools
203
+ magnetlab_get_qualification_form: z.object({
204
+ id: z.string().min(1, 'id is required'),
205
+ }),
206
+ magnetlab_create_qualification_form: z.object({
207
+ name: z.string().min(1, 'name is required'),
208
+ }),
209
+ magnetlab_list_questions: z.object({
210
+ form_id: z.string().min(1, 'form_id is required'),
211
+ }),
212
+ magnetlab_create_question: z.object({
213
+ form_id: z.string().min(1, 'form_id is required'),
214
+ question_text: z.string().min(1, 'question_text is required'),
215
+ question_type: z.enum(['text', 'single_choice', 'multi_choice']),
216
+ }),
217
+ };
218
+ /**
219
+ * Validate tool arguments against the schema for the given tool.
220
+ * Returns success with parsed data if valid, or failure with error message.
221
+ * Tools without schemas pass through unchanged.
222
+ */
223
+ export function validateToolArgs(toolName, args) {
224
+ const schema = toolSchemas[toolName];
225
+ // Tools without explicit schemas pass through
226
+ if (!schema) {
227
+ return { success: true, data: args };
228
+ }
229
+ const result = schema.safeParse(args);
230
+ if (!result.success) {
231
+ const issues = result.error.issues || [];
232
+ const errors = issues.map((e) => e.message).join(', ');
233
+ return { success: false, error: errors || 'Validation failed' };
234
+ }
235
+ return { success: true, data: result.data };
236
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@magnetlab/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for MagnetLab - control your lead magnets, funnels, content pipeline, and analytics from Claude Code",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "exports": {
8
+ ".": "./dist/index.js"
9
+ },
10
+ "bin": {
11
+ "magnetlab-mcp": "./dist/index.js"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "README.md"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "keywords": [
23
+ "mcp",
24
+ "claude",
25
+ "magnetlab",
26
+ "lead-magnet",
27
+ "funnel",
28
+ "content-pipeline",
29
+ "claude-code",
30
+ "model-context-protocol"
31
+ ],
32
+ "author": "MagnetLab",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/modernagencysales/magnetlab",
37
+ "directory": "packages/mcp"
38
+ },
39
+ "homepage": "https://magnetlab.ai",
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.0.0",
42
+ "commander": "^12.0.0",
43
+ "zod": "^3.23.8"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.0.0",
47
+ "typescript": "^5.0.0"
48
+ },
49
+ "engines": {
50
+ "node": ">=18"
51
+ }
52
+ }