@clipform/mcp-server 5.4.0 → 5.5.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.
package/README.md CHANGED
@@ -76,7 +76,7 @@ Your MCP client lists these automatically on connect (via `tools/list`). Full re
76
76
  | `clipform_attach_node_media` | Attach an existing workspace media asset (from clipform_upload_media_asset) to one or more nodes (max 10). |
77
77
  | `clipform_get_node_media` | Get the media attached to a node, including processing status. |
78
78
  | `clipform_delete_node_media` | Remove media from a node by unlinking it; the media asset and its files stay in the workspace library and keep working on any other node or live form that uses them. |
79
- | `clipform_set_logic` | Set the next node for one or more nodes, wiring a linear route (A to B to C). |
79
+ | `clipform_set_logic` | Set where one or more nodes go next. |
80
80
  | `clipform_log_generation` | Internal audit step run by a form-generation workflow. |
81
81
  | `clipform_search_news` | Search recent news articles from NewsAPI and The Guardian and return them as structured results. |
82
82
  | `clipform_generate_tts` | Generate narration audio from text with word-level captions for one question in a Clipform form (max 400 characters). |
@@ -6,7 +6,7 @@ import {
6
6
  recoveryHint,
7
7
  structuredResult,
8
8
  textResult
9
- } from "./chunk-42DEGWIU.js";
9
+ } from "./chunk-QT2M5FQQ.js";
10
10
  import "./chunk-ENVV65JX.js";
11
11
  import "./chunk-PBQ5BQWD.js";
12
12
  import "./chunk-PZ5AY32C.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FULL_CAPS,
3
3
  getSessionContextWithAuth
4
- } from "./chunk-6HTNG4QA.js";
4
+ } from "./chunk-G7FS2BAC.js";
5
5
  import {
6
6
  FORM_TYPES,
7
7
  MAX_CLIP_SECONDS,
@@ -10,7 +10,7 @@ import {
10
10
  WORKFLOW_TYPES,
11
11
  exposedCompositionIds,
12
12
  getDiscoveryParams
13
- } from "./chunk-42DEGWIU.js";
13
+ } from "./chunk-QT2M5FQQ.js";
14
14
  import {
15
15
  __export
16
16
  } from "./chunk-PZ5AY32C.js";
@@ -15259,4 +15259,4 @@ export {
15259
15259
  getWorkflowText,
15260
15260
  registerPrompts
15261
15261
  };
15262
- //# sourceMappingURL=chunk-M6AWVKPK.js.map
15262
+ //# sourceMappingURL=chunk-5EQGV5VF.js.map
@@ -2,7 +2,7 @@ import {
2
2
  CURRENT_PLAN_VERSIONS,
3
3
  PLAN_LIMITS,
4
4
  callApi
5
- } from "./chunk-42DEGWIU.js";
5
+ } from "./chunk-QT2M5FQQ.js";
6
6
  import {
7
7
  getMcpAuth
8
8
  } from "./chunk-ENVV65JX.js";
@@ -145,4 +145,4 @@ export {
145
145
  getSessionContextWithAuth,
146
146
  getSessionContext
147
147
  };
148
- //# sourceMappingURL=chunk-6HTNG4QA.js.map
148
+ //# sourceMappingURL=chunk-G7FS2BAC.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  FULL_CAPS,
3
3
  getSessionContext
4
- } from "./chunk-6HTNG4QA.js";
4
+ } from "./chunk-G7FS2BAC.js";
5
5
  import {
6
6
  ALL_VARIANTS,
7
7
  FORM_TYPES,
8
8
  FORM_TYPE_KEYS,
9
9
  callApi
10
- } from "./chunk-42DEGWIU.js";
10
+ } from "./chunk-QT2M5FQQ.js";
11
11
  import {
12
12
  getMcpAuth
13
13
  } from "./chunk-ENVV65JX.js";
@@ -146,4 +146,4 @@ export {
146
146
  getGuideUri,
147
147
  registerResources
148
148
  };
