@tempad-dev/mcp 0.10.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.
- package/README.md +20 -4
- package/README.zh-Hans.md +16 -3
- package/dist/cli.mjs +1 -1
- package/dist/hub.mjs +86 -31
- package/dist/hub.mjs.map +1 -1
- package/dist/{shared-Dh112Muy.mjs → shared-FHsVNIOk.mjs} +57 -18
- package/dist/shared-FHsVNIOk.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/shared-Dh112Muy.mjs.map +0 -1
|
@@ -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;
|
|
@@ -764,6 +765,7 @@ const ToolResultMessageSchema = z.object({
|
|
|
764
765
|
const PingMessageSchema = z.object({ type: z.literal("ping") }).strict();
|
|
765
766
|
const RuntimeHelloMessageSchema = z.object({
|
|
766
767
|
type: z.literal("runtimeHello"),
|
|
768
|
+
protocolVersion: z.number().int().positive().optional(),
|
|
767
769
|
extensionVersion: z.string().min(1),
|
|
768
770
|
extensionRuntimeFingerprint: z.string().regex(/^[a-f0-9]{64}$/)
|
|
769
771
|
}).strict();
|
|
@@ -800,13 +802,14 @@ function measureCallToolResultBytes(result) {
|
|
|
800
802
|
return utf8Bytes(result);
|
|
801
803
|
}
|
|
802
804
|
function buildGetCodeToolResult(payload) {
|
|
805
|
+
if ("results" in payload) return buildNodeReadBatchToolResult(payload, buildGetCodeToolResult);
|
|
803
806
|
const summary = [];
|
|
804
807
|
const codeSize = utf8Bytes(payload.code);
|
|
805
808
|
summary.push(`Generated \`${payload.lang}\` snippet (${formatBytes(codeSize)}).`);
|
|
806
809
|
if (payload.warnings?.length) summary.push(...payload.warnings.map((warning) => warning.message));
|
|
807
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.");
|
|
808
811
|
const tokenCount = payload.tokens ? Object.keys(payload.tokens).length : 0;
|
|
809
|
-
if (tokenCount) summary.push(`Token
|
|
812
|
+
if (tokenCount) summary.push(`Token definitions included: ${tokenCount}.`);
|
|
810
813
|
summary.push("Read structuredContent for the full code string and metadata.");
|
|
811
814
|
return buildTextToolResult(summary.join("\n"), payload);
|
|
812
815
|
}
|
|
@@ -849,13 +852,17 @@ function buildGetStructureToolResult(payload) {
|
|
|
849
852
|
const nodeCount = countOutlineNodes(payload.roots);
|
|
850
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")}.`;
|
|
851
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.";
|
|
852
|
-
return
|
|
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
|
+
};
|
|
853
859
|
}
|
|
854
860
|
function buildGetTokenDefsToolResult(payload) {
|
|
855
861
|
const count = Object.keys(payload).length;
|
|
856
862
|
return buildTextToolResult(`${count === 0 ? "No token definitions were resolved." : `Resolved ${formatCount(count, "token definition")}.`}\nRead structuredContent for token values and aliases.`, payload);
|
|
857
863
|
}
|
|
858
864
|
function buildGetScreenshotToolResult(payload) {
|
|
865
|
+
if ("results" in payload) return buildNodeReadBatchToolResult(payload, buildGetScreenshotToolResult);
|
|
859
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.";
|
|
860
867
|
return {
|
|
861
868
|
content: [{
|
|
@@ -872,6 +879,26 @@ function buildGetScreenshotToolResult(payload) {
|
|
|
872
879
|
structuredContent: payload
|
|
873
880
|
};
|
|
874
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
|
+
}
|
|
875
902
|
function buildGetAssetsToolResult(payload) {
|
|
876
903
|
const summary = [];
|
|
877
904
|
summary.push(payload.assets.length ? `Resolved ${formatCount(payload.assets.length, "asset")}.` : "No assets were resolved for the requested hashes.");
|
|
@@ -2125,6 +2152,14 @@ const ApplyCanvasResultSchema = z.object({
|
|
|
2125
2152
|
path: ["rootRemoved"]
|
|
2126
2153
|
});
|
|
2127
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
|
+
}
|
|
2128
2163
|
const ExactReadSessionParameterSchema = z.string().min(1).describe("Exact sessionId from list_design_sessions; omit for the active badge target.").optional();
|
|
2129
2164
|
const AssetDescriptorSchema = z.object({
|
|
2130
2165
|
hash: z.string().regex(MCP_HASH_PATTERN),
|
|
@@ -2143,44 +2178,48 @@ const GetCodeParametersSchema = z.object({
|
|
|
2143
2178
|
taskId: DesignTaskParameterSchema,
|
|
2144
2179
|
taskEpoch: DesignTaskEpochSchema,
|
|
2145
2180
|
sessionId: ExactReadSessionParameterSchema,
|
|
2146
|
-
nodeId:
|
|
2181
|
+
nodeId: NodeIdParameterSchema,
|
|
2182
|
+
nodeIds: NodeIdsParameterSchema,
|
|
2147
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(),
|
|
2148
|
-
resolveTokens: z.boolean().describe("Inline token values
|
|
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(),
|
|
2149
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()
|
|
2150
|
-
});
|
|
2186
|
+
}).superRefine(validateNodeTargets);
|
|
2151
2187
|
const GetTokenDefsParametersSchema = z.object({
|
|
2152
2188
|
taskId: DesignTaskParameterSchema,
|
|
2153
2189
|
taskEpoch: DesignTaskEpochSchema,
|
|
2154
2190
|
sessionId: ExactReadSessionParameterSchema,
|
|
2155
|
-
names: z.array(z.string().regex(/^--[a-zA-Z0-9-_]+$/)).min(1).describe("Canonical token names (CSS variable form) from
|
|
2156
|
-
includeAllModes: z.boolean().describe("
|
|
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()
|
|
2157
2193
|
});
|
|
2158
2194
|
const GetScreenshotParametersSchema = z.object({
|
|
2159
2195
|
taskId: DesignTaskParameterSchema,
|
|
2160
2196
|
taskEpoch: DesignTaskEpochSchema,
|
|
2161
2197
|
sessionId: ExactReadSessionParameterSchema,
|
|
2162
|
-
nodeId:
|
|
2163
|
-
|
|
2198
|
+
nodeId: NodeIdParameterSchema,
|
|
2199
|
+
nodeIds: NodeIdsParameterSchema
|
|
2200
|
+
}).superRefine(validateNodeTargets);
|
|
2164
2201
|
const GetStructureParametersSchema = z.object({
|
|
2165
2202
|
taskId: DesignTaskParameterSchema,
|
|
2166
2203
|
taskEpoch: DesignTaskEpochSchema,
|
|
2167
2204
|
sessionId: ExactReadSessionParameterSchema,
|
|
2168
|
-
nodeId:
|
|
2205
|
+
nodeId: NodeIdParameterSchema,
|
|
2206
|
+
nodeIds: NodeIdsParameterSchema,
|
|
2169
2207
|
pageId: z.string().min(1).describe("Exact local page id to outline.").optional(),
|
|
2170
2208
|
pageKey: CanvasStableKeySchema.describe("Exact stable key of a local page authored through apply_canvas.").optional(),
|
|
2171
2209
|
options: z.object({
|
|
2172
|
-
depth: z.number().int().
|
|
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(),
|
|
2173
2211
|
native: z.boolean().describe("Include compact native read-back for masks, IMAGE paint hashes, layout grids, and frame guides.").optional()
|
|
2174
2212
|
}).strict().optional()
|
|
2175
2213
|
}).strict().superRefine((value, context) => {
|
|
2176
2214
|
if ([
|
|
2177
2215
|
value.nodeId,
|
|
2216
|
+
value.nodeIds,
|
|
2178
2217
|
value.pageId,
|
|
2179
2218
|
value.pageKey
|
|
2180
2219
|
].filter((identity) => identity !== void 0).length <= 1) return;
|
|
2181
2220
|
context.addIssue({
|
|
2182
2221
|
code: "custom",
|
|
2183
|
-
message: "Use only one of nodeId, pageId, or pageKey."
|
|
2222
|
+
message: "Use only one of nodeId, nodeIds, pageId, or pageKey."
|
|
2184
2223
|
});
|
|
2185
2224
|
});
|
|
2186
2225
|
const GetDesignSystemParametersSchema = z.object({
|
|
@@ -2424,7 +2463,7 @@ function bindRequestMetadata(binding, meta) {
|
|
|
2424
2463
|
//#region package.json
|
|
2425
2464
|
var package_default = {
|
|
2426
2465
|
name: "@tempad-dev/mcp",
|
|
2427
|
-
version: "0.
|
|
2466
|
+
version: "0.11.0",
|
|
2428
2467
|
description: "Connect coding agents to Figma for design inspection, native canvas editing, and UI implementation.",
|
|
2429
2468
|
license: "MIT",
|
|
2430
2469
|
repository: {
|
|
@@ -2462,13 +2501,13 @@ var package_default = {
|
|
|
2462
2501
|
},
|
|
2463
2502
|
devDependencies: {
|
|
2464
2503
|
"@tempad-dev/shared": "workspace:^0.1.0",
|
|
2465
|
-
"@types/node": "^24.13.
|
|
2504
|
+
"@types/node": "^24.13.6",
|
|
2466
2505
|
"@types/proper-lockfile": "^4.1.4",
|
|
2467
2506
|
"@types/ws": "^8.18.1",
|
|
2468
2507
|
"tsdown": "^0.23.0",
|
|
2469
2508
|
"typescript": "^6.0.3",
|
|
2470
2509
|
"unplugin-raw": "^0.8.0",
|
|
2471
|
-
"vitest": "5.0.
|
|
2510
|
+
"vitest": "5.0.1"
|
|
2472
2511
|
},
|
|
2473
2512
|
engines: { "node": "^22 || ^24 || >=26" }
|
|
2474
2513
|
};
|
|
@@ -2539,6 +2578,6 @@ const log = pino({
|
|
|
2539
2578
|
}, prettyTransport);
|
|
2540
2579
|
const SOCK_PATH = resolveSockPath();
|
|
2541
2580
|
//#endregion
|
|
2542
|
-
export {
|
|
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 };
|
|
2543
2582
|
|
|
2544
|
-
//# sourceMappingURL=shared-
|
|
2583
|
+
//# sourceMappingURL=shared-FHsVNIOk.mjs.map
|