@clipform/mcp-server 2.10.2 → 2.10.3

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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * What a connected surface can actually do, derived from the connect-time
3
+ * toolset filter (#3309) so the guidance layers (server instructions, prompt
4
+ * recipes, `clipform_get_workflow`, craft guides) never reference a tool the
5
+ * surface doesn't register (#3681).
6
+ *
7
+ * The Claude Connectors Directory surface (`mcp.clipform.io/forms`) is
8
+ * account + forms only: no media generation and no research helpers. A
9
+ * workflow that still says "call clipform_generate_tts" there sends the model
10
+ * at a tool that doesn't exist, which shows up in review as failed tool
11
+ * calls. Every guidance producer takes a ServerCaps and gates on it.
12
+ */
13
+ interface ServerCaps {
14
+ /** Narration, video, image, music, render, and asset tools are registered. */
15
+ media: boolean;
16
+ /** News lookup and the generation audit log are registered. */
17
+ research: boolean;
18
+ }
19
+
20
+ export type { ServerCaps as S };
@@ -2,9 +2,10 @@ import {
2
2
  ALL_VARIANTS,
3
3
  FORM_TYPES,
4
4
  FORM_TYPE_KEYS,
5
+ FULL_CAPS,
5
6
  callApi,
6
7
  getSessionContext
7
- } from "./chunk-IL26A4IN.js";
8
+ } from "./chunk-O35IVA4L.js";
8
9
 
9
10
  // src/lib/guides.ts
10
11
  var guidesPromise = null;
@@ -42,6 +43,14 @@ function guideFallbackText(uri) {
42
43
  `forms tight - every question must earn its place.`
43
44
  ].join("\n");
44
45
  }
46
+ function applyCapsToGuide(text, caps) {
47
+ if (caps.media) return text;
48
+ return [
49
+ "> **This connection exposes form-building tools only** - no narration, video, image, or music tools. Where this guide mentions narration, media, or rendering, skip that part and carry the same craft into the written question text.",
50
+ "",
51
+ text
52
+ ].join("\n");
53
+ }
45
54
 
46
55
  // src/resources.ts
47
56
  var GUIDE_TYPES = FORM_TYPE_KEYS;
@@ -62,10 +71,10 @@ function getGuideUri(type, variant) {
62
71
  }
63
72
  return `clipform://guides/${type}`;
64
73
  }