149
- //# sourceMappingURL=chunk-C2NKMZ4Q.js.map
149
+ //# sourceMappingURL=chunk-HHSHBFJD.js.map
@@ -31,7 +31,7 @@ import {
31
31
  union,
32
32
  unknown,
33
33
  url
34
- } from "./chunk-M6AWVKPK.js";
34
+ } from "./chunk-5EQGV5VF.js";
35
35
  import {
36
36
  GUIDE_TYPES,
37
37
  QUIZ_VARIANTS,
@@ -40,7 +40,7 @@ import {
40
40
  getGuideUri,
41
41
  guideFallbackText,
42
42
  registerResources
43
- } from "./chunk-C2NKMZ4Q.js";
43
+ } from "./chunk-HHSHBFJD.js";
44
44
  import {
45
45
  ANON_PREVIEW_LINK_LABEL,
46
46
  ANON_PREVIEW_NOTICE,
@@ -54,16 +54,18 @@ import {
54
54
  isPreviewViewerUrl,
55
55
  previewOnlyNotice,
56
56
  withAdoptedNotice
57
- } from "./chunk-6HTNG4QA.js";
57
+ } from "./chunk-G7FS2BAC.js";
58
58
  import {
59
59
  ACTIVE_NODE_TYPES,
60
60
  ANON_MCP_BLOCKED_NODE_TYPES,
61
61
  ANON_MCP_LIVE_TTL_DAYS,
62
62
  ANON_MCP_RESPONSE_CAP,
63
+ CHOICE_MAX_OPTIONS,
63
64
  CONTACT_FIELDS,
64
65
  FEATURE_FLAGS,
65
66
  FORM_TYPES_LIST,
66
67
  FORM_TYPE_ALIASES,
68
+ LOGIC_TARGET_TYPES,
67
69
  MAX_CLIP_SECONDS,
68
70
  MAX_NARRATION_CHARS,
69
71
  MCP_TOOL_SECURITY,
@@ -82,6 +84,10 @@ import {
82
84
  gatedEnumValues,
83
85
  isAnonMcpLockedNode,
84
86
  isAnonymousAccountRequired,
87
+ isInactiveOptionEdge,
88
+ isNodeLevelAction,
89
+ isOptionEdge,
90
+ isTerminalType,
85
91
  lettersCapError,
86
92
  normalizeContactFields,
87
93
  recallDisplayText,
@@ -89,7 +95,7 @@ import {
89
95
  stripGatedConfigKeys,
90
96
  structuredResult,
91
97
  textResult
92
- } from "./chunk-42DEGWIU.js";
98
+ } from "./chunk-QT2M5FQQ.js";
93
99
  import {
94
100
  getMcpAuth,
95
101
  runWithMcpAuth,
@@ -16227,7 +16233,7 @@ var CaptionSchema = external_exports.object({
16227
16233
  });
16228
16234
  var OptionSchema = external_exports.object({
16229
16235
  content: external_exports.string().describe("Option text"),
16230
- is_correct: external_exports.boolean().optional().describe("Mark this as the correct answer for a quiz (maps to score 1; other options score 0). Use this OR score, not both."),
16236
+ is_correct: external_exports.boolean().optional().describe("Mark this option as a correct answer for a quiz. Stored as the answer key; when score is not given it also sets score 1 (or 0 on the others)."),
16231
16237
  score: external_exports.number().optional().describe("Score value for this option (for scored quizzes). Use 1 for correct, 0 for wrong. Scored options automatically enable correct-answer marking (record_scores) and correct/incorrect answer feedback on the node; set config.choice.show_answer_feedback: false to hide the feedback."),
16232
16238
  // `scores` (category-based) is gated behind custom_scores (planned, #767) -
16233
16239
  // omitted from the schema while off so the MCP doesn't accept a not-live field.
@@ -16331,7 +16337,6 @@ function applyNodeDefaults(node, rng2 = Math.random) {
16331
16337
  if (o.score == null && typeof o.is_correct === "boolean") {
16332
16338
  o.score = o.is_correct ? 1 : 0;
16333
16339
  }
16334
- delete o.is_correct;
16335
16340
  }
16336
16341
  }
16337
16342
  const supportsRecordScores = def?.config_schema?.properties?.choice?.properties?.record_scores !== void 0;
@@ -17123,6 +17128,19 @@ function projectNext(node, logicByNode) {
17123
17128
  const target = defaultTarget(logicByNode.get(node.id));
17124
17129
  return target ? { target_id: target.value, target_type: target.type } : void 0;
17125
17130
  }
17131
+ function projectAnswerRoutes(node, logicByNode) {
17132
+ const options = node.node_options ?? node.options ?? [];
17133
+ const targetByOption = /* @__PURE__ */ new Map();
17134
+ for (const action of logicByNode.get(node.id) ?? []) {
17135
+ if (!isOptionEdge(action) || isInactiveOptionEdge(node, action) || !action.details?.to) continue;
17136
+ const optionId = action.option_id ?? action.condition.vars.find((v) => v.type === "option")?.value;
17137
+ if (optionId && !targetByOption.has(optionId)) targetByOption.set(optionId, action.details.to);
17138
+ }
17139
+ return options.flatMap((o) => {
17140
+ const to = targetByOption.get(o.id);
17141
+ return to ? [{ option_id: o.id, option_content: o.content, target_id: to.value, target_type: to.type }] : [];
17142
+ });
17143
+ }
17126
17144
  function projectFormState(data) {
17127
17145
  const { nodes, logicByNode } = orderNodesWithLogic(data);
17128
17146
  const urls = projectUrls(data);
@@ -17193,21 +17211,32 @@ function formatFormState(data) {
17193
17211
  ` Options: ${options.map((o) => o.id ? `${o.content} (id: ${o.id})` : o.content).join(", ")}`
17194
17212
  );
17195
17213
  }
17214
+ const routes = projectAnswerRoutes(q, logicByNode);
17196
17215
  const next = projectNext(q, logicByNode);
17197
- if (next) {
17198
- lines.push(` -> next: ${next.target_id} (${next.target_type})`);
17216
+ if (routes.length === 0) {
17217
+ if (next) lines.push(` -> next: ${next.target_id} (${next.target_type})`);
17218
+ } else {
17219
+ const fallback = (logicByNode.get(q.id) ?? []).find((a) => isNodeLevelAction(a, q.id))?.details?.to;
17220
+ lines.push(` Routes by answer:`);
17221
+ for (const o of options ?? []) {
17222
+ const r = routes.find((route) => route.option_id === o.id);
17223
+ if (r) lines.push(` "${r.option_content}" -> ${r.target_id} (${r.target_type})`);
17224
+ else if (fallback) lines.push(` "${o.content}" -> ${fallback.value} (${fallback.type}, default route)`);
17225
+ else lines.push(` "${o.content}" -> NO ROUTE (add a rule for this answer or a default rule, or publishing fails)`);
17226
+ }
17199
17227
  }
17200
17228
  }
17201
17229
  return lines.join("\n");
17202
17230
  }
17203
17231
 
17204
17232
  // src/tools/get-form.ts
17233
+ var TargetTypeSchema = external_exports.enum(LOGIC_TARGET_TYPES);
17205
17234
  function registerGetFormTool(server) {
17206
17235
  server.registerTool(
17207
17236
  "clipform_get_form",
17208
17237
  {
17209
17238
  title: "Get Clipform",
17210
- description: `Retrieve a form's details including all nodes in sequential order and their routing. Returns title, settings, and every node with its options, config, media status, and next node (from clipform_set_logic).`,
17239
+ description: `Retrieve a form's details including all nodes in sequential order and their routing. Returns title, settings, and every node with its options, config, media status, next node, and - for a node that routes by answer - each answer's route (all set with clipform_set_logic).`,
17211
17240
  inputSchema: external_exports.object({
17212
17241
  form_id: external_exports.string().uuid().describe("The form UUID (returned by clipform_create_form, not the short share_id from the URL)")
17213
17242
  }),
@@ -17236,8 +17265,20 @@ function registerGetFormTool(server) {
17236
17265
  options: external_exports.array(external_exports.object({ id: external_exports.string(), content: external_exports.string() })).optional(),
17237
17266
  next: external_exports.object({
17238
17267
  target_id: external_exports.string().describe("The node/screen ID this node routes to"),
17239
- target_type: external_exports.enum(["node", "end_screen", "redirect", "link_list"]).describe("What kind of target target_id is")
17240
- }).optional().describe("This node's outgoing edge, set via clipform_set_logic. Omitted for a chain tail or terminal node.")
17268
+ target_type: TargetTypeSchema.describe("What kind of target target_id is")
17269
+ }).optional().describe("This node's outgoing edge, set via clipform_set_logic. Omitted for a chain tail or terminal node."),
17270
+ // Declared ahead of emission (#4839): the ChatGPT-approved schema is
17271
+ // additionalProperties:false, so routes stay text-only until a Rescan
17272
+ // approves this field (#4845, SUBMISSION.md). Then emit it from
17273
+ // projectFormState.
17274
+ routes: external_exports.array(
17275
+ external_exports.object({
17276
+ option_id: external_exports.string(),
17277
+ option_content: external_exports.string().describe("The answer's text"),
17278
+ target_id: external_exports.string().describe("The node/screen ID this answer routes to"),
17279
+ target_type: TargetTypeSchema
17280
+ })
17281
+ ).optional().describe("Each answer's own route, for a node that routes by answer")
17241
17282
  })
17242
17283
  ).describe("Nodes in sequential order - IDs for update_node / attach_node_media")
17243
17284
  }),
