AI-native design editor. Open-source Figma alternative.
fix(tools): reject arguments a tool does not take (#1014)
Danila Poyarkov0165111bb302
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.mdindex 9b4f2309b..54558bde8 100644--- a/.github/PULL_REQUEST_TEMPLATE.md+++ b/.github/PULL_REQUEST_TEMPLATE.md@@ -1,6 +1,8 @@-> Security vulnerability? Do not open a public PR. Report it privately through GitHub Security Advisories: https://github.com/open-pencil/open-pencil/security/advisories/new+<!--+Security vulnerability? Do not open a public PR. Report it privately through GitHub Security Advisories: https://github.com/open-pencil/open-pencil/security/advisories/newBefore opening a PR, read `CONTRIBUTING.md` and `AGENTS.md`. PRs should explain the intent, meaningful changes, and validation. Placeholder, non-English, unrelated, or otherwise unreviewable PRs may be closed by maintainers.+-->### Summarydiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4a5c3705d..6bef5333f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -35,6 +35,7 @@- `buildDerivedTextDataV4` is removed from `@open-pencil/core`, and `sceneNodeToKiwi` no longer writes glyph outlines by itself: pass the `runtime` that `withFigExportRuntime(graph, canvasKit, write)` hands its callback. In `@open-pencil/fig/node-change`, `FigNodeChangeExportRuntime` takes `shapeText(node)` instead of `getGlyphOutlineMetrics`, `buildDerivedTextData` takes the `baselines` it writes, and `convertFigmaDerivedTextGlyphs` takes the text's characters.- The `updates` messages from `@open-pencil/vue` no longer include `availableTitle`, `installPrompt`, `installedTitle`, and `downloading`, which only the system update dialogs and download toast used; `installed` now takes only `{ version }`, and `install` reads "Install Update". The Software Update window uses the new `windowTitle`, `currentVersion`, `whatsNew`, `installAndRestart`, `restartNow`, and related messages.- `fetchIcon`, `fetchIcons`, `searchIcons`, `searchIconsBatch`, and `clearIconCache` are removed from `@open-pencil/core`. Icons come from an `IconProvider` instead: `iconify` is the default Iconify provider, `createIconifyProvider()` makes one with its own cache, and `placeIcon` places an icon that keeps its name. A custom provider also implements `previews()`, `collections()`, and `browse()`, which give pickers each icon's SVG markup, the sets, and a set's icons.+- `defineTool` from `@open-pencil/core/tools` takes its `input` as a `v.strictObject` instead of a `v.object`, and `ToolDef.input` is a strict object schema, so a tool rejects arguments it does not declare.### Added@@ -134,6 +135,7 @@### Fixed+- Reject an argument an AI, MCP, CLI, or WebMCP tool does not take, such as `properties: { y: 500 }` for `update_node` or `font: { family }` for `set_font`, and name it, instead of reporting success without changing anything (#977).- Choose an instance's variant by its variant property in design JSX, such as `<Instance component="Button" State="Pressed" />`, without a warning that the property is unsupported.- Keep memory flat while the AI chat or an MCP client edits a document (#587). Each edit kept two copies of its whole page in the undo history, about 10 MB a call on a 400-layer page, until the 200-step history limit, so long sessions grew until the app ran out of memory; an edit now keeps only the layers it changed, and undoing it leaves the other layers as they are.- Keep the new-tab button and the active tab in view when many documents are open. Tabs shrink before the tab bar scrolls, the clipped side fades with a chevron that scrolls to hidden tabs, and the new-tab button is a compact button beside the last tab instead of scrolling away with the tabs.diff --git a/packages/core/src/tools/analyze/clusters.ts b/packages/core/src/tools/analyze/clusters.tsindex 59c90cb18..5172e6b74 100644--- a/packages/core/src/tools/analyze/clusters.ts+++ b/packages/core/src/tools/analyze/clusters.ts@@ -32,7 +32,7 @@ export const analyzeClusters = defineTool({'Find repeated design patterns (potential components). Groups nodes by structural signature — type, size, and child structure.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({min_count: v.optional(toolNumber(v.pipe(v.number(), v.description('Min instances to form a cluster (default: 2)')))),diff --git a/packages/core/src/tools/analyze/colors.ts b/packages/core/src/tools/analyze/colors.tsindex 80d799436..98ea69bb4 100644--- a/packages/core/src/tools/analyze/colors.ts+++ b/packages/core/src/tools/analyze/colors.ts@@ -37,7 +37,7 @@ export const analyzeColors = defineTool({description:'Analyze color palette usage across the current page. Shows frequency, variable bindings, and optionally clusters similar colors.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({limit: analysisLimitInput,show_similar: v.optional(v.pipe(v.boolean(), v.description('Include similar-color clusters for potential merging'))diff --git a/packages/core/src/tools/analyze/diff/changes.ts b/packages/core/src/tools/analyze/diff/changes.tsindex 355e9ecb0..78bb45a64 100644--- a/packages/core/src/tools/analyze/diff/changes.ts+++ b/packages/core/src/tools/analyze/diff/changes.ts@@ -47,7 +47,7 @@ export const diffChanges = defineTool({execution: { kind: 'sync', mutation: 'none' },// Only an AI chat run records the state it started from.exposure: { mcp: false, webmcp: false },- input: v.object({+ input: v.strictObject({id: v.optional(v.pipe(v.string(), v.description('Node to compare (default: the current page)')))}),execute: (figma, args) => {diff --git a/packages/core/src/tools/analyze/diff/tools.ts b/packages/core/src/tools/analyze/diff/tools.tsindex b701aed4f..19a2b77fe 100644--- a/packages/core/src/tools/analyze/diff/tools.ts+++ b/packages/core/src/tools/analyze/diff/tools.ts@@ -43,7 +43,7 @@ export const diffCreate = defineTool({description:'Patch that turns one node tree into another, as JSX attribute changes per node plus moved, added, and removed children. Children are matched by name. Apply it to the first tree with diff_apply.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({...nodeComparisonInput.entries,depth: v.optional(toolNumber(@@ -74,7 +74,7 @@ export const diffShow = defineTool({description:'Preview setting JSX attributes on a node, without changing it. Returns the patch, which diff_apply applies.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,attributes: v.pipe(v.string(),@@ -116,7 +116,7 @@ export const diffApply = defineTool({description:"Apply a patch from diff_create, diff_show, or diff_changes. Each node must still have the patch's old values unless force is set, and nothing changes unless every hunk applies. Use dryRun to check first.",execution: { kind: 'async', mutation: 'document' },- input: v.object({+ input: v.strictObject({patch: v.pipe(v.string(),v.description('Patch text from diff_create, diff_show, or diff_changes')diff --git a/packages/core/src/tools/analyze/diff/visual.ts b/packages/core/src/tools/analyze/diff/visual.tsindex e8c9ccd30..753797ce7 100644--- a/packages/core/src/tools/analyze/diff/visual.ts+++ b/packages/core/src/tools/analyze/diff/visual.ts@@ -77,7 +77,7 @@ export const diffVisual = defineTool({description:'Pixel diff between two rendered nodes. Returns a PNG with changed pixels in red over a faded copy of the source, the changed pixel ratio, and the changed region in source-node coordinates. Use it to confirm an edit only touched the intended area.',execution: { kind: 'async', mutation: 'none' },- input: v.object({+ input: v.strictObject({...nodeComparisonInput.entries,...rasterScaleInputs,threshold: v.optional(diff --git a/packages/core/src/tools/analyze/eval/index.ts b/packages/core/src/tools/analyze/eval/index.tsindex f25ca749e..53f2ed717 100644--- a/packages/core/src/tools/analyze/eval/index.ts+++ b/packages/core/src/tools/analyze/eval/index.ts@@ -11,7 +11,7 @@ export const evalCode = defineTool({execution: { kind: 'async', mutation: 'document' },capabilities: ['document:read', 'document:write', 'code:execute'],availability: 'eval',- input: v.object({+ input: v.strictObject({code: v.pipe(v.string(), v.description('JavaScript code to execute'))}),diff --git a/packages/core/src/tools/analyze/lint.ts b/packages/core/src/tools/analyze/lint.tsindex fe220251b..5589686bf 100644--- a/packages/core/src/tools/analyze/lint.ts+++ b/packages/core/src/tools/analyze/lint.ts@@ -72,7 +72,7 @@ export const lint = defineTool({'off-scale spacing and radius, colors that match a variable but are not bound, and structure hygiene. ' +'Findings are sorted by severity. A `fix` is safe to apply with lint_fix; `suggestions` change values and need judgment.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({ ...lintScopeInput, limit: analysisLimitInput }),+ input: v.strictObject({ ...lintScopeInput, limit: analysisLimitInput }),execute: (figma, args) => {const result = runLint(figma, args)const rank = { error: 0, warning: 1, info: 2 }@@ -94,7 +94,7 @@ export const lintFix = defineTool({'raise text to the minimum size, convert groups to frames, delete hidden layers). ' +'Returns what was applied and what remains.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({...lintScopeInput,suggestions: v.optional(v.pipe(v.boolean(), v.description('Also apply the first suggestion of each finding')),diff --git a/packages/core/src/tools/analyze/overlaps/index.ts b/packages/core/src/tools/analyze/overlaps/index.tsindex 7c69607c4..66f494b8e 100644--- a/packages/core/src/tools/analyze/overlaps/index.ts+++ b/packages/core/src/tools/analyze/overlaps/index.ts@@ -336,7 +336,7 @@ export const analyzeOverlaps = defineTool({'Detect visual overlaps and layout overflows across the current page. Useful for finding content that covers footers, text that bleeds outside frames, and accidental sibling overlaps.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({scope: v.optional(v.pipe(v.picklist(['all', 'same-parent', 'cross-parent', 'top-level', 'inside-parent']),diff --git a/packages/core/src/tools/analyze/spacing.ts b/packages/core/src/tools/analyze/spacing.tsindex 0e070690d..6b0b1fcf9 100644--- a/packages/core/src/tools/analyze/spacing.ts+++ b/packages/core/src/tools/analyze/spacing.ts@@ -9,7 +9,7 @@ export const analyzeSpacing = defineTool({description:'Analyze spacing values (gap, padding) across the current page. Checks grid compliance.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({grid: v.optional(toolNumber(v.pipe(diff --git a/packages/core/src/tools/analyze/typography.ts b/packages/core/src/tools/analyze/typography.tsindex 46239a31f..e9205c60a 100644--- a/packages/core/src/tools/analyze/typography.ts+++ b/packages/core/src/tools/analyze/typography.ts@@ -10,7 +10,7 @@ export const analyzeTypography = defineTool({description:'Analyze typography usage across the current page. Shows font families, sizes, weights, and their frequencies.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({limit: analysisLimitInput,group_by: v.optional(v.pipe(v.picklist(['family', 'size', 'weight']), v.description('Group results by a property'))diff --git a/packages/core/src/tools/calc.ts b/packages/core/src/tools/calc.tsindex 957a3acce..6420eb780 100644--- a/packages/core/src/tools/calc.ts+++ b/packages/core/src/tools/calc.ts@@ -29,7 +29,7 @@ export const calc = defineTool({'Examples: "844 - 56 - 96 - 82", \'["1440 * 8 / 12", "(952 - 16) / 2", "floor(390 * 0.6)"]\'',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({expr: v.pipe(v.string(), v.description('Single expression or JSON array of expressions'))}),execute: (_figma, { expr }) => {diff --git a/packages/core/src/tools/codegen/component-map.ts b/packages/core/src/tools/codegen/component-map.tsindex 73d00085f..cd57bc590 100644--- a/packages/core/src/tools/codegen/component-map.ts+++ b/packages/core/src/tools/codegen/component-map.ts@@ -115,7 +115,7 @@ export const designToComponentMap = defineTool({description:'Analyze the document and return a structured component decomposition: components (with variants, props, instance counts), screens, and a dependency overview.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({page: v.optional(v.pipe(v.string(), v.description('Page name to analyze (default: current page)')))diff --git a/packages/core/src/tools/codegen/tokens.ts b/packages/core/src/tools/codegen/tokens.tsindex 8cb969884..ddc93a3bd 100644--- a/packages/core/src/tools/codegen/tokens.ts+++ b/packages/core/src/tools/codegen/tokens.ts@@ -52,7 +52,7 @@ export const designToTokens = defineTool({description:'Write the document variables as a stylesheet of CSS custom properties: defaults in :root, every other mode under its condition (a selector such as [data-theme="dark"] or an @media query), aliases as var() references. The tailwind format puts tokens with a Tailwind v4 namespace (--color-*, --spacing-*, --radius-*, --text-*, …) in @theme and adds a @custom-variant per mode. The dtcg format returns W3C design token files instead: one per collection mode, text and effect styles as typography and shadow tokens, and a resolver document; collection and type filters do not apply to it. Issues lists tokens or modes that could not be written.',execution: { kind: 'async', mutation: 'none' },- input: v.object({+ input: v.strictObject({format: v.optional(v.pipe(v.picklist(['css', 'tailwind', 'dtcg']),@@ -92,7 +92,7 @@ export const importDesignTokens = defineTool({description:'Import W3C design token (DTCG) files into the document as variables, and typography and shadow tokens as text and effect styles. Pass each file with its path: a file per mode grouped by folder (as Figma exports modes), a .resolver.json with the files it refers to, or a Tokens Studio file with $themes. Collections and modes with the same names as existing ones are updated, variables are matched by name, and nothing is deleted. Returns what was added, updated, and skipped and why.',execution: { kind: 'async', mutation: 'document' },- input: v.object({+ input: v.strictObject({files: v.pipe(v.array(v.object({ path: v.string(), text: v.string() })),v.minLength(1),diff --git a/packages/core/src/tools/create/basic.ts b/packages/core/src/tools/create/basic.tsindex f2035f054..4bf497760 100644--- a/packages/core/src/tools/create/basic.ts+++ b/packages/core/src/tools/create/basic.ts@@ -10,7 +10,7 @@ export const createShape = defineTool({description:'Create a shape on the canvas. Use FRAME for containers/cards, RECTANGLE for solid blocks, ELLIPSE for circles, TEXT for labels, LINE for rules and dividers, STAR for starbursts and badges, POLYGON for triangles and regular polygons, and SECTION for page sections. Use create_vector with an SVG path for arbitrary shapes.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({type: v.pipe(v.picklist(['FRAME', 'RECTANGLE', 'ELLIPSE', 'TEXT', 'LINE', 'STAR', 'POLYGON', 'SECTION']),v.description('Node type')@@ -49,7 +49,7 @@ export const createPage = defineTool({description: 'Create a new page.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({name: v.pipe(v.string(), v.description('Page name'))}),execute: (figma, { name }) => {@@ -64,7 +64,7 @@ export const createSlice = defineTool({description: 'Create a slice (export region) on the canvas.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({...positionInputs,width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width'))),height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height'))),diff --git a/packages/core/src/tools/create/behaviours.ts b/packages/core/src/tools/create/behaviours.tsindex bd63e9108..536c2b201 100644--- a/packages/core/src/tools/create/behaviours.ts+++ b/packages/core/src/tools/create/behaviours.ts@@ -19,7 +19,7 @@ export const setBehaviour = defineTool({'Returns the behaviour and the required values and parts still missing; get_behaviour lists ' +'every kind with its values and parts.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(),v.description('Main component or component set ID; a variant uses its set')@@ -47,7 +47,7 @@ export const createSlot = defineTool({'Make a frame inside a main component a slot, as Create slot does: instances can then hold ' +'their own content in it, and a behaviour can bind it as a part. Returns the slot name.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Frame ID inside a main component'))}),execute: (figma, { id }) => {@@ -66,7 +66,7 @@ export const getBehaviour = defineTool({'names, with the required values and parts still missing. Without an ID, list every ' +'behaviour kind with the values and parts it binds.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({id: v.optional(v.pipe(v.string(), v.description('Component, set, or variant ID')))}),execute: (figma, { id }) => {diff --git a/packages/core/src/tools/create/components.ts b/packages/core/src/tools/create/components.tsindex dfd6dcaea..7fe2a4734 100644--- a/packages/core/src/tools/create/components.ts+++ b/packages/core/src/tools/create/components.ts@@ -9,7 +9,7 @@ export const createComponent = defineTool({description: 'Convert a frame/group into a component.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Node ID to convert'))}),execute: (figma, { id }) => {@@ -25,7 +25,7 @@ export const createInstance = defineTool({description: 'Create an instance of a component.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({component_id: v.pipe(v.string(), v.description('Component node ID')),x: v.optional(toolNumber(v.pipe(v.number(), v.description('X position')))),y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y position'))))@@ -48,7 +48,7 @@ export const combineAsVariants = defineTool({'as Figma names variants, "State=On, Size=Large", get those variant properties; names like ' +'"Button/Primary" derive a Variant property from the segments after the first slash.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Component node IDs to combine'))}),execute: (figma, { ids }) => {@@ -76,7 +76,7 @@ export const exposeInstanceSwap = defineTool({description: 'Expose nested instances as an instance-swap slot on their component.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({instance_ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Instance node IDs')),candidate_ids: v.pipe(v.array(v.string()),diff --git a/packages/core/src/tools/create/icons.ts b/packages/core/src/tools/create/icons.tsindex eb3875281..f72b7c6d5 100644--- a/packages/core/src/tools/create/icons.ts+++ b/packages/core/src/tools/create/icons.ts@@ -13,7 +13,7 @@ export const fetchIconsTool = defineTool({'Pre-fetch icons from Iconify into cache. Batches by prefix (one HTTP request per set). Call this once with all needed icons, then use insert_icon to place them instantly. Popular sets: lucide (outline), mdi (filled), heroicons, tabler, solar, mingcute, ri (remix).',execution: { kind: 'async', mutation: 'none' },capabilities: ['network:access'],- input: v.object({+ input: v.strictObject({names: v.pipe(v.array(v.string()),v.minLength(1),@@ -45,7 +45,7 @@ export const insertIcon = defineTool({'Insert one or more vector icons onto the canvas. Pass a single name or multiple names to batch-insert into the same parent. If already cached by fetch_icons — instant, no network request.',execution: { kind: 'async', mutation: 'document' },capabilities: ['document:write', 'network:access'],- input: v.object({+ input: v.strictObject({names: v.optional(v.pipe(v.array(v.string()),@@ -112,7 +112,7 @@ export const searchIconsTool = defineTool({'Search Iconify for icons by keyword. Accepts multiple queries — all searched in parallel. Returns results keyed by query.',execution: { kind: 'async', mutation: 'none' },capabilities: ['network:access'],- input: v.object({+ input: v.strictObject({queries: v.pipe(v.array(v.string()),v.minLength(1),diff --git a/packages/core/src/tools/create/render.ts b/packages/core/src/tools/create/render.tsindex f1a565e75..777dccaa3 100644--- a/packages/core/src/tools/create/render.ts+++ b/packages/core/src/tools/create/render.ts@@ -10,7 +10,7 @@ export const render = defineTool({description:'Render JSX to design nodes. Supports inline SVG paths, including open stroked paths: <svg viewBox="0 0 24 24" size={24}><path d="M2 12 L22 12" stroke="#000" fill="none" /></svg>. Use replace_id to replace a placeholder while preserving its position.',execution: { kind: 'async', mutation: 'document' },- input: v.object({+ input: v.strictObject({replace_id: v.optional(v.pipe(v.string(),diff --git a/packages/core/src/tools/create/svg.ts b/packages/core/src/tools/create/svg.tsindex eed5725b2..e171ad715 100644--- a/packages/core/src/tools/create/svg.ts+++ b/packages/core/src/tools/create/svg.ts@@ -10,7 +10,7 @@ export const importSVG = defineTool({description:'Import raw SVG markup onto the canvas as editable vector nodes. Supports common SVG shapes, inherited presentation attributes, transforms, gradients, and internal <use> references.',execution: { kind: 'async', mutation: 'document' },- input: v.object({+ input: v.strictObject({svg: v.pipe(v.string(),v.description('SVG markup string (e.g. \'<svg viewBox="0 0 24 24"><path d="M..."/></svg>\')')diff --git a/packages/core/src/tools/create/vector.ts b/packages/core/src/tools/create/vector.tsindex ea571ceeb..9b629aef6 100644--- a/packages/core/src/tools/create/vector.ts+++ b/packages/core/src/tools/create/vector.ts@@ -42,7 +42,7 @@ export const createVector = defineTool({description: 'Create a vector node from SVG path data or a VectorNetwork.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({...positionInputs,name: v.optional(v.pipe(v.string(), v.description('Node name'))),path: v.optional(diff --git a/packages/core/src/tools/describe/index.ts b/packages/core/src/tools/describe/index.tsindex bbebbdbc2..a9f000301 100644--- a/packages/core/src/tools/describe/index.ts+++ b/packages/core/src/tools/describe/index.ts@@ -11,7 +11,7 @@ export const describe = defineTool({'Semantic description of one or more nodes. Pass `id` for a single node, or `ids` for multiple nodes in one call. Omit depth for auto — adapts to subtree size (small block → deeper, large page → shallower).',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({id: v.optional(v.pipe(v.string(), v.description('Node ID (single node)'))),ids: v.optional(v.pipe(diff --git a/packages/core/src/tools/input.ts b/packages/core/src/tools/input.tsindex 431fafa28..909cd5745 100644--- a/packages/core/src/tools/input.ts+++ b/packages/core/src/tools/input.ts@@ -1,14 +1,14 @@import * as v from 'valibot'export const nodeIdInput = v.pipe(v.string(), v.description('Node ID'))-export const nodeInput = v.object({ id: nodeIdInput })-export const nodeComparisonInput = v.object({+export const nodeInput = v.strictObject({ id: nodeIdInput })+export const nodeComparisonInput = v.strictObject({from: v.pipe(v.string(), v.description('Source node ID')),to: v.pipe(v.string(), v.description('Target node ID'))})export function nodeTraversalInput(depthDescription: string) {- return v.object({+ return v.strictObject({id: nodeIdInput,depth: v.optional(toolNumber(v.pipe(v.number(), v.description(depthDescription))))})diff --git a/packages/core/src/tools/modify/effects.ts b/packages/core/src/tools/modify/effects.tsindex 18eed091c..1891a17b4 100644--- a/packages/core/src/tools/modify/effects.ts+++ b/packages/core/src/tools/modify/effects.ts@@ -13,7 +13,7 @@ export const setEffects = defineTool({description:'Set effects on a node (drop shadow, inner shadow, blur). Pass an array or a single effect.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,type: v.pipe(v.picklist(['DROP_SHADOW', 'INNER_SHADOW', 'FOREGROUND_BLUR', 'BACKGROUND_BLUR']),diff --git a/packages/core/src/tools/modify/geometry.ts b/packages/core/src/tools/modify/geometry.tsindex 3e9295c6f..4346cb6a6 100644--- a/packages/core/src/tools/modify/geometry.ts+++ b/packages/core/src/tools/modify/geometry.ts@@ -8,7 +8,7 @@ export const setRotation = defineTool({description: 'Set rotation angle of a node in degrees.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,angle: toolNumber(v.pipe(v.number(), v.description('Rotation angle in degrees')))}),@@ -25,7 +25,7 @@ export const setOpacity = defineTool({description: 'Set opacity of a node (0-1).',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,value: toolNumber(v.pipe(v.number(), v.minValue(0), v.maxValue(1), v.description('Opacity (0-1)'))@@ -44,7 +44,7 @@ export const setRadius = defineTool({description: 'Set corner radius. Use individual corners for independent values.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,radius: v.optional(toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Corner radius for all corners')))@@ -91,7 +91,7 @@ export const setMinMax = defineTool({description: 'Set min/max width and height constraints on a node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,min_width: v.optional(toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Minimum width')))diff --git a/packages/core/src/tools/modify/layout.ts b/packages/core/src/tools/modify/layout.tsindex 239af8fd3..f8e8fe72f 100644--- a/packages/core/src/tools/modify/layout.ts+++ b/packages/core/src/tools/modify/layout.ts@@ -10,7 +10,7 @@ export const setLayout = defineTool({description: 'Set auto-layout (flexbox) on a frame. Direction, alignment, spacing, padding.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Frame node ID')),direction: v.optional(v.pipe(@@ -108,7 +108,7 @@ export const setConstraints = defineTool({description: 'Set resize constraints for a node within its parent.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,horizontal: v.optional(v.pipe(@@ -142,7 +142,7 @@ export const setLayoutChild = defineTool({description:'Configure auto-layout child: sizing (FIXED/HUG/FILL), grow, alignment, absolute positioning.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Child node ID')),sizing_horizontal: v.optional(v.pipe(v.picklist(['FIXED', 'HUG', 'FILL']), v.description('Horizontal sizing mode'))diff --git a/packages/core/src/tools/modify/paint.ts b/packages/core/src/tools/modify/paint.tsindex 5a3b480c1..75197858c 100644--- a/packages/core/src/tools/modify/paint.ts+++ b/packages/core/src/tools/modify/paint.ts@@ -14,7 +14,7 @@ export const setFill = defineTool({description:'Set fill on a node. Solid: color="#ff0000". Linear gradient: gradient="top-bottom" or "left-right" with color (start) and color_end (end).',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,color: v.pipe(v.string(), v.description('Color (hex). For gradient: start color.')),color_end: v.optional(@@ -67,7 +67,7 @@ export const setStroke = defineTool({description: 'Set the stroke (border) of a node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,color: v.pipe(v.string(), v.description('Stroke color (hex)')),weight: v.optional(@@ -103,7 +103,7 @@ export const setImageFill = defineTool({description: 'Set an image fill on a node from base64-encoded image data.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,image_data: v.pipe(v.string(),diff --git a/packages/core/src/tools/modify/state.ts b/packages/core/src/tools/modify/state.tsindex 1d5202ea9..d46ff95fa 100644--- a/packages/core/src/tools/modify/state.ts+++ b/packages/core/src/tools/modify/state.ts@@ -8,7 +8,7 @@ export const setVisible = defineTool({description: 'Set visibility of a node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,value: v.pipe(v.boolean(), v.description('Visible (true/false)'))}),@@ -25,7 +25,7 @@ export const setBlend = defineTool({description: 'Set blend mode of a node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,mode: v.pipe(v.picklist([@@ -62,7 +62,7 @@ export const setLocked = defineTool({description: 'Set locked state of a node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,value: v.pipe(v.boolean(), v.description('Locked (true/false)'))}),@@ -79,7 +79,7 @@ export const setStrokeAlign = defineTool({description: 'Set stroke alignment of a node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,align: v.pipe(v.picklist(['INSIDE', 'CENTER', 'OUTSIDE']), v.description('Stroke alignment'))}),diff --git a/packages/core/src/tools/modify/text.ts b/packages/core/src/tools/modify/text.tsindex 36c0009b6..3a728998b 100644--- a/packages/core/src/tools/modify/text.ts+++ b/packages/core/src/tools/modify/text.ts@@ -13,7 +13,7 @@ export const setText = defineTool({description: 'Set text content of a text node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,text: v.pipe(v.string(), v.description('Text content'))}),@@ -30,7 +30,7 @@ export const setFont = defineTool({description: 'Set font properties of a text node.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,family: v.optional(v.pipe(v.string(), v.description('Font family name'))),size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))),@@ -58,7 +58,7 @@ export const setFontRange = defineTool({description: 'Set font properties for a text range.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,start: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Start character index'))),end: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('End character index'))),@@ -94,7 +94,7 @@ export const setTextResize = defineTool({description: 'Set text auto-resize mode.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,mode: v.pipe(v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE']),@@ -115,7 +115,7 @@ export const setTextProperties = defineTool({description:'Set text layout properties: alignment, auto-resize, text case, decoration, truncation.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Text node ID')),align_horizontal: v.optional(v.pipe(diff --git a/packages/core/src/tools/modify/update.ts b/packages/core/src/tools/modify/update.tsindex 41f6a3fcc..209ba3620 100644--- a/packages/core/src/tools/modify/update.ts+++ b/packages/core/src/tools/modify/update.ts@@ -12,7 +12,7 @@ export const updateNode = defineTool({description:'Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,x: v.optional(toolNumber(v.pipe(v.number(), v.description('X position')))),y: v.optional(toolNumber(v.pipe(v.number(), v.description('Y position')))),diff --git a/packages/core/src/tools/read/components.ts b/packages/core/src/tools/read/components.tsindex c0c8f6b9f..d7323abb7 100644--- a/packages/core/src/tools/read/components.ts+++ b/packages/core/src/tools/read/components.ts@@ -30,7 +30,7 @@ export const getComponents = defineTool({description:'List reusable components from the document and enabled component libraries, optionally filtered by name.',execution: { kind: 'async', mutation: 'none' },- input: v.object({+ input: v.strictObject({name: v.optional(v.pipe(v.string(), v.description('Filter by name (case-insensitive substring)'))),diff --git a/packages/core/src/tools/read/fonts.ts b/packages/core/src/tools/read/fonts.tsindex fa17baafa..af8c1ceba 100644--- a/packages/core/src/tools/read/fonts.ts+++ b/packages/core/src/tools/read/fonts.ts@@ -11,7 +11,7 @@ export const getFontStatus = defineTool({'loaded, and affected nodes.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({}),+ input: v.strictObject({}),execute: (figma) => figma.getFontStatus()})@@ -20,7 +20,7 @@ export const listFonts = defineTool({description: 'List fonts used in the current page.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({family: v.optional(v.pipe(v.string(), v.description('Filter by family name (substring)')))}),execute: (figma, args) => {@@ -57,7 +57,7 @@ export const listAvailableFonts = defineTool({'which only reports families currently used in the page.',execution: { kind: 'async', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({family: v.optional(v.pipe(v.string(), v.description('Filter by family name (substring, case-insensitive)')))diff --git a/packages/core/src/tools/read/jsx.ts b/packages/core/src/tools/read/jsx.tsindex 4c758052e..daa08e43a 100644--- a/packages/core/src/tools/read/jsx.ts+++ b/packages/core/src/tools/read/jsx.ts@@ -13,7 +13,7 @@ export const getJSX = defineTool({description:'Get JSX representation of a node and its children. Compact round-trip format — same syntax as the render tool.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,path: v.optional(v.pipe(diff --git a/packages/core/src/tools/read/libraries.ts b/packages/core/src/tools/read/libraries.tsindex 8bf404515..89edbc5f4 100644--- a/packages/core/src/tools/read/libraries.ts+++ b/packages/core/src/tools/read/libraries.ts@@ -9,7 +9,7 @@ export const listLibraries = defineTool({description: 'List available published component libraries.',execution: { kind: 'async', mutation: 'none' },exposure: { webmcp: false },- input: v.object({}),+ input: v.strictObject({}),execute: async (figma) => {const catalog = getComponentCatalog(figma.graph)const libraries = catalog ? await catalog.listLibraries() : []@@ -23,7 +23,7 @@ export const insertLibraryComponent = defineTool({'Insert a reusable component from an enabled library by stable library and asset identity.',execution: { kind: 'async', mutation: 'document' },- input: v.object({+ input: v.strictObject({library_id: v.pipe(v.string(), v.description('Library ID')),revision_id: v.optional(v.pipe(v.string(), v.description('Pinned revision ID'))),asset_key: v.pipe(v.string(), v.description('Stable asset key')),diff --git a/packages/core/src/tools/read/nodes.ts b/packages/core/src/tools/read/nodes.tsindex 490cec498..7cca84ca9 100644--- a/packages/core/src/tools/read/nodes.ts+++ b/packages/core/src/tools/read/nodes.ts@@ -46,7 +46,7 @@ export const getPageTree = defineTool({description:'Get the node tree of the current page. Returns lightweight hierarchy: id, type, name, size. Use depth, root_id, or node_types to keep large pages small. Use get_node for full properties of a specific node.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({depth: v.optional(toolNumber(v.pipe(@@ -96,7 +96,7 @@ export const getNode = defineTool({description:'Get detailed properties of a node by ID. Use depth to limit child recursion (0 = node only, 1 = direct children, etc). Default: unlimited.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,depth: v.optional(toolNumber(@@ -118,7 +118,7 @@ export const findNodes = defineTool({name: 'find_nodes',description: 'Find nodes by name pattern and/or type.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({name: v.optional(v.pipe(v.string(), v.description('Name substring to match (case-insensitive)'))),diff --git a/packages/core/src/tools/read/pages.ts b/packages/core/src/tools/read/pages.tsindex ed783acdf..8c1afe4e1 100644--- a/packages/core/src/tools/read/pages.ts+++ b/packages/core/src/tools/read/pages.ts@@ -8,7 +8,7 @@ export const listPages = defineTool({name: 'list_pages',description: 'List all pages in the document.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({}),+ input: v.strictObject({}),execute: (figma) => {const pages = figma.root.childrenreturn {@@ -23,7 +23,7 @@ export const switchPage = defineTool({description: 'Switch to a different page by name or ID.',execution: { kind: 'sync', mutation: 'view' },- input: v.object({+ input: v.strictObject({page: v.pipe(v.string(), v.description('Page name or ID'))}),execute: (figma, { page }) => {@@ -39,7 +39,7 @@ export const getCurrentPage = defineTool({name: 'get_current_page',description: 'Get the current page name and ID.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({}),+ input: v.strictObject({}),execute: (figma) => {return { id: figma.currentPage.id, name: figma.currentPage.name }}@@ -50,7 +50,7 @@ export const pageBounds = defineTool({description: 'Get bounding box of all objects on the current page.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({}),+ input: v.strictObject({}),execute: (figma) => {return computeBounds(figma.currentPage.children.map((child) => child.absoluteBoundingBox))}diff --git a/packages/core/src/tools/read/query.ts b/packages/core/src/tools/read/query.tsindex 4c7c14245..8bed09fd6 100644--- a/packages/core/src/tools/read/query.ts+++ b/packages/core/src/tools/read/query.ts@@ -18,7 +18,7 @@ Examples://TEXT[contains(@text, 'Hello')] — text nodes containing "Hello"`,execution: { kind: 'async', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({selector: v.pipe(v.string(), v.description('XPath selector')),page: v.optional(v.pipe(v.string(), v.description('Page name (default: current page)'))),limit: v.optional(toolNumber(v.pipe(v.number(), v.description('Max results (default: 1000)'))))diff --git a/packages/core/src/tools/read/selection.ts b/packages/core/src/tools/read/selection.tsindex d278c4334..2699be902 100644--- a/packages/core/src/tools/read/selection.ts+++ b/packages/core/src/tools/read/selection.ts@@ -13,7 +13,7 @@ export const getSelection = defineTool({'Get the selected nodes: the place to start when the user points at layers. Returns each selected node with its direct children by default; children past the depth are counted as childCount. Use get_node or describe for deeper branches.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({depth: v.optional(toolNumber(v.pipe(@@ -38,7 +38,7 @@ export const selectNodes = defineTool({description: 'Select one or more nodes by ID.',execution: { kind: 'sync', mutation: 'view' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to select'))}),execute: (figma, { ids }) => {diff --git a/packages/core/src/tools/schema.ts b/packages/core/src/tools/schema.tsindex b86310823..6c8cbfc90 100644--- a/packages/core/src/tools/schema.ts+++ b/packages/core/src/tools/schema.ts@@ -39,7 +39,7 @@ interface ToolMetadata {}export interface ToolDef extends ToolMetadata {- input: v.ObjectSchema<v.ObjectEntries, undefined>+ input: v.StrictObjectSchema<v.ObjectEntries, undefined>/** Derived from execution metadata, never declared independently by a tool. */readonly mutates: booleanexecute: (figma: FigmaAPI, args: Record<string, unknown>) => unknown@@ -50,9 +50,9 @@ type ToolDefinitionMetadata = Omit<ToolMetadata, 'exposure' | 'capabilities' | 'export function defineTool<P extends v.ObjectEntries, R>(def: ToolDefinitionMetadata & {- input: v.ObjectSchema<P, undefined>+ input: v.StrictObjectSchema<P, undefined>execution: ToolExecution & (R extends PromiseLike<unknown> ? { kind: 'async' } : unknown)- execute: (figma: FigmaAPI, args: v.InferOutput<v.ObjectSchema<P, undefined>>) => R+ execute: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined>>) => R}): ToolDef {return {@@ -72,7 +72,8 @@ export function defineTool<P extends v.ObjectEntries, R>(/*** Every tool run goes through here, so a wrong call from AI chat, the CLI, or WebMCP names the* tool and lists each problem with its argument, as `v.summarize` formats them. MCP clients get- * the MCP SDK's own report, which validates the same schema before the handler runs.+ * the MCP SDK's own report, which validates the same schema before the handler runs. Inputs are+ * strict objects, so a misspelled or mis-nested argument fails here instead of being dropped.*/export function parseToolArgs<S extends v.GenericSchema>(name: string,diff --git a/packages/core/src/tools/stock-photo.ts b/packages/core/src/tools/stock-photo.tsindex 050a081c3..2f1db5e59 100644--- a/packages/core/src/tools/stock-photo.ts+++ b/packages/core/src/tools/stock-photo.ts@@ -26,7 +26,7 @@ export const stockPhoto = defineTool({'Containers with content, text, lines, and structural nodes are rejected.',execution: { kind: 'async', mutation: 'document' },capabilities: ['document:write', 'network:access'],- input: v.object({+ input: v.strictObject({requests: v.pipe(v.string(),v.description(diff --git a/packages/core/src/tools/structure/arrange.ts b/packages/core/src/tools/structure/arrange.tsindex 1a236f85e..67c7b8fbd 100644--- a/packages/core/src/tools/structure/arrange.ts+++ b/packages/core/src/tools/structure/arrange.ts@@ -10,7 +10,7 @@ export const arrangeNodes = defineTool({description:'Arrange top-level nodes on the canvas in a grid, row, or column layout. Useful after batch creation to tidy up overlapping frames.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.optional(v.pipe(v.array(v.string()),diff --git a/packages/core/src/tools/structure/basic.ts b/packages/core/src/tools/structure/basic.tsindex b41db6c31..bdf7d64e3 100644--- a/packages/core/src/tools/structure/basic.ts+++ b/packages/core/src/tools/structure/basic.ts@@ -8,7 +8,7 @@ export const deleteNode = defineTool({description: 'Delete a node by ID.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Node ID to delete'))}),execute: (figma, { id }) => {@@ -24,7 +24,7 @@ export const cloneNode = defineTool({description: 'Clone (duplicate) a node.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Node ID to clone'))}),execute: (figma, { id }) => {@@ -40,7 +40,7 @@ export const renameNode = defineTool({description: 'Rename a node in the layers panel.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,name: v.pipe(v.string(), v.description('New name'))}),@@ -69,7 +69,7 @@ export const nodeMove = defineTool({description: 'Move a node to new coordinates.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,x: toolNumber(v.pipe(v.number(), v.description('X position'))),y: toolNumber(v.pipe(v.number(), v.description('Y position')))@@ -88,7 +88,7 @@ export const nodeResize = defineTool({description: 'Resize a node.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,width: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Width'))),height: toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Height')))diff --git a/packages/core/src/tools/structure/batch.ts b/packages/core/src/tools/structure/batch.tsindex 6f0e81980..490feffcb 100644--- a/packages/core/src/tools/structure/batch.ts+++ b/packages/core/src/tools/structure/batch.ts@@ -96,7 +96,7 @@ export const batchUpdate = defineTool({description:'Execute multiple modifications in one call. Each operation is {id, props} where props can include: spacing, padding, padding_horizontal, padding_vertical, counter_align, sizing_horizontal, sizing_vertical, grow, name, visible, corner_radius, auto_resize (for text), direction. Runs all updates with one layout recompute.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({operations: v.pipe(v.string(),v.description(diff --git a/packages/core/src/tools/structure/hierarchy.ts b/packages/core/src/tools/structure/hierarchy.tsindex 2b80c4093..a20be7b27 100644--- a/packages/core/src/tools/structure/hierarchy.ts+++ b/packages/core/src/tools/structure/hierarchy.ts@@ -7,7 +7,7 @@ export const reparentNode = defineTool({description: 'Move a node into a different parent.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Node ID to move')),parent_id: v.pipe(v.string(), v.description('New parent node ID'))}),@@ -26,7 +26,7 @@ export const groupNodes = defineTool({description: 'Group selected nodes.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(2), v.description('Node IDs to group'))}),execute: (figma, { ids }) => {@@ -43,7 +43,7 @@ export const ungroupNode = defineTool({description: 'Ungroup a group node.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Group node ID'))}),execute: (figma, { id }) => {@@ -59,7 +59,7 @@ export const flattenNodes = defineTool({description: 'Flatten nodes into a single vector.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to flatten'))}),execute: (figma, { ids }) => {@@ -73,7 +73,7 @@ export const nodeToComponent = defineTool({description: 'Convert one or more frames/groups into components.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to convert'))}),execute: (figma, { ids }) => {diff --git a/packages/core/src/tools/structure/replace.ts b/packages/core/src/tools/structure/replace.tsindex 9e9fa61f2..471884585 100644--- a/packages/core/src/tools/structure/replace.ts+++ b/packages/core/src/tools/structure/replace.ts@@ -7,7 +7,7 @@ export const nodeReplaceWith = defineTool({description: 'Replace a node with JSX content.',execution: { kind: 'async', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Node ID to replace')),jsx: v.pipe(v.string(), v.description('JSX string for the replacement'))}),diff --git a/packages/core/src/tools/variables/bindings.ts b/packages/core/src/tools/variables/bindings.tsindex ece6c63c3..286c3c8e6 100644--- a/packages/core/src/tools/variables/bindings.ts+++ b/packages/core/src/tools/variables/bindings.ts@@ -9,7 +9,7 @@ export const bindVariable = defineTool({description:'Bind a variable to a node property. For fills/strokes color bindings use indexed format like "fills/0/color".',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({node_id: nodeIdInput,field: v.pipe(v.string(),diff --git a/packages/core/src/tools/variables/collections.ts b/packages/core/src/tools/variables/collections.tsindex b205cbe41..18bb45138 100644--- a/packages/core/src/tools/variables/collections.ts+++ b/packages/core/src/tools/variables/collections.ts@@ -6,7 +6,7 @@ export const listCollections = defineTool({name: 'list_collections',description: 'List all variable collections.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({}),+ input: v.strictObject({}),execute: (figma) => {const collections = figma.getLocalVariableCollections()return { count: collections.length, collections }@@ -18,7 +18,7 @@ export const getCollection = defineTool({description: 'Get a variable collection by ID.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Collection ID'))}),execute: (figma, { id }) => {@@ -36,7 +36,7 @@ export const createCollection = defineTool({description: 'Create a new variable collection.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({name: v.pipe(v.string(), v.description('Collection name'))}),execute: (figma, { name }) => {@@ -49,7 +49,7 @@ export const deleteCollection = defineTool({description: 'Delete a variable collection and all its variables.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Collection ID'))}),execute: (figma, { id }) => {diff --git a/packages/core/src/tools/variables/read.ts b/packages/core/src/tools/variables/read.tsindex 392b0cbf3..a73084bd7 100644--- a/packages/core/src/tools/variables/read.ts+++ b/packages/core/src/tools/variables/read.ts@@ -6,7 +6,7 @@ export const listVariables = defineTool({name: 'list_variables',description: 'List all design variables (colors, numbers, strings, booleans).',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({type: v.optional(v.pipe(v.picklist(['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']),@@ -24,7 +24,7 @@ export const getVariable = defineTool({name: 'get_variable',description: 'Get a variable by ID.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Variable ID'))}),execute: (figma, { id }) => {@@ -38,7 +38,7 @@ export const findVariables = defineTool({name: 'find_variables',description: 'Find variables by name pattern.',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({query: v.pipe(v.string(), v.description('Name substring (case-insensitive)')),type: v.optional(v.pipe(v.picklist(['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']), v.description('Filter by type'))diff --git a/packages/core/src/tools/variables/unbind.ts b/packages/core/src/tools/variables/unbind.tsindex 43763bb9b..19c4ab5b3 100644--- a/packages/core/src/tools/variables/unbind.ts+++ b/packages/core/src/tools/variables/unbind.ts@@ -8,7 +8,7 @@ export const unbindVariable = defineTool({description: 'Remove a variable binding from a node property.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({node_id: nodeIdInput,field: v.pipe(v.string(),diff --git a/packages/core/src/tools/variables/values.ts b/packages/core/src/tools/variables/values.tsindex c034b7384..fc39affbf 100644--- a/packages/core/src/tools/variables/values.ts+++ b/packages/core/src/tools/variables/values.ts@@ -17,7 +17,7 @@ export const createVariable = defineTool({description: 'Create a new variable in a collection.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({name: v.pipe(v.string(), v.description('Variable name')),type: v.pipe(v.picklist(['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']),@@ -40,7 +40,7 @@ export const setVariable = defineTool({description: 'Set the value of a variable for a specific mode.',execution: { kind: 'sync', mutation: 'properties' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Variable ID')),mode: v.pipe(v.string(), v.description('Mode ID')),value: v.pipe(v.string(), v.description('Value (hex for COLOR, number for FLOAT, etc.)'))@@ -59,7 +59,7 @@ export const deleteVariable = defineTool({description: 'Delete a variable.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: v.pipe(v.string(), v.description('Variable ID'))}),execute: (figma, { id }) => {diff --git a/packages/core/src/tools/vector/boolean.ts b/packages/core/src/tools/vector/boolean.tsindex d5411f008..43aff4368 100644--- a/packages/core/src/tools/vector/boolean.ts+++ b/packages/core/src/tools/vector/boolean.ts@@ -7,7 +7,7 @@ export const booleanUnion = defineTool({description: 'Union (combine) multiple nodes.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(2), v.description('Node IDs to union'))}),execute: (figma, { ids }) => {@@ -21,7 +21,7 @@ export const booleanSubtract = defineTool({description: 'Subtract the second node from the first.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(2), v.description('Node IDs (first minus rest)'))}),execute: (figma, { ids }) => {@@ -35,7 +35,7 @@ export const booleanIntersect = defineTool({description: 'Intersect multiple nodes.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(2), v.description('Node IDs to intersect'))}),execute: (figma, { ids }) => {@@ -49,7 +49,7 @@ export const booleanExclude = defineTool({description: 'Exclude (XOR) multiple nodes.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(2), v.description('Node IDs to exclude'))}),execute: (figma, { ids }) => {diff --git a/packages/core/src/tools/vector/export.ts b/packages/core/src/tools/vector/export.tsindex 1b8f7423b..dd3b780e7 100644--- a/packages/core/src/tools/vector/export.ts+++ b/packages/core/src/tools/vector/export.ts@@ -69,7 +69,7 @@ export const exportSVG = defineTool({description: 'Export nodes as SVG markup. Returns the SVG string.',execution: { kind: 'async', mutation: 'none' },exposure: { webmcp: false },- input: v.object({ ...exportInputs }),+ input: v.strictObject({ ...exportInputs }),execute: async (figma, args) => {const { renderNodesToSVG } = await import('#core/io/formats/svg')const pageId = figma.currentPageId@@ -87,7 +87,7 @@ export const exportPDF = defineTool({'Export nodes as a vector PDF document. Text remains selectable, paths stay sharp at any zoom. Returns base64-encoded PDF data.',execution: { kind: 'async', mutation: 'none' },exposure: { webmcp: false },- input: v.object({ ...exportInputs }),+ input: v.strictObject({ ...exportInputs }),execute: async (figma, args) => {const { renderNodesToPDF } = await import('#core/io/formats/pdf')const pageId = figma.currentPageId@@ -106,7 +106,7 @@ export const exportImage = defineTool({'Export nodes as a raster image (PNG, JPG, or WEBP). Returns base64-encoded image data. Use to visually verify designs.',execution: { kind: 'async', mutation: 'none' },exposure: { webmcp: false },- input: v.object({+ input: v.strictObject({...exportInputs,format: v.optional(v.pipe(v.picklist(['PNG', 'JPG', 'WEBP']), v.description('Image format')),diff --git a/packages/core/src/tools/vector/path.ts b/packages/core/src/tools/vector/path.tsindex ca494cbae..eb6e80670 100644--- a/packages/core/src/tools/vector/path.ts+++ b/packages/core/src/tools/vector/path.ts@@ -37,7 +37,7 @@ export const pathSet = defineTool({description: 'Set vector path data on a node. Provide a VectorNetwork JSON.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,path: v.pipe(v.string(), v.description('VectorNetwork JSON'))}),@@ -56,7 +56,7 @@ export const pathScale = defineTool({description: 'Scale vector path from center.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,factor: toolNumber(v.pipe(v.number(), v.description('Scale factor (e.g. 2 for double)')))}),@@ -87,7 +87,7 @@ export const pathFlip = defineTool({description: 'Flip vector path horizontally or vertically.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,axis: v.pipe(v.picklist(['horizontal', 'vertical']), v.description('Flip axis'))}),@@ -118,7 +118,7 @@ export const pathMove = defineTool({description: 'Move all path points by an offset.',execution: { kind: 'sync', mutation: 'document' },- input: v.object({+ input: v.strictObject({id: nodeIdInput,dx: toolNumber(v.pipe(v.number(), v.description('X offset'))),dy: toolNumber(v.pipe(v.number(), v.description('Y offset')))diff --git a/packages/core/src/tools/vector/viewport.ts b/packages/core/src/tools/vector/viewport.tsindex 917356b8f..e663078fa 100644--- a/packages/core/src/tools/vector/viewport.ts+++ b/packages/core/src/tools/vector/viewport.ts@@ -8,7 +8,7 @@ export const viewportGet = defineTool({description: 'Get current viewport position and zoom level.',execution: { kind: 'sync', mutation: 'none' },exposure: { webmcp: false },- input: v.object({}),+ input: v.strictObject({}),execute: (figma) => {return figma.viewport}@@ -19,7 +19,7 @@ export const viewportSet = defineTool({description: 'Set viewport position and zoom.',execution: { kind: 'sync', mutation: 'view' },- input: v.object({+ input: v.strictObject({x: toolNumber(v.pipe(v.number(), v.description('Center X'))),y: toolNumber(v.pipe(v.number(), v.description('Center Y'))),zoom: toolNumber(v.pipe(v.number(), v.minValue(0.01), v.description('Zoom level')))@@ -35,7 +35,7 @@ export const viewportZoomToFit = defineTool({description: 'Zoom viewport to fit specified nodes.',execution: { kind: 'sync', mutation: 'view' },- input: v.object({+ input: v.strictObject({ids: v.pipe(v.array(v.string()), v.minLength(1), v.description('Node IDs to fit in view'))}),execute: (figma, { ids }) => {diff --git a/packages/core/tests/tools/ai-adapter.test.ts b/packages/core/tests/tools/ai-adapter.test.tsindex 99d0b1932..323dfd6fd 100644--- a/packages/core/tests/tools/ai-adapter.test.ts+++ b/packages/core/tests/tools/ai-adapter.test.ts@@ -21,7 +21,7 @@ function adapt(output: unknown): ModelOutputTool {name: 'image_tool',description: 'Returns a fixed result',execution: { kind: 'sync', mutation: 'none' },- input: v.object({}),+ input: v.strictObject({}),execute: () => output})const figma = new FigmaAPI(new SceneGraph())@@ -95,7 +95,7 @@ async function runLogged(execute: () => unknown) {name: 'logged_tool',description: 'Runs the given body',execution: { kind: 'sync', mutation: 'none' },- input: v.object({}),+ input: v.strictObject({}),execute})const figma = new FigmaAPI(new SceneGraph())diff --git a/packages/core/tests/tools/schema.test.ts b/packages/core/tests/tools/schema.test.tsindex a4812c70e..79e513233 100644--- a/packages/core/tests/tools/schema.test.ts+++ b/packages/core/tests/tools/schema.test.ts@@ -3,20 +3,26 @@ import { describe, expect, test } from 'bun:test'import * as v from 'valibot'import { FigmaAPI } from '@open-pencil/core/figma-api'-import { defineTool } from '@open-pencil/core/tools'+import { ALL_TOOLS, defineTool } from '@open-pencil/core/tools'import { SceneGraph } from '@open-pencil/scene-graph'const tool = defineTool({name: 'place_box',description: 'Places a box',execution: { kind: 'sync', mutation: 'none' },- input: v.object({+ input: v.strictObject({kind: v.picklist(['FRAME', 'RECTANGLE']),width: v.pipe(v.number(), v.minValue(1))}),execute: (_figma, args) => args})+function builtIn(name: string) {+ const def = ALL_TOOLS.find((candidate) => candidate.name === name)+ if (!def) throw new Error(`Missing tool ${name}`)+ return def+}+describe('tool arguments', () => {test('name the tool and list every problem with its argument', () => {const figma = new FigmaAPI(new SceneGraph())@@ -35,4 +41,22 @@ describe('tool arguments', () => {const figma = new FigmaAPI(new SceneGraph())expect(tool.execute(figma, { kind: 'FRAME', width: 10 })).toEqual({ kind: 'FRAME', width: 10 })})++ test('reject arguments the tool does not take instead of dropping them', () => {+ const figma = new FigmaAPI(new SceneGraph())+ expect(() => tool.execute(figma, { kind: 'FRAME', width: 10, height: 10 })).toThrow(+ 'Invalid arguments for place_box'+ )++ // Mis-nested calls that once succeeded as no-ops.+ const rect = figma.createRectangle()+ expect(() =>+ builtIn('update_node').execute(figma, { id: rect.id, properties: { x: 0, y: 500 } })+ ).toThrow('Invalid arguments for update_node')+ expect(rect.y).toBe(0)+ const text = figma.createText()+ expect(() =>+ builtIn('set_font').execute(figma, { id: text.id, font: { family: 'Verdana' } })+ ).toThrow('Invalid arguments for set_font')+ })})diff --git a/packages/mcp/src/tool/registration.ts b/packages/mcp/src/tool/registration.tsindex 3687117f4..9684b1cc2 100644--- a/packages/mcp/src/tool/registration.ts+++ b/packages/mcp/src/tool/registration.ts@@ -120,7 +120,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOptiondef.name,{description: def.description,- inputSchema: v.object({ ...def.input.entries, ...automationTargetSchema })+ inputSchema: v.strictObject({ ...def.input.entries, ...automationTargetSchema })},async (args: Record<string, unknown>) => {try {@@ -184,7 +184,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption{description:'List open OpenPencil documents/tabs with their IDs, file paths, current pages, and pages.',- inputSchema: v.object({})+ inputSchema: v.strictObject({})},async () => {try {@@ -205,7 +205,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption? 'Save the current document to disk. If path is provided, it must be inside the configured MCP root.': 'Save the current document to disk. Uses the existing file path if available, otherwise prompts for a location.',inputSchema: resolvedRoot- ? v.object({+ ? v.strictObject({path: v.optional(v.pipe(v.string(),@@ -215,7 +215,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption),...automationTargetSchema})- : v.object({ ...automationTargetSchema })+ : v.strictObject({ ...automationTargetSchema })},async (args: { path?: string; document_id?: string; page_id?: string }) => {try {@@ -245,7 +245,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption'open_file',{description: 'Open a .fig or .pen file from inside the configured MCP root.',- inputSchema: v.object({+ inputSchema: v.strictObject({path: v.pipe(v.string(),v.minLength(1),@@ -278,7 +278,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption{description:'Create a new empty document with an optional save path inside the configured MCP root.',- inputSchema: v.object({+ inputSchema: v.strictObject({path: v.optional(v.pipe(v.string(),@@ -326,7 +326,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption'close_file',{inputSchema: resolvedRoot- ? v.object({+ ? v.strictObject({...closeEntries,path: v.optional(v.pipe(@@ -338,7 +338,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption))})- : v.object(closeEntries)+ : v.strictObject(closeEntries)},async (args: {unsaved?: 'error' | 'save' | 'discard'@@ -367,7 +367,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOptionregister('activate_document',{- inputSchema: v.object({+ inputSchema: v.strictObject({document_id: v.pipe(v.string(), v.description('Document/tab ID from list_documents')),page_id: automationTargetSchema.page_id})@@ -384,18 +384,22 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption)for (const command of ['undo', 'redo'] as const) {- register(command, { inputSchema: v.object({ ...automationTargetSchema }) }, async (args) => {- try {- const { target } = splitAutomationTarget(args)- const res = await sendCommand(sendRPC, command, target)- return ok(withTarget({ ...(res.result as RPCJSONObject | undefined) }, res))- } catch (e) {- return fail(e)+ register(+ command,+ { inputSchema: v.strictObject({ ...automationTargetSchema }) },+ async (args) => {+ try {+ const { target } = splitAutomationTarget(args)+ const res = await sendCommand(sendRPC, command, target)+ return ok(withTarget({ ...(res.result as RPCJSONObject | undefined) }, res))+ } catch (e) {+ return fail(e)+ }}- })+ )}- register('get_settings', { inputSchema: v.object({}) }, async () => {+ register('get_settings', { inputSchema: v.strictObject({}) }, async () => {try {const res = await sendCommand(sendRPC, 'get_settings', {})return ok(res.result ?? {})@@ -407,7 +411,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOptionregister('update_settings',{- inputSchema: v.object({+ inputSchema: v.strictObject({settings: v.pipe(v.record(v.string(), v.unknown()),v.description(@@ -432,7 +436,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption{description:'Get design-to-code generation guidelines. Call before generating frontend code.',- inputSchema: v.object({})+ inputSchema: v.strictObject({})},async () => ok({ prompt: CODEGEN_PROMPT }))diff --git a/tests/engine/mcp/server/index.test.ts b/tests/engine/mcp/server/index.test.tsindex dfc7c5d31..bb9faf7d6 100644--- a/tests/engine/mcp/server/index.test.ts+++ b/tests/engine/mcp/server/index.test.ts@@ -270,6 +270,21 @@ describe('MCP server', () => {expect(fill.isError).not.toBe(true)})+ test('rejects arguments a tool does not take instead of dropping them', async () => {+ const create = await client.callTool({+ name: 'create_shape',+ arguments: { type: 'RECTANGLE', x: 0, y: 0, width: 50, height: 50 }+ })+ const { id } = parseResult(create) as { id: string }++ const update = await client.callTool({+ name: 'update_node',+ arguments: { id, properties: { x: 0, y: 500 } }+ })+ expect(update.isError).toBe(true)+ expect(graph.getNode(id)?.y).toBe(0)+ })+test('get_page_tree returns page structure', async () => {await client.callTool({name: 'create_shape',diff --git a/tests/engine/tools/input.test.ts b/tests/engine/tools/input.test.tsindex 2136db1be..cb3910108 100644--- a/tests/engine/tools/input.test.ts+++ b/tests/engine/tools/input.test.ts@@ -63,13 +63,14 @@ describe('native tool input contracts', () => {{ name: 'update_node', field: 'font_weight', invalid: [99, 901], valid: [100, 900] }])('$name validates $field before execution', ({ name, field, invalid, valid }) => {const input = getTool(name).input+ const base = 'id' in input.entries ? { id: 'node' } : {}for (const value of invalid) {- expect(v.safeParse(input, { id: 'node', [field]: value }).success).toBe(false)- expect(v.safeParse(input, { id: 'node', [field]: String(value) }).success).toBe(false)+ expect(v.safeParse(input, { ...base, [field]: value }).success).toBe(false)+ expect(v.safeParse(input, { ...base, [field]: String(value) }).success).toBe(false)}for (const value of valid) {- expect(v.safeParse(input, { id: 'node', [field]: value }).success).toBe(true)- expect(v.safeParse(input, { id: 'node', [field]: String(value) }).success).toBe(true)+ expect(v.safeParse(input, { ...base, [field]: value }).success).toBe(true)+ expect(v.safeParse(input, { ...base, [field]: String(value) }).success).toBe(true)}})