@tempad-dev/mcp 0.9.0 → 0.11.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.
@@ -10,12 +10,13 @@ const MCP_PORT_CANDIDATES = [
10
10
  8127
11
11
  ];
12
12
  const TEMPAD_MCP_BRIDGE_SUBPROTOCOL = "tempad-mcp";
13
- const TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS = [13];
13
+ const TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS = [13, 15];
14
14
  const MCP_MAX_PAYLOAD_BYTES = 4194304;
15
15
  const MCP_TOOL_INLINE_BUDGET_BYTES = 65536;
16
16
  const MCP_APPLY_CANVAS_RUNTIME_BUDGET_BYTES = 2048;
17
17
  const MCP_TOOL_TIMEOUT_MS = 15e3;
18
18
  const MCP_GET_CODE_TIMEOUT_MS = 3e4;
19
+ const MCP_NODE_READ_BATCH_WORK_BUDGET_MS = 1e4;
19
20
  const MCP_GET_DESIGN_SYSTEM_TIMEOUT_MS = 45e3;
20
21
  const MCP_APPLY_CANVAS_TIMEOUT_MS = 12e4;
21
22
  const MCP_AUTO_ACTIVATE_GRACE_MS = 1500;
@@ -25,7 +26,7 @@ const MCP_ASSET_TTL_MS = 2592e6;
25
26
  const MCP_HASH_PATTERN = new RegExp(`^(?:[a-f0-9]{64}|[a-f0-9]{8})$`);
26
27
  const MCP_DESIGN_TASK_LEASE_MS = 3e5;
27
28
  const DesignTaskIdSchema = z.string().min(1).max(128);
