@addai/flows-mcp 0.2.0 → 0.3.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 (74) hide show
  1. package/README.md +13 -0
  2. package/dist/bin/install.js +53 -0
  3. package/dist/bin/install.js.map +1 -1
  4. package/dist/client.d.ts +2 -0
  5. package/dist/client.js +20 -2
  6. package/dist/client.js.map +1 -1
  7. package/dist/healing.d.ts +9 -0
  8. package/dist/healing.js +104 -0
  9. package/dist/healing.js.map +1 -0
  10. package/dist/index.js +6 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/instructions.d.ts +6 -0
  13. package/dist/instructions.js +149 -0
  14. package/dist/instructions.js.map +1 -0
  15. package/dist/node-defaults.js +395 -46
  16. package/dist/node-defaults.js.map +1 -1
  17. package/dist/prompts.d.ts +2 -0
  18. package/dist/prompts.js +741 -0
  19. package/dist/prompts.js.map +1 -0
  20. package/dist/tools/custom-nodes.js +14 -9
  21. package/dist/tools/custom-nodes.js.map +1 -1
  22. package/dist/tools/flows.js +36 -35
  23. package/dist/tools/flows.js.map +1 -1
  24. package/dist/tools/nodes.js +17 -7
  25. package/dist/tools/nodes.js.map +1 -1
  26. package/dist/tools/preview.d.ts +3 -0
  27. package/dist/tools/preview.js +85 -0
  28. package/dist/tools/preview.js.map +1 -0
  29. package/dist/tools/reference.js +8 -5
  30. package/dist/tools/reference.js.map +1 -1
  31. package/dist/tools/runs.js +112 -1
  32. package/dist/tools/runs.js.map +1 -1
  33. package/dist/tools/variables.js +1 -1
  34. package/dist/tools/variables.js.map +1 -1
  35. package/dist/types.d.ts +13 -0
  36. package/dist/validation/enums.d.ts +20 -0
  37. package/dist/validation/enums.js +36 -0
  38. package/dist/validation/enums.js.map +1 -0
  39. package/dist/validation/handles.d.ts +2 -0
  40. package/dist/validation/handles.js +88 -0
  41. package/dist/validation/handles.js.map +1 -0
  42. package/dist/validation/index.d.ts +3 -0
  43. package/dist/validation/index.js +47 -0
  44. package/dist/validation/index.js.map +1 -0
  45. package/dist/validation/nested-ids.d.ts +2 -0
  46. package/dist/validation/nested-ids.js +55 -0
  47. package/dist/validation/nested-ids.js.map +1 -0
  48. package/dist/validation/reachability.d.ts +2 -0
  49. package/dist/validation/reachability.js +62 -0
  50. package/dist/validation/reachability.js.map +1 -0
  51. package/dist/validation/references.d.ts +2 -0
  52. package/dist/validation/references.js +107 -0
  53. package/dist/validation/references.js.map +1 -0
  54. package/dist/validation/shape-rules.d.ts +7 -0
  55. package/dist/validation/shape-rules.js +284 -0
  56. package/dist/validation/shape-rules.js.map +1 -0
  57. package/dist/validation/shape.d.ts +2 -0
  58. package/dist/validation/shape.js +47 -0
  59. package/dist/validation/shape.js.map +1 -0
  60. package/dist/validation/structure.d.ts +2 -0
  61. package/dist/validation/structure.js +137 -0
  62. package/dist/validation/structure.js.map +1 -0
  63. package/dist/validation/syntax.d.ts +2 -0
  64. package/dist/validation/syntax.js +69 -0
  65. package/dist/validation/syntax.js.map +1 -0
  66. package/dist/validation/types.d.ts +49 -0
  67. package/dist/validation/types.js +2 -0
  68. package/dist/validation/types.js.map +1 -0
  69. package/package.json +15 -4
  70. package/skill/SKILL.md +116 -0
  71. package/skill/anti-patterns.md +207 -0
  72. package/skill/node-cheatsheet.md +37 -0
  73. package/skill/recipes.md +308 -0
  74. package/skill/version.txt +1 -0