65
- async function readGuide(uri) {
66
- return await fetchGuideText(uri) ?? guideFallbackText(uri);
74
+ async function readGuide(uri, caps) {
75
+ return applyCapsToGuide(await fetchGuideText(uri) ?? guideFallbackText(uri), caps);
67
76
  }
68
- function registerResources(server) {
77
+ function registerResources(server, caps = FULL_CAPS) {
69
78
  for (const type of GUIDE_TYPES) {
70
79
  server.registerResource(
71
80
  `guide-${type}`,
@@ -79,7 +88,7 @@ function registerResources(server) {
79
88
  contents: [{
80
89
  uri: getGuideUri(type),
81
90
  mimeType: "text/markdown",
82
- text: await readGuide(getGuideUri(type))
91
+ text: await readGuide(getGuideUri(type), caps)
83
92
  }]
84
93
  })
85
94
  );
@@ -97,7 +106,7 @@ function registerResources(server) {
97
106
  contents: [{
98
107
  uri: getGuideUri("quiz", variant),
99
108
  mimeType: "text/markdown",
100
- text: await readGuide(getGuideUri("quiz", variant))
109
+ text: await readGuide(getGuideUri("quiz", variant), caps)
101
110
  }]
102
111
  })
103
112
  );
@@ -128,9 +137,10 @@ function registerResources(server) {
128
137
  export {
129
138
  fetchGuideText,
130
139
  guideFallbackText,
140
+ applyCapsToGuide,
131
141
  GUIDE_TYPES,
132
142
  QUIZ_VARIANTS,
133
143
  getGuideUri,
134
144
  registerResources
135
145
  };
136
- //# sourceMappingURL=chunk-UBJ7CZL2.js.map
146
+ //# sourceMappingURL=chunk-A5RVUIGS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/guides.ts","../src/resources.ts"],"sourcesContent":["import { callApi } from \"./api-client.js\";\nimport type { ServerCaps } from \"./caps.js\";\n\n/**\n * Craft guide bodies live server-side (#470) - the npm package is a shim\n * that fetches them at runtime instead of bundling them in the tarball.\n * One fetch per process (all ~30KB of guides in a single response), cached;\n * a failed fetch is NOT cached so the next read retries.\n */\n\nexport interface RemoteGuide {\n type: string;\n variant: string | null;\n uri: string;\n mimeType: string;\n text: string;\n}\n\nlet guidesPromise: Promise<Map<string, RemoteGuide>> | null = null;\n\nasync function loadGuides(): Promise<Map<string, RemoteGuide>> {\n const result = await callApi(\"/internal/mcp/guides\", { method: \"GET\" });\n if (!result.ok) {\n throw new Error(`Failed to load guides: ${result.error}`);\n }\n const guides = (result.data as { guides?: RemoteGuide[] }).guides ?? [];\n return new Map(guides.map((g) => [g.uri, g]));\n}\n\n/** Fetch a guide body by its clipform:// URI. Returns null when unavailable. */\nexport async function fetchGuideText(uri: string): Promise<string | null> {\n if (!guidesPromise) {\n guidesPromise = loadGuides();\n }\n try {\n const guides = await guidesPromise;\n return guides.get(uri)?.text ?? null;\n } catch (err) {\n guidesPromise = null; // don't cache failures - retry on the next read\n // Loud, not silent: a misconfigured API_URL/key otherwise degrades every\n // guide to the stub with nothing in the logs.\n console.error(`[guides] Failed to fetch ${uri}: ${err instanceof Error ? err.message : String(err)}`);\n return null;\n }\n}\n\n/** Shown in place of a guide when the API is unreachable or unauthenticated. */\nexport function guideFallbackText(uri: string): string {\n return [\n `# Guide unavailable`,\n ``,\n `The craft guide (${uri}) could not be loaded from the Clipform API.`,\n `Guides are served at runtime and need a reachable API with a valid key -`,\n `check API_URL and CLIPFORM_API_KEY, then try again.`,\n ``,\n `General principles in the meantime: write narration for the ear (short,`,\n `conversational), never reveal answers in narration or media, and keep`,\n `forms tight - every question must earn its place.`,\n ].join(\"\\n\");\n}\n\n/**\n * Craft guide bodies are written for the full tool surface and mention the\n * narration/video tools by name. On a surface that doesn't register them\n * (the Claude Connectors Directory resource, #3681) prefix the guide with a\n * note so the model doesn't chase tools it can't call. The body itself is\n * untouched - the craft (question design, pacing) is the same either way.\n */\nexport function applyCapsToGuide(text: string, caps: ServerCaps): string {\n if (caps.media) return text;\n return [\n \"> **This connection exposes form-building tools only** - no narration, video, image, or music tools. Where this guide mentions narration, media, or rendering, skip that part and carry the same craft into the written question text.\",\n \"\",\n text,\n ].join(\"\\n\");\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { getSessionContext } from \"./lib/session-context.js\";\nimport { FORM_TYPE_KEYS, FORM_TYPES, ALL_VARIANTS } from \"@vid-master/config\";\n\nexport const GUIDE_TYPES = FORM_TYPE_KEYS as readonly string[] as readonly [string, ...string[]];\nexport type GuideType = (typeof FORM_TYPE_KEYS)[number];\n\nexport const QUIZ_VARIANTS = ALL_VARIANTS as readonly string[] as readonly [string, ...string[]];\nexport type QuizVariant = (typeof ALL_VARIANTS)[number];\n// Guide BODIES are not bundled here (#470): the npm tarball ships only this\n// registration metadata. Text is fetched from the API at runtime - see\n// lib/guides.ts (cached per process, stub fallback when unreachable).\nimport { fetchGuideText, guideFallbackText, applyCapsToGuide } from \"./lib/guides.js\";\nimport { FULL_CAPS, type ServerCaps } from \"./lib/caps.js\";\n\nconst GUIDE_DESCRIPTIONS: Record<GuideType, string> = {\n \"quiz\": \"Craft knowledge for writing engaging quizzes - difficulty curves, question psychology, narration style, scoring\",\n \"survey\": \"Craft knowledge for feedback surveys, NPS, and research forms - brevity, rating scales, respondent fatigue\",\n \"interview\": \"Craft knowledge for building interview forms - warm-up pacing, open questions, consent, video responses\",\n \"funnel\": \"Craft knowledge for lead qualification funnels - planned feature, conditional routing coming soon\",\n \"testimonial\": \"Craft knowledge for collecting testimonials and customer stories on video - storytelling prompts, comfort techniques, consent\",\n \"application\": \"Craft knowledge for application and evaluation forms - multi-section structure, video responses for behavioural questions, screening\",\n \"booking\": \"Craft knowledge for event registration and booking forms - minimal friction, video welcome, confirmation flow\",\n};\n\n// Sourced from config (single source of truth) so the agent-facing resource\n// descriptions can't drift from FORM_TYPES.quiz.variant_descriptions (#2534,\n// the exact pair packages/config/CLAUDE.md warns about).\nconst QUIZ_VARIANT_DESCRIPTIONS = FORM_TYPES.quiz.variant_descriptions;\n\nexport function getGuideUri(type: GuideType, variant?: QuizVariant): string {\n if (type === \"quiz\" && variant) {\n return `clipform://guides/quiz/${variant}`;\n }\n return `clipform://guides/${type}`;\n}\n\nasync function readGuide(uri: string, caps: ServerCaps): Promise<string> {\n return applyCapsToGuide((await fetchGuideText(uri)) ?? guideFallbackText(uri), caps);\n}\n\nexport function registerResources(server: McpServer, caps: ServerCaps = FULL_CAPS) {\n for (const type of GUIDE_TYPES) {\n server.registerResource(\n `guide-${type}`,\n getGuideUri(type),\n {\n description: GUIDE_DESCRIPTIONS[type],\n mimeType: \"text/markdown\",\n annotations: { audience: [\"assistant\" as const], priority: 0.8 },\n },\n async () => ({\n contents: [{\n uri: getGuideUri(type),\n mimeType: \"text/markdown\",\n text: await readGuide(getGuideUri(type), caps),\n }],\n }),\n );\n }\n\n for (const variant of QUIZ_VARIANTS) {\n server.registerResource(\n `guide-quiz-${variant}`,\n getGuideUri(\"quiz\", variant),\n {\n description: QUIZ_VARIANT_DESCRIPTIONS[variant],\n mimeType: \"text/markdown\",\n annotations: { audience: [\"assistant\" as const], priority: 0.8 },\n },\n async () => ({\n contents: [{\n uri: getGuideUri(\"quiz\", variant),\n mimeType: \"text/markdown\",\n text: await readGuide(getGuideUri(\"quiz\", variant), caps),\n }],\n }),\n );\n }\n\n server.registerResource(\n \"context-session\",\n \"clipform://context/session\",\n {\n description:\n \"Current session info: auth mode, workspace name, plan name, and node/form limits. Read this before planning content to know your constraints.\",\n mimeType: \"text/markdown\",\n annotations: { audience: [\"assistant\"], priority: 1.0 },\n },\n async () => {\n const text = await getSessionContext();\n return {\n contents: [\n {\n uri: \"clipform://context/session\",\n mimeType: \"text/markdown\",\n text: text || \"Session context unavailable - API may not be reachable.\",\n },\n ],\n };\n }\n );\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAI,gBAA0D;AAE9D,eAAe,aAAgD;AAC7D,QAAM,SAAS,MAAM,QAAQ,wBAAwB,EAAE,QAAQ,MAAM,CAAC;AACtE,MAAI,CAAC,OAAO,IAAI;AACd,UAAM,IAAI,MAAM,0BAA0B,OAAO,KAAK,EAAE;AAAA,EAC1D;AACA,QAAM,SAAU,OAAO,KAAoC,UAAU,CAAC;AACtE,SAAO,IAAI,IAAI,OAAO,IAAI,CAAC,MAA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oami: "account",
2695
2695
  clipform_get_results: "account",
2696
2696
  clipform_get_responses: "account",
2697
- // forms: form/node structure + research tools used while building.
2697
+ // forms: form/node structure + craft guidance used while building.
2698
2698
  clipform_create_form: "forms",
2699
2699
  clipform_import_form: "forms",
2700
2700
  clipform_add_node: "forms",
@@ -2704,10 +2704,12 @@ var MCP_TOOL_TOOLSETS = {
2704
2704
  clipform_set_logic: "forms",
2705
2705
  clipform_get_guide: "forms",
2706
2706
  clipform_get_workflow: "forms",
2707
- clipform_search_news: "forms",
2708
- clipform_fetch_boundary: "forms",
2709
- clipform_log_generation: "forms",
2710
- // media: creative/render/asset tools.
2707
+ // research: third-party content lookup + generation-workflow audit.
2708
+ clipform_search_news: "research",
2709
+ clipform_log_generation: "research",
2710
+ // media: creative/render/asset tools. fetch_boundary only feeds the Map
2711
+ // composition's `boundary` prop, so it lives with the render tools.
2712
+ clipform_fetch_boundary: "media",
2711
2713
  clipform_generate_tts: "media",
2712
2714
  clipform_generate_video: "media",
2713
2715
  clipform_render_composition: "media",
@@ -2725,6 +2727,16 @@ var MCP_TOOL_TOOLSETS = {
2725
2727
  clipform_list_video_templates: "media"
2726
2728
  };
2727
2729
 
2730
+ // src/lib/caps.ts
2731
+ var FULL_CAPS = Object.freeze({ media: true, research: true });
2732
+ function capsFromToolsets(toolsets) {
2733
+ if (toolsets === void 0) return FULL_CAPS;
2734
+ return {
2735
+ media: toolsets.includes("media"),
2736
+ research: toolsets.includes("research")
2737
+ };
2738
+ }
2739
+
2728
2740
  // src/lib/api-client.ts
2729
2741
  function getApiBaseUrl() {
2730
2742
  const url = process.env.API_URL;
@@ -2930,6 +2942,8 @@ export {
2930
2942
  exposedCompositionIds,
2931
2943
  MCP_TOOL_TIERS,
2932
2944
  MCP_TOOL_TOOLSETS,
2945
+ FULL_CAPS,
2946
+ capsFromToolsets,
2933
2947
  callApi,
2934
2948
  errorResult,
2935
2949
  textResult,
@@ -2937,4 +2951,4 @@ export {
2937
2951
  getSessionContextWithAuth,
2938
2952
  getSessionContext
2939
2953
  };
2940
- //# sourceMappingURL=chunk-IL26A4IN.js.map
2954
+ //# sourceMappingURL=chunk-O35IVA4L.js.map