@@ -17962,12 +18003,15 @@ function registerAddNodeTool(server) {
17962
18003
  "clipform_add_node",
17963
18004
  {
17964
18005
  title: "Add Node",
17965
- description: `Add a new node to an existing form. Inserted before the end screen by default; after_node_id controls insertion position. Inserting into a linear flow automatically re-links the chain (the node before the insertion point points to the new node, which points to what followed) - you do not need clipform_set_logic for a simple insert. Branching still needs an explicit logic write. Node types and config schemas match clipform_create_form.`,
18006
+ description: `Add a new node to an existing form. Inserted before the end screen by default; after_node_id controls insertion position. Inserting into a linear flow automatically re-links the chain (the node before the insertion point points to the new node, which points to what followed) - you do not need clipform_set_logic for a simple insert. For a second ending that only some answers reach (an end screen or redirect), pass unlinked: true and then route to it with clipform_set_logic. Node types and config schemas match clipform_create_form.`,
17966
18007
  inputSchema: external_exports.object({
17967
18008
  form_id: external_exports.string().uuid().describe("The form UUID (returned by clipform_create_form, not the short share_id from the URL)"),
17968
18009
  node: NodeSchema.describe("The node to add"),
17969
18010
  after_node_id: external_exports.string().optional().describe(
17970
- "Insert after this node ID. Omit to append before the end screen."
18011
+ "Insert after this node ID. Omit to append before the end screen. Not used with unlinked."
18012
+ ),
18013
+ unlinked: external_exports.boolean().optional().describe(
18014
+ "Create an ending (end_screen or redirect) outside the flow, so nothing routes to it until you point an answer at it with clipform_set_logic. Only for ending types: a question added this way would sit outside the flow."
17971
18015
  )
17972
18016
  }),
17973
18017
  outputSchema: external_exports.object({
@@ -17981,11 +18025,20 @@ function registerAddNodeTool(server) {
17981
18025
  openWorldHint: false
17982
18026
  }
17983
18027
  },
17984
- async ({ form_id, node, after_node_id }) => {
18028
+ async ({ form_id, node, after_node_id, unlinked }) => {
18029
+ if (unlinked && after_node_id) {
18030
+ return errorResult("Pass either after_node_id (insert into the flow) or unlinked: true (outside the flow), not both.");
18031
+ }
18032
+ if (unlinked && !isTerminalType(node.type)) {
18033
+ return errorResult(
18034
+ `unlinked is only for an ending (end_screen or redirect), not ${node.type}. To give one answer its own question, insert it into the flow with after_node_id, then route answers with clipform_set_logic.`
18035
+ );
18036
+ }
17985
18037
  applyNodeDefaults(node);
17986
18038
  const droppedKeys = stripGatedNodeConfig(node);
17987
18039
  const body = { node };
17988
18040
  if (after_node_id) body.after_node_id = after_node_id;
18041
+ if (unlinked) body.auto_arrange = false;
17989
18042
  const result = await callApi(`/forms/${form_id}/nodes`, {
17990
18043
  method: "POST",
17991
18044
  body
@@ -17995,7 +18048,7 @@ function registerAddNodeTool(server) {
17995
18048
  }
17996
18049
  const nodeId = result.data.node_id;
17997
18050
  const warnings = result.data.warnings ?? [];
17998
- const relinkNote = warnings.length > 0 ? ` ${warnings.join(" ")}` : " The logic chain was automatically re-linked - no clipform_set_logic call is needed for this insert.";
18051
+ const relinkNote = unlinked ? " It is not linked into the flow: route an answer to it with clipform_set_logic (option_content)." : warnings.length > 0 ? ` ${warnings.join(" ")}` : " The logic chain was automatically re-linked - no clipform_set_logic call is needed for this insert.";
17999
18052
  return structuredResult(
18000
18053
  `Node added. ID: ${nodeId} | Type: ${node.type}.${relinkNote}${droppedKeys.length > 0 ? ` ${ignoredConfigNote(droppedKeys)}` : ""}`,
18001
18054
  { node_id: nodeId, type: node.type }
@@ -18647,25 +18700,51 @@ function registerDeleteNodeMediaTool(server) {
18647
18700
 
18648
18701
  // src/tools/set-node-logic.ts
18649
18702
  var LogicRuleSchema = external_exports.object({
18650
- target_node_id: external_exports.string().describe("The node ID this node routes to")
18703
+ target_node_id: external_exports.string().describe("The node ID this route goes to: any other node, including an end screen"),
18704
+ option_content: external_exports.string().optional().describe(
18705
+ "Route only this answer: the option's text exactly as clipform_get_form lists it, without the (id: ...) suffix. Omit for the node's default route, which covers every current answer without a rule of its own."
18706
+ )
18651
18707
  });
18652
18708
  var NodeLogicSchema = external_exports.object({
18653
18709
  node_id: external_exports.string().describe("The node ID to set routing on"),
18654
- rules: external_exports.array(LogicRuleSchema).min(1).max(1).describe("Exactly one rule: the single node this node routes to")
18710
+ rules: external_exports.array(LogicRuleSchema).min(1).max(CHOICE_MAX_OPTIONS + 1).describe(
18711
+ "One rule without option_content for a single next node, or one rule per answer (option_content) plus an optional default rule"
18712
+ )
18655
18713
  });
18714
+ function ruleSetError(rules) {
18715
+ const defaults = rules.filter((r) => !r.option_content).length;
18716
+ if (defaults > 1) return "more than one rule without option_content - give one default route at most";
18717
+ const seen = /* @__PURE__ */ new Set();
18718
+ for (const r of rules) {
18719
+ if (!r.option_content) continue;
18720
+ if (seen.has(r.option_content)) return `two rules for the answer "${r.option_content}" - give each answer one route`;
18721
+ seen.add(r.option_content);
18722
+ }
18723
+ return null;
18724
+ }
18656
18725
  function registerSetNodeLogicTool(server) {
18657
18726
  server.registerTool(
18658
18727
  "clipform_set_logic",
18659
18728
  {
18660
18729
  title: "Set Node Logic",
18661
- description: `Set the next node for one or more nodes, wiring a linear route (A to B to C). Pass multiple nodes in one call instead of separate tool calls. Each node routes to exactly one target node. Branching by which option a respondent picks is not configured here; it is set up in the form's Build tab in the dashboard (the builder URL returned by clipform_get_form / clipform_create_form).
18730
+ description: `Set where one or more nodes go next. Pass multiple nodes in one call instead of separate tool calls.
18731
+
18732
+ - Linear: one rule with only target_node_id (A to B to C).
18733
+ - By answer: on a single-select choice node with branching on, give one rule per answer with option_content set to the option's text, plus an optional default rule without option_content. Every answer needs a route: one with no rule of its own and no default has nowhere to go, and publishing fails. Different answers can go to different nodes or end screens. A multi-select choice has one route out, so answer rules are refused there.
18662
18734
 
18663
- A call replaces that node's routing entirely - it does not merge with any prior target.
18735
+ Turning branching on: set config.choice.enable_branching: true in clipform_create_form, or with clipform_update_node. update_node replaces the whole choice object, so send the node's full current choice config from clipform_get_form with enable_branching added - a choice object with only enable_branching drops quiz settings such as record_scores.
18736
+
18737
+ A second ending that only some answers reach is added with clipform_add_node and unlinked: true.
18738
+
18739
+ A call replaces that node's routing entirely - it does not merge with any prior target. A default rule covers the answers that exist now; an answer added later needs its own rule. clipform_get_form shows each answer's route afterwards, and flags any answer with no route.
18664
18740
 
18665
18741
  Example:
18666
18742
  nodes: [
18667
18743
  { node_id: "q1-id", rules: [{ target_node_id: "q2-id" }] },
18668
- { node_id: "q2-id", rules: [{ target_node_id: "q3-id" }] }
18744
+ { node_id: "country-id", rules: [
18745
+ { option_content: "United Kingdom", target_node_id: "video-id" },
18746
+ { option_content: "Somewhere else", target_node_id: "sorry-end-id" }
18747
+ ] }
18669
18748
  ]`,
18670
18749
  inputSchema: external_exports.object({
18671
18750
  form_id: external_exports.string().uuid().describe("The form UUID (returned by clipform_create_form, not the short share_id from the URL)"),
@@ -18694,6 +18773,12 @@ Example:
18694
18773
  const allLines = [];
18695
18774
  const results = [];
18696
18775
  for (const { node_id, rules } of nodes) {
18776
+ const invalid = ruleSetError(rules);
18777
+ if (invalid) {
18778
+ allLines.push(`Node ${node_id}: FAILED - ${invalid}`);
18779
+ results.push({ node_id, ok: false, error: invalid });
18780
+ continue;
18781
+ }
18697
18782
  const result = await callApi(
18698
18783
  `/forms/${form_id}/nodes/${node_id}/logic/rules`,
18699
18784
  {
@@ -18710,10 +18795,13 @@ Example:
18710
18795
  allLines.push(`Node ${node_id}: logic set (${rulesCount} rules)`);
18711
18796
  results.push({ node_id, ok: true, rules_count: rulesCount });
18712
18797
  }
18713
- if (results.some((r) => r.ok)) {
18798
+ const routedByAnswer = nodes.some(
18799
+ (n, i) => results[i]?.ok && n.rules.some((r) => r.option_content)
18800
+ );
18801
+ if (routedByAnswer) {
18714
18802
  allLines.push(
18715
18803
  `
18716
- To branch by which option a respondent picks (not yet supported here), open the form's Build tab in the dashboard - use the builder URL from clipform_get_form or clipform_create_form.`
18804
+ Routes by answer are set. Call clipform_get_form to check each answer's route; it also says whether a live form needs republishing.`
18717
18805
  );
18718
18806
  }
18719
18807
  return structuredResult(allLines.join("\n"), { results });
@@ -20521,4 +20609,4 @@ export {
20521
20609
  * MIT Licensed
20522
20610
  *)
20523
20611
  */
20524
- //# sourceMappingURL=chunk-MQTISSLP.js.map
20612
+ //# sourceMappingURL=chunk-IZKDVBG7.js.map