@clipform/mcp-server 4.1.0 → 4.2.1

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.
@@ -6,7 +6,7 @@ import {
6
6
  recoveryHint,
7
7
  structuredResult,
8
8
  textResult
9
- } from "./chunk-4IAURGG7.js";
9
+ } from "./chunk-GZZGKW5A.js";
10
10
  import "./chunk-VPF6MLKM.js";
11
11
  import "./chunk-PBQ5BQWD.js";
12
12
  import "./chunk-PZ5AY32C.js";
@@ -29,7 +29,7 @@ import {
29
29
  union,
30
30
  unknown,
31
31
  url
32
- } from "./chunk-5RUWQOYD.js";
32
+ } from "./chunk-QG354AVT.js";
33
33
  import {
34
34
  GUIDE_TYPES,
35
35
  QUIZ_VARIANTS,
@@ -38,13 +38,13 @@ import {
38
38
  getGuideUri,
39
39
  guideFallbackText,
40
40
  registerResources
41
- } from "./chunk-TXUWAYBZ.js";
41
+ } from "./chunk-RKMGVU57.js";
42
42
  import {
43
43
  ANON_PREVIEW_NOTICE,
44
44
  FULL_CAPS,
45
45
  anonPreviewNotice,
46
46
  capsFromToolsets
47
- } from "./chunk-PDI6VJYQ.js";
47
+ } from "./chunk-O4LOUBGW.js";
48
48
  import {
49
49
  ACTIVE_NODE_TYPES,
50
50
  CONTACT_FIELDS,
@@ -66,7 +66,7 @@ import {
66
66
  resolveFormType,
67
67
  structuredResult,
68
68
  textResult
69
- } from "./chunk-4IAURGG7.js";
69
+ } from "./chunk-GZZGKW5A.js";
70
70
  import {
71
71
  getMcpAuth,
72
72
  runWithMcpAuth,
@@ -4774,6 +4774,37 @@ var inputRequired = Object.assign(buildInputRequired, {
4774
4774
  return { method: "roots/list" };
4775
4775
  }
4776
4776
  });
4777
+ function acceptedContent(responses, key, schema) {
4778
+ const view = inputResponse(responses, key);
4779
+ if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
4780
+ if (schema === void 0) return view.content;
4781
+ const outcome = schema["~standard"].validate(view.content);
4782
+ if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
4783
+ return outcome.issues === void 0 ? outcome.value : void 0;
4784
+ }
4785
+ function inputResponse(responses, key) {
4786
+ if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
4787
+ const entry = responses[key];
4788
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
4789
+ const candidate = entry;
4790
+ if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
4791
+ const content = candidate["content"];
4792
+ return {
4793
+ kind: "elicit",
4794
+ action: candidate["action"],
4795
+ ...content !== null && typeof content === "object" && !Array.isArray(content) && { content }
4796
+ };
4797
+ }
4798
+ if (Array.isArray(candidate["roots"])) return {
4799
+ kind: "roots",
4800
+ roots: candidate["roots"]
4801
+ };
4802
+ if (typeof candidate["role"] === "string" && candidate["content"] !== void 0) return {
4803
+ kind: "sampling",
4804
+ result: candidate
4805
+ };
4806
+ return { kind: "missing" };
4807
+ }
4777
4808
  var REQUEST_STATE_ONLY_LEG_PACING_MS = 250;