@@ -0,0 +1,308 @@
1
+ # Flow Recipes — Copy-Paste Working Patterns
2
+
3
+ Each recipe shows the exact tool calls in order. After step 2 of the workflow (study node types), follow the recipe.
4
+
5
+ ---
6
+
7
+ ## Recipe 1: Webhook → If → HTTP Request → Goal/Exit
8
+
9
+ ```
10
+ create_flow({ name: "Order Router", trigger_type: "trigger" })
11
+ // → { id: "flow-id", nodes: [{ id: "trigger-id", type: "trigger" }] }
12
+
13
+ add_nodes({
14
+ flow_id: "flow-id",
15
+ nodes: [
16
+ { type: "if", temp_id: "check", data: {
17
+ conditions: [{
18
+ id: crypto.randomUUID(),
19
+ leftValue: "{{trigger-id.body.total}}",
20
+ operator: "greater_than",
21
+ rightValue: "100",
22
+ dataType: "number"
23
+ }],
24
+ conditionLogic: "and"
25
+ }},
26
+ { type: "httpRequest", temp_id: "fulfill", data: {
27
+ url: "https://api.fulfillment.com/orders",
28
+ method: "POST",
29
+ bodyType: "json",
30
+ body: '{"id": "{{trigger-id.body.id}}"}',
31
+ authentication: { type: "bearer", token: "{{Variables.apiKey}}" }
32
+ }},
33
+ { type: "goal", temp_id: "ok", data: { goalName: "fulfilled" } },
34
+ { type: "exit", temp_id: "low", data: { exitName: "below_threshold" } }
35
+ ],
36
+ edges: [
37
+ { source: "trigger-id", target: "check" },
38
+ { source: "check", target: "fulfill", source_handle: "true" },
39
+ { source: "check", target: "low", source_handle: "false" },
40
+ { source: "fulfill", target: "ok" }
41
+ ]
42
+ })
43
+
44
+ validate_flow({ flow_id: "flow-id" })
45
+ test_flow({ flow_id: "flow-id", input_data: { total: 150, id: "ord-123" } })
46
+ publish_flow({ flow_id: "flow-id" })
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Recipe 2: Public Start-Form Page → Map → Respond
52
+
53
+ ```
54
+ create_flow({ name: "Signup", trigger_type: "trigger" })
55
+ // Remove the default webhook trigger, use a start-form page instead
56
+ get_flow({ flow_id: "flow-id" })
57
+ remove_nodes({ flow_id: "flow-id", node_ids: ["trigger-id"] })
58
+
59
+ add_nodes({
60
+ flow_id: "flow-id",
61
+ nodes: [
62
+ { type: "page", temp_id: "form", data: {
63
+ isStartForm: true,
64
+ formSlug: "signup",
65
+ elements: [
66
+ { id: crypto.randomUUID(), type: "shortText", label: "Name", required: true },
67
+ { id: crypto.randomUUID(), type: "email", label: "Email", required: true }
68
+ ]
69
+ }},
70
+ { type: "map", temp_id: "transform", data: {
71
+ mappings: [
72
+ { id: crypto.randomUUID(), inputExpression: "{{form.submissionData.Name}}",
73
+ outputName: "display_name", transformType: "trim", enabled: true },
74
+ { id: crypto.randomUUID(), inputExpression: "{{form.submissionData.Email}}",
75
+ outputName: "email_lower", transformType: "lowercase", enabled: true }
76
+ ]
77
+ }},
78
+ { type: "goal", temp_id: "done", data: { goalName: "signed_up" } }
79
+ ],
80
+ edges: [
81
+ { source: "form", target: "transform", source_handle: "right" },
82
+ { source: "transform", target: "done" }
83
+ ]
84
+ })
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Recipe 3: Schedule → Loop → Variable Increment → Goal
90
+
91
+ ```
92
+ set_variable({ flow_id: "flow-id", name: "processed_count", type: "number", default_value: 0 })
93
+
94
+ add_nodes({
95
+ flow_id: "flow-id",
96
+ nodes: [
97
+ { type: "httpRequest", temp_id: "fetch", data: {
98
+ url: "https://api.x/pending-items", method: "GET"
99
+ }},
100
+ { type: "loop", temp_id: "each", data: {
101
+ arraySources: ["{{fetch.body.items}}"]
102
+ }},
103
+ { type: "variable", temp_id: "bump", data: {
104
+ action: "update", variableName: "processed_count", operator: "add", value: "1"
105
+ }},
106
+ { type: "goal", temp_id: "done", data: { goalName: "batch_complete" } }
107
+ ],
108
+ edges: [
109
+ { source: "schedule-trigger-id", target: "fetch" },
110
+ { source: "fetch", target: "each" },
111
+ { source: "each", target: "bump", source_handle: "loop" },
112
+ { source: "each", target: "done", source_handle: "done" }
113
+ ]
114
+ })
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Recipe 4: Email Trigger → Code (parse) → Switch → Branches
120
+
121
+ ```
122
+ create_flow({ name: "Support Router", trigger_type: "emailTrigger" })
123
+
124
+ add_nodes({
125
+ flow_id: "flow-id",
126
+ nodes: [
127
+ { type: "code", temp_id: "parse", data: {
128
+ mode: "runOnce",
129
+ code: `
130
+ const email = $("email-trigger-id");
131
+ const body = email.text || "";
132
+ const isUrgent = /urgent|asap|emergency/i.test(body);
133
+ const category = body.toLowerCase().includes("billing") ? "billing"
134
+ : body.toLowerCase().includes("bug") ? "bug"
135
+ : "general";
136
+ return { isUrgent, category };
137
+ `
138
+ }},
139
+ { type: "switch", temp_id: "route", data: {
140
+ mode: "first",
141
+ hasDefault: true,
142
+ cases: [
143
+ { id: crypto.randomUUID(), outputLabel: "case-billing", logicOperator: "AND", enabled: true,
144
+ conditions: [{ id: crypto.randomUUID(), leftValue: "{{parse.category}}",
145
+ operator: "equals", rightValue: "billing", dataType: "string" }] },
146
+ { id: crypto.randomUUID(), outputLabel: "case-bug", logicOperator: "AND", enabled: true,
147
+ conditions: [{ id: crypto.randomUUID(), leftValue: "{{parse.category}}",
148
+ operator: "equals", rightValue: "bug", dataType: "string" }] }
149
+ ]
150
+ }}
151
+ // + downstream nodes for each branch...
152
+ ],
153
+ edges: [
154
+ { source: "email-trigger-id", target: "parse" },
155
+ { source: "parse", target: "route" }
156
+ // edges from route with source_handle: "case-billing" / "case-bug" / "default"
157
+ ]
158
+ })
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Recipe 5: Table Trigger → Review → Approved/Rejected → HTTP
164
+
165
+ ```
166
+ add_nodes({
167
+ flow_id: "flow-id",
168
+ nodes: [
169
+ { type: "review", temp_id: "approval", data: {
170
+ title: "New row needs approval",
171
+ description: "Review the row data and approve or reject",
172
+ fields: [
173
+ { id: crypto.randomUUID(), label: "Requested by", value: "{{table-trigger-id.row.requester}}" },
174
+ { id: crypto.randomUUID(), label: "Amount", value: "{{table-trigger-id.row.amount}}" }
175
+ ],
176
+ options: [
177
+ { id: "option_0", label: "Approve", color: "green" },
178
+ { id: "option_1", label: "Reject", color: "red" }
179
+ ]
180
+ }},
181
+ { type: "httpRequest", temp_id: "approve-api", data: {
182
+ url: "https://api.x/approve/{{table-trigger-id.rowId}}", method: "POST"
183
+ }},
184
+ { type: "goal", temp_id: "ok", data: { goalName: "approved" } },
185
+ { type: "exit", temp_id: "no", data: { exitName: "rejected" } }
186
+ ],
187
+ edges: [
188
+ { source: "table-trigger-id", target: "approval" },
189
+ { source: "approval", target: "approve-api", source_handle: "option_0" },
190
+ { source: "approval", target: "no", source_handle: "option_1" },
191
+ { source: "approve-api", target: "ok" }
192
+ ]
193
+ })
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Recipe 6: HTTP → Code (filter) → SplitTest → Two Variants
199
+
200
+ ```
201
+ add_nodes({
202
+ flow_id: "flow-id",
203
+ nodes: [
204
+ { type: "httpRequest", temp_id: "fetch", data: {
205
+ url: "https://api.x/users", method: "GET"
206
+ }},
207
+ { type: "code", temp_id: "filter", data: {
208
+ mode: "runOnce",
209
+ code: `
210
+ const res = $("fetch");
211
+ const active = (res.body.users || []).filter(u => u.active);
212
+ return { users: active, count: active.length };
213
+ `
214
+ }},
215
+ { type: "splitTest", temp_id: "variant", data: {
216
+ variants: [
217
+ { id: crypto.randomUUID(), label: "Variant A", percentage: 50 },
218
+ { id: crypto.randomUUID(), label: "Variant B", percentage: 50 }
219
+ ]
220
+ }},
221
+ { type: "httpRequest", temp_id: "notify-a", data: {
222
+ url: "https://api.x/notify/a", method: "POST",
223
+ bodyType: "json", body: '{"count": "{{filter.count}}"}'
224
+ }},
225
+ { type: "httpRequest", temp_id: "notify-b", data: {
226
+ url: "https://api.x/notify/b", method: "POST",
227
+ bodyType: "json", body: '{"count": "{{filter.count}}"}'
228
+ }}
229
+ ],
230
+ edges: [
231
+ { source: "trigger-id", target: "fetch" },
232
+ { source: "fetch", target: "filter" },
233
+ { source: "filter", target: "variant" },
234
+ { source: "variant", target: "notify-a", source_handle: "Variant A" },
235
+ { source: "variant", target: "notify-b", source_handle: "Variant B" }
236
+ ]
237
+ })
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Recipe 7: Webhook → Wait → Sub-flow → Goal
243
+
244
+ ```
245
+ add_nodes({
246
+ flow_id: "flow-id",
247
+ nodes: [
248
+ { type: "wait", temp_id: "pause", data: {
249
+ waitType: "duration", duration: 10, durationUnit: "minutes"
250
+ }},
251
+ { type: "flow", temp_id: "sub", data: {
252
+ flowId: "child-flow-id",
253
+ flowName: "Send Reminder",
254
+ waitForCompletion: true,
255
+ body: '{"email": "{{trigger-id.body.email}}"}'
256
+ }},
257
+ { type: "goal", temp_id: "done", data: { goalName: "reminder_sent" } }
258
+ ],
259
+ edges: [
260
+ { source: "trigger-id", target: "pause" },
261
+ { source: "pause", target: "sub" },
262
+ { source: "sub", target: "done" }
263
+ ]
264
+ })
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Recipe 8: Page (mid-flow) → Review → Map → Respond
270
+
271
+ ```
272
+ add_nodes({
273
+ flow_id: "flow-id",
274
+ nodes: [
275
+ { type: "page", temp_id: "form", data: {
276
+ elements: [
277
+ { id: crypto.randomUUID(), type: "longText", label: "Feedback", required: true }
278
+ ]
279
+ }},
280
+ { type: "review", temp_id: "check", data: {
281
+ title: "Review submitted feedback",
282
+ fields: [{ id: crypto.randomUUID(), label: "Feedback", value: "{{form.submissionData.Feedback}}" }],
283
+ options: [
284
+ { id: "option_0", label: "Publish", color: "green" },
285
+ { id: "option_1", label: "Spam", color: "red" }
286
+ ]
287
+ }},
288
+ { type: "map", temp_id: "prep", data: {
289
+ mappings: [
290
+ { id: crypto.randomUUID(), inputExpression: "{{form.submissionData.Feedback}}",
291
+ outputName: "trimmed", transformType: "trim", enabled: true }
292
+ ]
293
+ }},
294
+ { type: "respondToWebhook", temp_id: "resp", data: {
295
+ statusCode: 200, bodyType: "json",
296
+ responseBody: '{"status":"published","content":"{{prep.trimmed}}"}'
297
+ }},
298
+ { type: "exit", temp_id: "spam", data: { exitName: "rejected" } }
299
+ ],
300
+ edges: [
301
+ { source: "trigger-id", target: "form" },
302
+ { source: "form", target: "check", source_handle: "right" },
303
+ { source: "check", target: "prep", source_handle: "option_0" },
304
+ { source: "check", target: "spam", source_handle: "option_1" },
305
+ { source: "prep", target: "resp" }
306
+ ]
307
+ })
308
+ ```
@@ -0,0 +1 @@
1
+ 0.3.0