28
- const DesignTaskParameterSchema = DesignTaskIdSchema.describe("Task id returned by begin_design. Pass it on every call belonging to that design task; omit for independent reads.").optional();
29
+ const DesignTaskParameterSchema = DesignTaskIdSchema.describe("Task id returned by manage_design_task. Pass it on every call belonging to that design task; omit for independent reads.").optional();
29
30
  const FigmaSessionSchema = z.object({
30
31
  sessionId: z.string().min(1),
31
32
  fileKey: z.string().min(1).max(256),
@@ -88,7 +89,7 @@ const AgentCapabilitiesSchema = z.object({
88
89
  steerDelivery: z.enum(["native", "next-tool"]).optional(),
89
90
  reason: z.string().max(240).optional()
90
91
  }).strict();
91
- const DesignTaskEpochSchema = z.number().int().nonnegative().optional().describe("Lease epoch returned by begin_design or resume_design. Required after resuming; stale epochs cannot write.");
92
+ const DesignTaskEpochSchema = z.number().int().nonnegative().optional().describe("Lease epoch returned by manage_design_task. Required after resuming; stale epochs cannot write.");
92
93
  const MCP_DESIGN_FEEDBACK_MAX_TEXT = 32e3;
93
94
  const FeedbackCommentSchema = z.string().trim().max(8e3);
94
95
  const DesignFeedbackItemSchema = z.object({
@@ -225,6 +226,37 @@ const EndDesignParametersSchema = z.object({
225
226
  outcome: z.enum(["completed", "cancelled"]).default("completed"),
226
227
  summary: z.string().trim().min(1).max(400).optional().describe("Optional brief explanation of the result for the user. Describe applied changes, not a proposal or live progress.")
227
228
  }).strict();
229
+ const FinishDesignParametersSchema = EndDesignParametersSchema.omit({
230
+ taskEpoch: true,
231
+ outcome: true
232
+ }).extend({ epoch: ResumeDesignParametersSchema.shape.epoch });
233
+ const DesignTaskActionSchemas = {
234
+ begin: BeginDesignParametersSchema,
235
+ resume: ResumeDesignParametersSchema,
236
+ complete: FinishDesignParametersSchema,
237
+ cancel: FinishDesignParametersSchema
238
+ };
239
+ const ManageDesignTaskParametersSchema = z.object({
240
+ action: z.enum([
241
+ "begin",
242
+ "resume",
243
+ "complete",
244
+ "cancel"
245
+ ]),
246
+ title: BeginDesignParametersSchema.shape.title.optional().describe("Required for begin."),
247
+ sessionId: BeginDesignParametersSchema.shape.sessionId,
248
+ requestId: BeginDesignParametersSchema.shape.requestId.optional(),
249
+ taskId: DesignTaskIdSchema.optional().describe("Required except for begin."),
250
+ epoch: ResumeDesignParametersSchema.shape.epoch.optional().describe("Required except for begin. Current epoch from the task result or get_design_task."),
251
+ summary: EndDesignParametersSchema.shape.summary
252
+ }).strict().superRefine(({ action, ...args }, context) => {
253
+ const result = DesignTaskActionSchemas[action].safeParse(args);
254
+ if (!result.success) for (const issue of result.error.issues) context.addIssue({
255
+ code: "custom",
256
+ path: issue.path,
257
+ message: issue.message
258
+ });
259
+ });
228
260
  const DesignToolRouteSchema = z.object({
229
261
  sessionId: z.string().min(1),
230
262
  fileKey: z.string().min(1),
@@ -733,6 +765,7 @@ const ToolResultMessageSchema = z.object({
733
765
  const PingMessageSchema = z.object({ type: z.literal("ping") }).strict();
734
766
  const RuntimeHelloMessageSchema = z.object({
735
767
  type: z.literal("runtimeHello"),
768
+ protocolVersion: z.number().int().positive().optional(),
736
769
  extensionVersion: z.string().min(1),
737
770
  extensionRuntimeFingerprint: z.string().regex(/^[a-f0-9]{64}$/)
738
771
  }).strict();
@@ -769,13 +802,14 @@ function measureCallToolResultBytes(result) {
769
802
  return utf8Bytes(result);
770
803
  }
771
804
  function buildGetCodeToolResult(payload) {
805
+ if ("results" in payload) return buildNodeReadBatchToolResult(payload, buildGetCodeToolResult);
772
806
  const summary = [];
773
807
  const codeSize = utf8Bytes(payload.code);
774
808
  summary.push(`Generated \`${payload.lang}\` snippet (${formatBytes(codeSize)}).`);
775
809
  if (payload.warnings?.length) summary.push(...payload.warnings.map((warning) => warning.message));
776
810
  summary.push(payload.assets?.length ? `Assets attached: ${payload.assets.length}. Use asset.localPath directly when present; otherwise download asset.url.` : "No binary assets were attached to this response.");
777
811
  const tokenCount = payload.tokens ? Object.keys(payload.tokens).length : 0;
778
- if (tokenCount) summary.push(`Token references included: ${tokenCount}.`);
812
+ if (tokenCount) summary.push(`Token definitions included: ${tokenCount}.`);
779
813
  summary.push("Read structuredContent for the full code string and metadata.");
780
814
  return buildTextToolResult(summary.join("\n"), payload);
781
815
  }
@@ -818,13 +852,17 @@ function buildGetStructureToolResult(payload) {
818
852
  const nodeCount = countOutlineNodes(payload.roots);
819
853
  const summary = roots === 0 ? "No structure nodes were returned." : `Returned ${payload.truncated ? "a truncated structure outline" : "structure outline"} with ${formatCount(roots, "root")} and ${formatCount(nodeCount, "node")}.`;
820
854
  const guidance = payload.truncated ? "The outline is partial because the response safety cap was reached; narrow the selection or depth before treating it as complete." : "Read structuredContent for the full outline payload.";
821
- return buildTextToolResult(`${summary}${payload.page ? ` Page "${payload.page.name}" (${payload.page.id}) is ${payload.page.active ? "active" : "not active"} with ${formatCount(payload.page.childCount, "child", "children")}.` : ""}\n${guidance}`, payload);
855
+ return {
856
+ ...buildTextToolResult(`${summary}${payload.page ? ` Page "${payload.page.name}" (${payload.page.id}) is ${payload.page.active ? "active" : "not active"} with ${formatCount(payload.page.childCount, "child", "children")}.` : ""}${payload.errors?.length ? ` ${payload.errors.length} root(s) failed; inspect errors.` : ""}\n${guidance}${payload.remainingNodeIds?.length ? " Read omitted roots by passing remainingNodeIds as nodeIds." : ""}`, payload),
857
+ ...!roots && payload.errors?.length && !payload.remainingNodeIds?.length ? { isError: true } : {}
858
+ };
822
859
  }
823
860
  function buildGetTokenDefsToolResult(payload) {
824
861
  const count = Object.keys(payload).length;
825
862
  return buildTextToolResult(`${count === 0 ? "No token definitions were resolved." : `Resolved ${formatCount(count, "token definition")}.`}\nRead structuredContent for token values and aliases.`, payload);
826
863
  }
827
864
  function buildGetScreenshotToolResult(payload) {
865
+ if ("results" in payload) return buildNodeReadBatchToolResult(payload, buildGetScreenshotToolResult);
828
866
  const access = payload.asset.localPath ? `Open the local PNG directly with an image viewer: ${payload.asset.localPath}.` : "Download and open the linked PNG with an image viewer.";
829
867
  return {
830
868
  content: [{
@@ -841,6 +879,26 @@ function buildGetScreenshotToolResult(payload) {
841
879
  structuredContent: payload
842
880
  };
843
881
  }
882
+ function buildNodeReadBatchToolResult(payload, build) {
883
+ const failures = payload.results.filter((entry) => entry.error).length;
884
+ const remaining = payload.remainingNodeIds?.length ?? 0;
885
+ const content = [{
886
+ type: "text",
887
+ text: `Returned ${payload.results.length - failures} node result(s), ${failures} failure(s). Each results entry identifies its exact nodeId.${remaining ? ` ${remaining} node(s) remain; pass remainingNodeIds as nodeIds with the same options to continue.` : ""}`
888
+ }];
889
+ for (const entry of payload.results) {
890
+ content.push({
891
+ type: "text",
892
+ text: `Node ${entry.nodeId}:${entry.error ? ` ${entry.error.code ? `[${entry.error.code}] ` : ""}${entry.error.message}` : ""}`
893
+ });
894
+ if (entry.result !== void 0) content.push(...build(entry.result).content ?? []);
895
+ }
896
+ return {
897
+ content,
898
+ structuredContent: payload,
899
+ ...failures && failures === payload.results.length && !remaining ? { isError: true } : {}
900
+ };
901
+ }
844
902
  function buildGetAssetsToolResult(payload) {
845
903
  const summary = [];
846
904
  summary.push(payload.assets.length ? `Resolved ${formatCount(payload.assets.length, "asset")}.` : "No assets were resolved for the requested hashes.");
@@ -2094,6 +2152,14 @@ const ApplyCanvasResultSchema = z.object({
2094
2152
  path: ["rootRemoved"]
2095
2153
  });
2096
2154
  });
2155
+ const NodeIdParameterSchema = z.string().min(1).describe("Exact single node id. Mutually exclusive with nodeIds.").optional();
2156
+ const NodeIdsParameterSchema = z.array(z.string().min(1)).min(1).describe("Exact node ids in result order; duplicates are read once. Omit both nodeId and nodeIds to snapshot the current selection. Explicit nodeIds always returns per-node results for code and screenshots. Continue remainingNodeIds with another nodeIds call.").optional();
2157
+ function validateNodeTargets(value, context) {
2158
+ if (value.nodeId !== void 0 && value.nodeIds !== void 0) context.addIssue({
2159
+ code: "custom",
2160
+ message: "Use only one of nodeId or nodeIds."
2161
+ });
2162
+ }
2097
2163
  const ExactReadSessionParameterSchema = z.string().min(1).describe("Exact sessionId from list_design_sessions; omit for the active badge target.").optional();
2098
2164
  const AssetDescriptorSchema = z.object({
2099
2165
  hash: z.string().regex(MCP_HASH_PATTERN),
@@ -2112,44 +2178,48 @@ const GetCodeParametersSchema = z.object({
2112
2178
  taskId: DesignTaskParameterSchema,
2113
2179
  taskEpoch: DesignTaskEpochSchema,
2114
2180
  sessionId: ExactReadSessionParameterSchema,
2115
- nodeId: z.string().describe("Optional exact target node id; omit to use the current single selection.").optional(),
2181
+ nodeId: NodeIdParameterSchema,
2182
+ nodeIds: NodeIdsParameterSchema,
2116
2183
  preferredLang: z.enum(["jsx", "vue"]).describe("Preferred output language to bias the snapshot; otherwise uses the design’s hint/detected language, then falls back to JSX.").optional(),
2117
- resolveTokens: z.boolean().describe("Inline token values instead of references for quick renders; default false returns token metadata plus bounded repeated-unbound-color diagnostics so you can reconcile the theming system. When true, values are resolved per-node (mode-aware) and literal diagnostics are omitted.").optional(),
2184
+ resolveTokens: z.boolean().describe("Inline token values in code using each consuming node’s effective modes; default false keeps references and repeated-unbound-color diagnostics. Token metadata always preserves definitions, all modes, and aliases. Failed resolutions keep references and emit warnings. Literal diagnostics are omitted when true.").optional(),
2118
2185
  vectorMode: z.enum(["smart", "snapshot"]).describe("Vector output mode. `smart` (default) emits `<svg data-src=\"...\">` placeholders in code and preserves themeable instance color on the emitted SVG root markup for downstream adaptation; if asset upload fails after export, the tool may inline the SVG as a fallback to preserve source of truth. `snapshot` preserves vector assets for fidelity. Final vector delivery may still be adapted to the Host app’s SVG policy.").optional()
2119
- });
2186
+ }).superRefine(validateNodeTargets);
2120
2187
  const GetTokenDefsParametersSchema = z.object({
2121
2188
  taskId: DesignTaskParameterSchema,
2122
2189
  taskEpoch: DesignTaskEpochSchema,
2123
2190
  sessionId: ExactReadSessionParameterSchema,
2124
- names: z.array(z.string().regex(/^--[a-zA-Z0-9-_]+$/)).min(1).describe("Canonical token names (CSS variable form) from Object.keys(get_code.tokens) or your own list to resolve, e.g., --color-primary."),
2125
- includeAllModes: z.boolean().describe("Include all token modes (light/dark/etc.) instead of just the active one to mirror responsive tokens; default false.").optional()
2191
+ names: z.array(z.string().regex(/^--[a-zA-Z0-9-_]+$/)).min(1).describe("Canonical token names (CSS variable form) from a get_code node result’s tokens or your own list, e.g., --color-primary. Returns definitions with aliases, not consumer-specific resolved values."),
2192
+ includeAllModes: z.boolean().describe("Return all defined modes. Default false uses the collection’s active mode when available, otherwise its default; this lookup has no consuming node context. Aliases are preserved.").optional()
2126
2193
  });
2127
2194
  const GetScreenshotParametersSchema = z.object({
2128
2195
  taskId: DesignTaskParameterSchema,
2129
2196
  taskEpoch: DesignTaskEpochSchema,
2130
2197
  sessionId: ExactReadSessionParameterSchema,
2131
- nodeId: z.string().describe("Optional exact node id to render; omit to use the current single selection.").optional()
2132
- });
2198
+ nodeId: NodeIdParameterSchema,
2199
+ nodeIds: NodeIdsParameterSchema
2200
+ }).superRefine(validateNodeTargets);
2133
2201
  const GetStructureParametersSchema = z.object({
2134
2202
  taskId: DesignTaskParameterSchema,
2135
2203
  taskEpoch: DesignTaskEpochSchema,
2136
2204
  sessionId: ExactReadSessionParameterSchema,
2137
- nodeId: z.string().describe("Optional node id to outline; defaults to the current single selection when no page identity is supplied.").optional(),
2205
+ nodeId: NodeIdParameterSchema,
2206
+ nodeIds: NodeIdsParameterSchema,
2138
2207
  pageId: z.string().min(1).describe("Exact local page id to outline.").optional(),
2139
2208
  pageKey: CanvasStableKeySchema.describe("Exact stable key of a local page authored through apply_canvas.").optional(),
2140
2209
  options: z.object({
2141
- depth: z.number().int().positive().describe("Positive integer; 1 is the shallowest traversal (root plus direct children). Omit for the full tree, subject to safety caps.").optional(),
2210
+ depth: z.number().int().nonnegative().describe("Nonnegative integer; 0 returns exact roots only, 1 includes direct children. Omit for automatic depth, subject to safety caps.").optional(),
2142
2211
  native: z.boolean().describe("Include compact native read-back for masks, IMAGE paint hashes, layout grids, and frame guides.").optional()
2143
2212
  }).strict().optional()
2144
2213
  }).strict().superRefine((value, context) => {
2145
2214
  if ([
2146
2215
  value.nodeId,
2216
+ value.nodeIds,
2147
2217
  value.pageId,
2148
2218
  value.pageKey
2149
2219
  ].filter((identity) => identity !== void 0).length <= 1) return;
2150
2220
  context.addIssue({
2151
2221
  code: "custom",
2152
- message: "Use only one of nodeId, pageId, or pageKey."
2222
+ message: "Use only one of nodeId, nodeIds, pageId, or pageKey."
2153
2223
  });
2154
2224
  });
2155
2225
  const GetDesignSystemParametersSchema = z.object({
@@ -2393,7 +2463,7 @@ function bindRequestMetadata(binding, meta) {
2393
2463
  //#region package.json
2394
2464
  var package_default = {
2395
2465
  name: "@tempad-dev/mcp",
2396
- version: "0.9.0",
2466
+ version: "0.11.0",
2397
2467
  description: "Connect coding agents to Figma for design inspection, native canvas editing, and UI implementation.",
2398
2468
  license: "MIT",
2399
2469
  repository: {
@@ -2431,13 +2501,13 @@ var package_default = {
2431
2501
  },
2432
2502
  devDependencies: {
2433
2503
  "@tempad-dev/shared": "workspace:^0.1.0",
2434
- "@types/node": "^24.13.4",
2504
+ "@types/node": "^24.13.6",
2435
2505
  "@types/proper-lockfile": "^4.1.4",
2436
2506
  "@types/ws": "^8.18.1",
2437
2507
  "tsdown": "^0.23.0",
2438
2508
  "typescript": "^6.0.3",
2439
2509
  "unplugin-raw": "^0.8.0",
2440
- "vitest": "5.0.0"
2510
+ "vitest": "5.0.1"
2441
2511
  },
2442
2512
  engines: { "node": "^22 || ^24 || >=26" }
2443
2513
  };
@@ -2508,6 +2578,6 @@ const log = pino({
2508
2578
  }, prettyTransport);
2509
2579
  const SOCK_PATH = resolveSockPath();
2510
2580
  //#endregion
2511
- export { SetDesignAnchorParametersSchema as $, GetDesignSystemParametersSchema as A, MCP_AUTO_ACTIVATE_GRACE_MS as B, DesignTaskIdSchema as C, GetAssetsParametersSchema as D, FigmaSessionSchema as E, LegacyMessageFromExtensionSchema as F, MCP_MAX_ASSET_STORE_BYTES as G, MCP_GET_CODE_TIMEOUT_MS as H, LegacyToolCallPayloadSchema as I, MCP_TOOL_INLINE_BUDGET_BYTES as J, MCP_MAX_PAYLOAD_BYTES as K, MCP_APPLY_CANVAS_RUNTIME_BUDGET_BYTES as L, GetScreenshotParametersSchema as M, GetStructureParametersSchema as N, GetAssetsResultSchema as O, GetTokenDefsParametersSchema as P, ResumeDesignParametersSchema as Q, MCP_APPLY_CANVAS_TIMEOUT_MS as R, DesignAnchorSchema as S, EndDesignParametersSchema as T, MCP_GET_DESIGN_SYSTEM_TIMEOUT_MS as U, MCP_DESIGN_TASK_LEASE_MS as V, MCP_MAX_ASSET_BYTES as W, MessageFromExtensionSchema as X, MCP_TOOL_TIMEOUT_MS as Y, RESUMABLE_DESIGN_TASK_STATUSES as Z, runtimeIdentity as _, HUB_RUNTIME_IDENTITY_PATH as a, buildApplyCanvasToolResult as at, ApplyCanvasResultSchema as b, RUNTIME_DIR as c, buildGetDesignSystemToolResult as ct, ensureFile as d, buildGetTokenDefsToolResult as dt, TEMPAD_MCP_BRIDGE_SUBPROTOCOL as et, getRecordProperty as f, buildUploadAssetToolResult as ft, clientDescriptor as g, bindRequestMetadata as h, utf8Bytes as ht, HUB_LOCK_UPDATE_MS as i, UploadAssetResultSchema as it, GetDesignSystemResultSchema as j, GetCodeParametersSchema as k, SOCK_PATH as l, buildGetScreenshotToolResult as lt, ClientEventSchema as m, measureCallToolResultBytes as mt, HUB_LOCK_PATH as n, TEMPAD_MCP_ERROR_CODES as nt, LOCK_PATH as o, buildGetAssetsToolResult as ot, log as p, formatDesignFeedback as pt, MCP_PORT_CANDIDATES as q, HUB_LOCK_STALE_MS as r, UploadAssetParametersSchema as rt, PACKAGE_VERSION as s, buildGetCodeToolResult as st, ASSET_DIR as t, TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS as tt, ensureDir as u, buildGetStructureToolResult as ut, AGENT_CLIENTS as v, DesignTaskSchema as w, BeginDesignParametersSchema as x, ApplyCanvasParametersSchema as y, MCP_ASSET_TTL_MS as z };
2581
+ export { TEMPAD_MCP_BRIDGE_SUBPROTOCOL as $, GetScreenshotParametersSchema as A, MCP_GET_CODE_TIMEOUT_MS as B, DesignTaskSchema as C, GetCodeParametersSchema as D, GetAssetsResultSchema as E, MCP_APPLY_CANVAS_RUNTIME_BUDGET_BYTES as F, MCP_NODE_READ_BATCH_WORK_BUDGET_MS as G, MCP_MAX_ASSET_BYTES as H, MCP_APPLY_CANVAS_TIMEOUT_MS as I, MCP_TOOL_TIMEOUT_MS as J, MCP_PORT_CANDIDATES as K, MCP_ASSET_TTL_MS as L, GetTokenDefsParametersSchema as M, LegacyMessageFromExtensionSchema as N, GetDesignSystemParametersSchema as O, LegacyToolCallPayloadSchema as P, SetDesignAnchorParametersSchema as Q, MCP_AUTO_ACTIVATE_GRACE_MS as R, DesignTaskIdSchema as S, GetAssetsParametersSchema as T, MCP_MAX_ASSET_STORE_BYTES as U, MCP_GET_DESIGN_SYSTEM_TIMEOUT_MS as V, MCP_MAX_PAYLOAD_BYTES as W, MessageFromExtensionSchema as X, ManageDesignTaskParametersSchema as Y, RESUMABLE_DESIGN_TASK_STATUSES as Z, runtimeIdentity as _, HUB_RUNTIME_IDENTITY_PATH as a, buildGetAssetsToolResult as at, ApplyCanvasResultSchema as b, RUNTIME_DIR as c, buildGetScreenshotToolResult as ct, ensureFile as d, buildUploadAssetToolResult as dt, TEMPAD_MCP_BRIDGE_SUPPORTED_PROTOCOL_VERSIONS as et, getRecordProperty as f, formatDesignFeedback as ft, clientDescriptor as g, bindRequestMetadata as h, HUB_LOCK_UPDATE_MS as i, buildApplyCanvasToolResult as it, GetStructureParametersSchema as j, GetDesignSystemResultSchema as k, SOCK_PATH as l, buildGetStructureToolResult as lt, ClientEventSchema as m, utf8Bytes as mt, HUB_LOCK_PATH as n, UploadAssetParametersSchema as nt, LOCK_PATH as o, buildGetCodeToolResult as ot, log as p, measureCallToolResultBytes as pt, MCP_TOOL_INLINE_BUDGET_BYTES as q, HUB_LOCK_STALE_MS as r, UploadAssetResultSchema as rt, PACKAGE_VERSION as s, buildGetDesignSystemToolResult as st, ASSET_DIR as t, TEMPAD_MCP_ERROR_CODES as tt, ensureDir as u, buildGetTokenDefsToolResult as ut, AGENT_CLIENTS as v, FigmaSessionSchema as w, DesignAnchorSchema as x, ApplyCanvasParametersSchema as y, MCP_DESIGN_TASK_LEASE_MS as z };
2512
2582
 
2513
- //# sourceMappingURL=shared-8rz2qWXn.mjs.map
2583
+ //# sourceMappingURL=shared-FHsVNIOk.mjs.map