4778
4809
  function inputRequiredRoundsExceededMessage(method, maxRounds) {
4779
4810
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
@@ -17179,23 +17210,42 @@ ${anonNotice}`;
17179
17210
 
17180
17211
  // src/lib/confirm.ts
17181
17212
  var CONFIRM_FIELD_DESCRIPTION = "Set to true ONLY after the user has explicitly confirmed this destructive action. Leave unset otherwise - hosts that support confirmation dialogs will prompt the user automatically.";
17182
- async function confirmDestructive(server, opts) {
17213
+ var CONFIRM_RESPONSE_SCHEMA = external_exports.object({ confirm: external_exports.boolean() });
17214
+ var CANCELLED = "Cancelled - nothing was changed.";
17215
+ async function confirmDestructive(server, ctx, opts) {
17183
17216
  if (opts.alreadyConfirmed === true) return { proceed: true };
17217
+ const mcpReq = ctx?.mcpReq;
17218
+ const responses = mcpReq?.inputResponses;
17219
+ if (responses && responses.confirm !== void 0) {
17220
+ const answer = acceptedContent(responses, "confirm", CONFIRM_RESPONSE_SCHEMA);
17221
+ if (answer?.confirm === true) return { proceed: true };
17222
+ return { proceed: false, message: CANCELLED };
17223
+ }
17224
+ const requestedSchema = {
17225
+ type: "object",
17226
+ properties: {
17227
+ confirm: { type: "boolean", title: "Confirm", description: opts.message }
17228
+ },
17229
+ required: ["confirm"]
17230
+ };
17231
+ const envelope = mcpReq?.envelope;
17232
+ if (envelope) {
17233
+ if (envelope["io.modelcontextprotocol/clientCapabilities"]?.elicitation) {
17234
+ return {
17235
+ proceed: false,
17236
+ result: inputRequired({
17237
+ inputRequests: { confirm: inputRequired.elicit({ message: opts.message, requestedSchema }) }
17238
+ })
17239
+ };
17240
+ }
17241
+ return { proceed: false, message: opts.relay };
17242
+ }
17184
17243
  const lowLevel = server.server;
17185
17244
  const caps = lowLevel?.getClientCapabilities?.();
17186
17245
  if (caps?.elicitation) {
17187
- const r = await lowLevel.elicitInput({
17188
- message: opts.message,
17189
- requestedSchema: {
17190
- type: "object",
17191
- properties: {
17192
- confirm: { type: "boolean", title: "Confirm", description: opts.message }
17193
- },
17194
- required: ["confirm"]
17195
- }
17196
- });
17246
+ const r = await lowLevel.elicitInput({ message: opts.message, requestedSchema });
17197
17247
  if (r.action === "accept" && r.content?.confirm === true) return { proceed: true };
17198
- return { proceed: false, message: "Cancelled - nothing was changed." };
17248
+ return { proceed: false, message: CANCELLED };
17199
17249
  }
17200
17250
  return { proceed: false, message: opts.relay };
17201
17251
  }
@@ -17223,14 +17273,14 @@ function registerDeleteFormTool(server) {
17223
17273
  openWorldHint: true
17224
17274
  }
17225
17275
  },
17226
- async ({ form_id, confirm }) => {
17227
- const decision = await confirmDestructive(server, {
17276
+ async ({ form_id, confirm }, ctx) => {
17277
+ const decision = await confirmDestructive(server, ctx, {
17228
17278
  alreadyConfirmed: confirm,
17229
17279
  message: `Move form ${form_id} to the trash? It stops accepting responses immediately and can be restored later.`,
17230
17280
  relay: `Confirmation required: moving form ${form_id} to the trash stops it accepting responses immediately. It can be restored later. Ask the user to confirm, then call clipform_delete_form again with confirm: true.`
17231
17281
  });
17232
17282
  if (!decision.proceed) {
17233
- return textResult(decision.message);
17283
+ return decision.result ?? textResult(decision.message);
17234
17284
  }
17235
17285
  const result = await callApi(`/forms/${form_id}`, {
17236
17286
  method: "DELETE"
@@ -17797,14 +17847,14 @@ function registerDeleteNodeTool(server) {
17797
17847
  openWorldHint: false
17798
17848
  }
17799
17849
  },
17800
- async ({ form_id, node_id, confirm }) => {
17801
- const decision = await confirmDestructive(server, {
17850
+ async ({ form_id, node_id, confirm }, ctx) => {
17851
+ const decision = await confirmDestructive(server, ctx, {
17802
17852
  alreadyConfirmed: confirm,
17803
17853
  message: `Delete node ${node_id} from this form? This cannot be undone.`,
17804
17854
  relay: `Confirmation required: deleting node ${node_id} cannot be undone. Ask the user to confirm, then call clipform_delete_node again with confirm: true.`
17805
17855
  });
17806
17856
  if (!decision.proceed) {
17807
- return textResult(decision.message);
17857
+ return decision.result ?? textResult(decision.message);
17808
17858
  }
17809
17859
  const result = await callApi(
17810
17860
  `/forms/${form_id}/nodes/${node_id}`,
@@ -18290,14 +18340,14 @@ function registerDeleteNodeMediaTool(server) {
18290
18340
  openWorldHint: true
18291
18341
  }
18292
18342
  },
18293
- async ({ form_id, node_id, confirm }) => {
18294
- const decision = await confirmDestructive(server, {
18343
+ async ({ form_id, node_id, confirm }, ctx) => {
18344
+ const decision = await confirmDestructive(server, ctx, {
18295
18345
  alreadyConfirmed: confirm,
18296
18346
  message: `Remove the media attached to node ${node_id}? This deletes the underlying video/file and cannot be undone.`,
18297
18347
  relay: `Confirmation required: removing media from node ${node_id} deletes the underlying video/file and cannot be undone. Ask the user to confirm, then call clipform_delete_node_media again with confirm: true.`
18298
18348
  });
18299
18349
  if (!decision.proceed) {
18300
- return textResult(decision.message);
18350
+ return decision.result ?? textResult(decision.message);
18301
18351
  }
18302
18352
  const result = await callApi(
18303
18353
  `/forms/${form_id}/nodes/${node_id}/media`,
@@ -19903,10 +19953,19 @@ Optional args by type:
19903
19953
  var __dirname = dirname(fileURLToPath(import.meta.url));
19904
19954
  var pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
19905
19955
  var MCP_VERSION = pkg.version;
19956
+ var serverJson = JSON.parse(readFileSync(join(__dirname, "..", "server.json"), "utf-8"));
19906
19957
  var MCP_SERVER_IDENTITY = Object.freeze({
19907
- name: "clipform-mcp-server",
19958
+ name: serverJson.name,
19908
19959
  version: MCP_VERSION
19909
19960
  });
19961
+ var MCP_SERVER_CARD_IDENTITY = Object.freeze({
19962
+ name: serverJson.name,
19963
+ title: serverJson.title,
19964
+ description: serverJson.description,
19965
+ websiteUrl: serverJson.websiteUrl,
19966
+ icons: serverJson.icons,
19967
+ repository: serverJson.repository
19968
+ });
19910
19969
  function buildInstructions(caps) {
19911
19970
  return [
19912
19971
  buildOnboardingOffer(),
@@ -20067,6 +20126,7 @@ function createServer(options) {
20067
20126
  }
20068
20127
 
20069
20128
  export {
20129
+ SUPPORTED_PROTOCOL_VERSIONS,
20070
20130
  ReadBuffer,
20071
20131
  serializeMessage,
20072
20132
  process2 as process,
@@ -20074,6 +20134,7 @@ export {
20074
20134
  createMcpHandler,
20075
20135
  RENDER_TIMING,
20076
20136
  MCP_SERVER_IDENTITY,
20137
+ MCP_SERVER_CARD_IDENTITY,
20077
20138
  buildInstructions,
20078
20139
  createServer
20079
20140
  };
@@ -20086,4 +20147,4 @@ export {
20086
20147
  * MIT Licensed
20087
20148
  *)
20088
20149
  */
20089
- //# sourceMappingURL=chunk-5A66GD3U.js.map
20150
+ //# sourceMappingURL=chunk-BKTCQ5HS.js.map