AI-native design editor. Open-source Figma alternative.
refactor(tools): default interface exposure to inclusion
Danila Poyarkov46aa00d3d1f5
diff --git a/AGENTS.md b/AGENTS.mdindex 43653097d..216d0f355 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -108,7 +108,7 @@ Use Conventional Commits (`feat`, `fix`, `refactor`, `perf`, `docs`, `test`, `bu## Tools (AI / MCP / CLI)-- Core operations are `ToolDef`s under `packages/core/src/tools/**`; `schema.ts` defines their contract and registries expose them. Each definition owns its native Valibot `input`, execution/mutation metadata, and explicit browser exposure. Infer arguments from the schema; derive effects and default capabilities from execution metadata instead of maintaining parameter DSLs or tool-name lists. Add work to the nearest existing domain and the appropriate registry.+- Core operations are `ToolDef`s under `packages/core/src/tools/**`; `schema.ts` defines their contract and registries expose them. Each definition owns its native Valibot `input`, execution/mutation metadata, and optional per-interface exposure exclusions (`mcp`, `ai`, `webmcp`). Exposure defaults to inclusion; adapters use `isToolExposed()`, then apply execution support and user permissions independently. Infer arguments from the schema; derive effects and default capabilities from execution metadata instead of maintaining parameter DSLs or tool-name lists. Add work to the nearest existing domain and the appropriate registry.- `ai-adapter.ts` converts ToolDefs for Vercel AI; `src/app/ai/tools/index.ts` binds them to the active editor's `FigmaAPI`.- CLI commands own CLI UX independently; `eval` exposes operations through `FigmaAPI`.- MCP-only filesystem/server tools live in `packages/mcp/src/tool/registration.ts`; listener/session lifecycle lives under `server/`, stdio under `stdio/`, and transport discovery under `transport/`. File access must resolve symlinks inside the effective MCP root; CLI defaults are cwd on macOS/Linux and home on Windows.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 67aa9f452..4a8e488ea 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,7 +4,7 @@### Breaking changes-- Use MCP SDK v2 server/client types for programmatic MCP integrations. Define custom tools with native Valibot `input` schemas and execution metadata instead of `params`, `ParamDef`, or `paramToZod()`; tool arguments and effects derive from this shared contract.+- Use MCP SDK v2 server/client types for programmatic MCP integrations. Define custom tools with native Valibot `input` schemas and execution metadata instead of `params`, `ParamDef`, or `paramToZod()`; tool arguments and effects derive from this shared contract. Tool exposure defaults to inclusion, with independent `mcp`, `ai`, and `webmcp` exclusions; execution support and user permissions still apply.- Update custom Vue SDK binding providers to implement `getBindingId()` and handle `unresolved`. Replace `setValue()` with `prepareEdit()`, returning a stable edit key, captured value, setter, and restoration callback.### Addeddiff --git a/packages/core/src/tools/ai-adapter.ts b/packages/core/src/tools/ai-adapter.tsindex 6d38d7fc1..3b27b71fd 100644--- a/packages/core/src/tools/ai-adapter.ts+++ b/packages/core/src/tools/ai-adapter.ts@@ -12,7 +12,7 @@ import type { JSONObject } from '@open-pencil/scene-graph/primitives'import type { FigmaAPI } from '#core/figma-api'-import type { ToolDef } from './schema'+import { isToolExposed, type ToolDef } from './schema'export interface ToolLogEntry {tool: string@@ -149,6 +149,7 @@ export function toolsToAI(const result: ToolSet = {}for (const def of tools) {+ if (!isToolExposed(def, 'ai')) continueconst toolOpts: Record<string, unknown> = {description: def.description,inputSchema: toStandardJSONSchema(def.input),diff --git a/packages/core/src/tools/analyze/clusters.ts b/packages/core/src/tools/analyze/clusters.tsindex e9e6133d8..59c90cb18 100644--- a/packages/core/src/tools/analyze/clusters.ts+++ b/packages/core/src/tools/analyze/clusters.ts@@ -31,6 +31,7 @@ export const analyzeClusters = defineTool({description:'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({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 94f57d827..f3c9e0087 100644--- a/packages/core/src/tools/analyze/colors.ts+++ b/packages/core/src/tools/analyze/colors.ts@@ -31,7 +31,6 @@ 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' },- exposure: { webmcp: true },input: v.object({limit: analysisLimitInput,show_similar: v.optional(diff --git a/packages/core/src/tools/analyze/diff.ts b/packages/core/src/tools/analyze/diff.tsindex ad3f38da5..9a4f7253a 100644--- a/packages/core/src/tools/analyze/diff.ts+++ b/packages/core/src/tools/analyze/diff.ts@@ -126,6 +126,7 @@ export const diffCreate = defineTool({description:'Create a structural diff between two node trees. Compares properties (fills, strokes, effects, text, size, position) in unified diff format.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({from: v.pipe(v.string(), v.description('Source node ID')),to: v.pipe(v.string(), v.description('Target node ID')),@@ -181,6 +182,7 @@ export const diffShow = defineTool({description:'Preview what would change if properties were applied to a node. Shows a unified diff of current vs proposed state.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({id: nodeIdInput,props: v.pipe(diff --git a/packages/core/src/tools/analyze/overlaps/index.ts b/packages/core/src/tools/analyze/overlaps/index.tsindex 0cebb151d..7c69607c4 100644--- a/packages/core/src/tools/analyze/overlaps/index.ts+++ b/packages/core/src/tools/analyze/overlaps/index.ts@@ -335,6 +335,7 @@ export const analyzeOverlaps = defineTool({description:'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({scope: v.optional(v.pipe(diff --git a/packages/core/src/tools/analyze/spacing.ts b/packages/core/src/tools/analyze/spacing.tsindex f71e01065..0e070690d 100644--- a/packages/core/src/tools/analyze/spacing.ts+++ b/packages/core/src/tools/analyze/spacing.ts@@ -9,7 +9,6 @@ export const analyzeSpacing = defineTool({description:'Analyze spacing values (gap, padding) across the current page. Checks grid compliance.',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({grid: v.optional(toolNumber(diff --git a/packages/core/src/tools/analyze/typography.ts b/packages/core/src/tools/analyze/typography.tsindex 9d4800d9d..46239a31f 100644--- a/packages/core/src/tools/analyze/typography.ts+++ b/packages/core/src/tools/analyze/typography.ts@@ -10,7 +10,6 @@ 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' },- exposure: { webmcp: true },input: v.object({limit: analysisLimitInput,group_by: v.optional(diff --git a/packages/core/src/tools/calc.ts b/packages/core/src/tools/calc.tsindex 3181d36a6..102dad4e5 100644--- a/packages/core/src/tools/calc.ts+++ b/packages/core/src/tools/calc.ts@@ -27,6 +27,7 @@ export const calc = defineTool({'Supports: + - * / % ** ( ) min max floor ceil round abs sqrt pow. ' +'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({expr: v.pipe(v.string(), v.description('Single expression or JSON array of expressions'))}),diff --git a/packages/core/src/tools/codegen/component-map.ts b/packages/core/src/tools/codegen/component-map.tsindex 82d54d20c..73d00085f 100644--- a/packages/core/src/tools/codegen/component-map.ts+++ b/packages/core/src/tools/codegen/component-map.ts@@ -115,7 +115,6 @@ 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' },- exposure: { webmcp: true },input: v.object({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 3fdc54c54..fea676278 100644--- a/packages/core/src/tools/codegen/tokens.ts+++ b/packages/core/src/tools/codegen/tokens.ts@@ -167,7 +167,6 @@ export const designToTokens = defineTool({description:'Extract design tokens from Figma variables as CSS custom properties, Tailwind theme config, or JSON. Resolves aliases, handles multiple modes (light/dark).',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({format: v.optional(v.pipe(v.picklist(['css', 'tailwind', 'json']), v.description('Output format')),diff --git a/packages/core/src/tools/create/icons.ts b/packages/core/src/tools/create/icons.tsindex b2482d637..5f1a7e3eb 100644--- a/packages/core/src/tools/create/icons.ts+++ b/packages/core/src/tools/create/icons.ts@@ -8,6 +8,7 @@ import { defineTool } from '#core/tools/schema'export const fetchIconsTool = defineTool({name: 'fetch_icons',+ exposure: { webmcp: false },description:'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' },@@ -106,6 +107,7 @@ export const insertIcon = defineTool({export const searchIconsTool = defineTool({name: 'search_icons',+ exposure: { webmcp: false },description:'Search Iconify for icons by keyword. Accepts multiple queries — all searched in parallel. Returns results keyed by query.',execution: { kind: 'async', mutation: 'none' },diff --git a/packages/core/src/tools/describe/index.ts b/packages/core/src/tools/describe/index.tsindex 2475e9b73..bbebbdbc2 100644--- a/packages/core/src/tools/describe/index.ts+++ b/packages/core/src/tools/describe/index.ts@@ -10,6 +10,7 @@ export const describe = defineTool({description:'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({id: v.optional(v.pipe(v.string(), v.description('Node ID (single node)'))),ids: v.optional(diff --git a/packages/core/src/tools/index.ts b/packages/core/src/tools/index.tsindex 783ef827e..ee0970fbb 100644--- a/packages/core/src/tools/index.ts+++ b/packages/core/src/tools/index.ts@@ -17,7 +17,7 @@ export {toolChangesDocument} from './schema'export type { ToolDef, ToolExecution, ToolCapability } from './schema'-export { isAtomicTool } from './schema'+export { isAtomicTool, isToolExposed, type ToolInterface, type ToolExposure } from './schema'export { toolNumber } from './input'export { toolsToAI, buildDebugLog } from './ai-adapter'export type { ToolLogEntry, ToolDebugLog, AIAdapterOptions, StepBudget } from './ai-adapter'diff --git a/packages/core/src/tools/modify/effects.ts b/packages/core/src/tools/modify/effects.tsindex e6d2319c2..61534b219 100644--- a/packages/core/src/tools/modify/effects.ts+++ b/packages/core/src/tools/modify/effects.ts@@ -13,7 +13,6 @@ 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' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,type: v.pipe(diff --git a/packages/core/src/tools/modify/geometry.ts b/packages/core/src/tools/modify/geometry.tsindex 51ab2c83e..3e9295c6f 100644--- a/packages/core/src/tools/modify/geometry.ts+++ b/packages/core/src/tools/modify/geometry.ts@@ -8,7 +8,6 @@ export const setRotation = defineTool({description: 'Set rotation angle of a node in degrees.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,angle: toolNumber(v.pipe(v.number(), v.description('Rotation angle in degrees')))@@ -26,7 +25,6 @@ export const setOpacity = defineTool({description: 'Set opacity of a node (0-1).',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,value: toolNumber(@@ -46,7 +44,6 @@ export const setRadius = defineTool({description: 'Set corner radius. Use individual corners for independent values.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,radius: v.optional(@@ -94,7 +91,6 @@ export const setMinMax = defineTool({description: 'Set min/max width and height constraints on a node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,min_width: v.optional(diff --git a/packages/core/src/tools/modify/layout.ts b/packages/core/src/tools/modify/layout.tsindex 8e05ff8ed..239af8fd3 100644--- a/packages/core/src/tools/modify/layout.ts+++ b/packages/core/src/tools/modify/layout.ts@@ -10,7 +10,6 @@ export const setLayout = defineTool({description: 'Set auto-layout (flexbox) on a frame. Direction, alignment, spacing, padding.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: v.pipe(v.string(), v.description('Frame node ID')),direction: v.optional(@@ -109,7 +108,6 @@ export const setConstraints = defineTool({description: 'Set resize constraints for a node within its parent.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,horizontal: v.optional(@@ -144,7 +142,6 @@ export const setLayoutChild = defineTool({description:'Configure auto-layout child: sizing (FIXED/HUG/FILL), grow, alignment, absolute positioning.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: v.pipe(v.string(), v.description('Child node ID')),sizing_horizontal: v.optional(diff --git a/packages/core/src/tools/modify/paint.ts b/packages/core/src/tools/modify/paint.tsindex 8f37e73f6..3026bb6a2 100644--- a/packages/core/src/tools/modify/paint.ts+++ b/packages/core/src/tools/modify/paint.ts@@ -14,7 +14,6 @@ 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' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,color: v.pipe(v.string(), v.description('Color (hex). For gradient: start color.')),@@ -68,7 +67,6 @@ export const setStroke = defineTool({description: 'Set the stroke (border) of a node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,color: v.pipe(v.string(), v.description('Stroke color (hex)')),diff --git a/packages/core/src/tools/modify/state.ts b/packages/core/src/tools/modify/state.tsindex 105f35041..1d5202ea9 100644--- a/packages/core/src/tools/modify/state.ts+++ b/packages/core/src/tools/modify/state.ts@@ -8,7 +8,6 @@ export const setVisible = defineTool({description: 'Set visibility of a node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,value: v.pipe(v.boolean(), v.description('Visible (true/false)'))@@ -26,7 +25,6 @@ export const setBlend = defineTool({description: 'Set blend mode of a node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,mode: v.pipe(@@ -64,7 +62,6 @@ export const setLocked = defineTool({description: 'Set locked state of a node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,value: v.pipe(v.boolean(), v.description('Locked (true/false)'))@@ -82,7 +79,6 @@ export const setStrokeAlign = defineTool({description: 'Set stroke alignment of a node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({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 4963a509b..2af5d6906 100644--- a/packages/core/src/tools/modify/text.ts+++ b/packages/core/src/tools/modify/text.ts@@ -13,7 +13,6 @@ export const setText = defineTool({description: 'Set text content of a text node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,text: v.pipe(v.string(), v.description('Text content'))@@ -31,7 +30,6 @@ export const setFont = defineTool({description: 'Set font properties of a text node.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,family: v.optional(v.pipe(v.string(), v.description('Font family name'))),@@ -60,7 +58,6 @@ export const setFontRange = defineTool({description: 'Set font properties for a text range.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,start: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Start character index'))),@@ -97,7 +94,6 @@ export const setTextResize = defineTool({description: 'Set text auto-resize mode.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,mode: v.pipe(@@ -119,7 +115,6 @@ export const setTextProperties = defineTool({description:'Set text layout properties: alignment, auto-resize, text case, decoration, truncation.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: v.pipe(v.string(), v.description('Text node ID')),align_horizontal: v.optional(diff --git a/packages/core/src/tools/modify/update.ts b/packages/core/src/tools/modify/update.tsindex 5fb1fde6b..41f6a3fcc 100644--- a/packages/core/src/tools/modify/update.ts+++ b/packages/core/src/tools/modify/update.ts@@ -12,7 +12,6 @@ export const updateNode = defineTool({description:'Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,x: v.optional(toolNumber(v.pipe(v.number(), v.description('X position')))),diff --git a/packages/core/src/tools/read/components.ts b/packages/core/src/tools/read/components.tsindex ae5addb44..c0c8f6b9f 100644--- a/packages/core/src/tools/read/components.ts+++ b/packages/core/src/tools/read/components.ts@@ -30,7 +30,6 @@ export const getComponents = defineTool({description:'List reusable components from the document and enabled component libraries, optionally filtered by name.',execution: { kind: 'async', mutation: 'none' },- exposure: { webmcp: true },input: v.object({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 279aca8bc..1014d1aa1 100644--- a/packages/core/src/tools/read/fonts.ts+++ b/packages/core/src/tools/read/fonts.ts@@ -9,6 +9,7 @@ export const getFontStatus = defineTool({'Report whether fonts used on the current page are faithfully available. Returns requested ' +'faces, their loaded source, active substitutions, and affected nodes.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({}),execute: (figma) => figma.getFontStatus()})@@ -17,6 +18,7 @@ export const listFonts = defineTool({name: 'list_fonts',description: 'List fonts used in the current page.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({family: v.optional(v.pipe(v.string(), v.description('Filter by family name (substring)')))}),@@ -53,6 +55,7 @@ export const listAvailableFonts = defineTool({'Use this to discover what fonts are available to set on a text node — distinct from list_fonts ' +'which only reports families currently used in the page.',execution: { kind: 'async', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({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 7db226058..4622df03f 100644--- a/packages/core/src/tools/read/jsx.ts+++ b/packages/core/src/tools/read/jsx.ts@@ -12,7 +12,6 @@ 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' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,path: v.optional(@@ -46,6 +45,7 @@ export const diffJSX = defineTool({description:'Structural diff between two nodes in JSX format. Shows added/removed children, changed props.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({from: v.pipe(v.string(), v.description('Source node ID')),to: v.pipe(v.string(), v.description('Target node ID'))diff --git a/packages/core/src/tools/read/libraries.ts b/packages/core/src/tools/read/libraries.tsindex 34b2926cf..8bf404515 100644--- a/packages/core/src/tools/read/libraries.ts+++ b/packages/core/src/tools/read/libraries.ts@@ -8,6 +8,7 @@ export const listLibraries = defineTool({name: 'list_libraries',description: 'List available published component libraries.',execution: { kind: 'async', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({}),execute: async (figma) => {const catalog = getComponentCatalog(figma.graph)diff --git a/packages/core/src/tools/read/nodes.ts b/packages/core/src/tools/read/nodes.tsindex c5048737e..490cec498 100644--- a/packages/core/src/tools/read/nodes.ts+++ b/packages/core/src/tools/read/nodes.ts@@ -46,7 +46,6 @@ 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' },- exposure: { webmcp: true },input: v.object({depth: v.optional(toolNumber(@@ -97,7 +96,6 @@ 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' },- exposure: { webmcp: true },input: v.object({id: nodeIdInput,depth: v.optional(@@ -120,7 +118,6 @@ export const findNodes = defineTool({name: 'find_nodes',description: 'Find nodes by name pattern and/or type.',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({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 41a5df5a8..ed783acdf 100644--- a/packages/core/src/tools/read/pages.ts+++ b/packages/core/src/tools/read/pages.ts@@ -8,7 +8,6 @@ export const listPages = defineTool({name: 'list_pages',description: 'List all pages in the document.',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({}),execute: (figma) => {const pages = figma.root.children@@ -40,7 +39,6 @@ export const getCurrentPage = defineTool({name: 'get_current_page',description: 'Get the current page name and ID.',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({}),execute: (figma) => {return { id: figma.currentPage.id, name: figma.currentPage.name }@@ -51,6 +49,7 @@ export const pageBounds = defineTool({name: 'page_bounds',description: 'Get bounding box of all objects on the current page.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({}),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 df8aa349d..4c7c14245 100644--- a/packages/core/src/tools/read/query.ts+++ b/packages/core/src/tools/read/query.ts@@ -17,6 +17,7 @@ Examples://*[@cornerRadius > 0] — any node with corner radius//TEXT[contains(@text, 'Hello')] — text nodes containing "Hello"`,execution: { kind: 'async', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({selector: v.pipe(v.string(), v.description('XPath selector')),page: v.optional(v.pipe(v.string(), v.description('Page name (default: current page)'))),diff --git a/packages/core/src/tools/read/selection.ts b/packages/core/src/tools/read/selection.tsindex 09d9374c1..8b580c594 100644--- a/packages/core/src/tools/read/selection.ts+++ b/packages/core/src/tools/read/selection.ts@@ -7,6 +7,7 @@ export const getSelection = defineTool({name: 'get_selection',description: 'Get details about currently selected nodes.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({}),execute: (figma) => {const selection = figma.currentPage.selectiondiff --git a/packages/core/src/tools/schema.ts b/packages/core/src/tools/schema.tsindex a4bb2c24f..f6967124c 100644--- a/packages/core/src/tools/schema.ts+++ b/packages/core/src/tools/schema.ts@@ -23,12 +23,15 @@ export type ToolExecution =| { kind: 'sync'; mutation: 'none' | 'view' | 'properties' | 'document' }| { kind: 'async'; mutation: 'none' | 'view' | 'document' }+export type ToolInterface = 'mcp' | 'ai' | 'webmcp'+export type ToolExposure = Partial<Record<ToolInterface, boolean>>+interface ToolMetadata {name: stringdescription: stringexecution: ToolExecution- /** Explicit browser opt-in, independent of execution or read-only status. */- exposure: { webmcp: boolean }+ /** Interface inclusion defaults to true; execution support and user permissions remain separate. */+ exposure: ToolExposurecapabilities: readonly ToolCapability[]availability: 'default' | 'eval'}@@ -52,7 +55,7 @@ export function defineTool<P extends v.ObjectEntries, R>(): ToolDef {return {...def,- exposure: def.exposure ?? { webmcp: false },+ exposure: def.exposure ?? {},capabilities: def.capabilities ?? [toolChangesDocument(def) ? 'document:write' : 'document:read'],@@ -68,6 +71,10 @@ export function toolChangesDocument(def: Pick<ToolDef, 'execution'>): boolean {return def.execution.mutation === 'properties' || def.execution.mutation === 'document'}+export function isToolExposed(def: Pick<ToolDef, 'exposure'>, target: ToolInterface): boolean {+ return def.exposure[target] !== false+}+export function isAtomicTool(def: ToolDef): boolean {return def.execution.kind === 'sync' && def.execution.mutation === 'properties'}diff --git a/packages/core/src/tools/structure/basic.ts b/packages/core/src/tools/structure/basic.tsindex d864db681..225003d0a 100644--- a/packages/core/src/tools/structure/basic.ts+++ b/packages/core/src/tools/structure/basic.ts@@ -56,6 +56,7 @@ export const nodeBounds = defineTool({name: 'node_bounds',description: 'Get absolute bounding box of a node.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: nodeInput,execute: (figma, { id }) => {const node = figma.getNodeById(id)diff --git a/packages/core/src/tools/structure/tree.ts b/packages/core/src/tools/structure/tree.tsindex 1049d1574..a74785f2d 100644--- a/packages/core/src/tools/structure/tree.ts+++ b/packages/core/src/tools/structure/tree.ts@@ -8,6 +8,7 @@ export const nodeAncestors = defineTool({name: 'node_ancestors',description: 'Get the ancestor chain from a node to the page root.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({id: nodeIdInput,depth: v.optional(toolNumber(v.pipe(v.number(), v.description('Max depth to traverse'))))@@ -31,6 +32,7 @@ export const nodeChildren = defineTool({name: 'node_children',description: 'Get direct children of a node.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: nodeInput,execute: (figma, { id }) => {const node = figma.getNodeById(id)@@ -43,6 +45,7 @@ export const nodeTree = defineTool({name: 'node_tree',description: 'Get a node tree with types and hierarchy.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({id: nodeIdInput,depth: v.optional(@@ -73,6 +76,7 @@ export const nodeBindings = defineTool({name: 'node_bindings',description: 'Get variable bindings for a node.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: nodeInput,execute: (figma, { id }) => {const result = getRawNodeOrError(figma, id)diff --git a/packages/core/src/tools/variables/bindings.ts b/packages/core/src/tools/variables/bindings.tsindex 7d6fe33a5..ece6c63c3 100644--- a/packages/core/src/tools/variables/bindings.ts+++ b/packages/core/src/tools/variables/bindings.ts@@ -9,7 +9,6 @@ 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' },- exposure: { webmcp: true },input: v.object({node_id: nodeIdInput,field: v.pipe(diff --git a/packages/core/src/tools/variables/collections.ts b/packages/core/src/tools/variables/collections.tsindex de96c93f4..b205cbe41 100644--- a/packages/core/src/tools/variables/collections.ts+++ b/packages/core/src/tools/variables/collections.ts@@ -6,7 +6,6 @@ export const listCollections = defineTool({name: 'list_collections',description: 'List all variable collections.',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({}),execute: (figma) => {const collections = figma.getLocalVariableCollections()@@ -18,6 +17,7 @@ export const getCollection = defineTool({name: 'get_collection',description: 'Get a variable collection by ID.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({id: v.pipe(v.string(), v.description('Collection ID'))}),diff --git a/packages/core/src/tools/variables/read.ts b/packages/core/src/tools/variables/read.tsindex 09b9ebd56..392b0cbf3 100644--- a/packages/core/src/tools/variables/read.ts+++ b/packages/core/src/tools/variables/read.ts@@ -6,7 +6,6 @@ export const listVariables = defineTool({name: 'list_variables',description: 'List all design variables (colors, numbers, strings, booleans).',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({type: v.optional(v.pipe(@@ -25,7 +24,6 @@ export const getVariable = defineTool({name: 'get_variable',description: 'Get a variable by ID.',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({id: v.pipe(v.string(), v.description('Variable ID'))}),@@ -40,7 +38,6 @@ export const findVariables = defineTool({name: 'find_variables',description: 'Find variables by name pattern.',execution: { kind: 'sync', mutation: 'none' },- exposure: { webmcp: true },input: v.object({query: v.pipe(v.string(), v.description('Name substring (case-insensitive)')),type: v.optional(diff --git a/packages/core/src/tools/variables/unbind.ts b/packages/core/src/tools/variables/unbind.tsindex 06ec7f75e..43763bb9b 100644--- a/packages/core/src/tools/variables/unbind.ts+++ b/packages/core/src/tools/variables/unbind.ts@@ -8,7 +8,6 @@ export const unbindVariable = defineTool({description: 'Remove a variable binding from a node property.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({node_id: nodeIdInput,field: v.pipe(diff --git a/packages/core/src/tools/variables/values.ts b/packages/core/src/tools/variables/values.tsindex d8100500e..bd6e4e035 100644--- a/packages/core/src/tools/variables/values.ts+++ b/packages/core/src/tools/variables/values.ts@@ -40,7 +40,6 @@ export const setVariable = defineTool({description: 'Set the value of a variable for a specific mode.',execution: { kind: 'sync', mutation: 'properties' },- exposure: { webmcp: true },input: v.object({id: v.pipe(v.string(), v.description('Variable ID')),mode: v.pipe(v.string(), v.description('Mode ID')),diff --git a/packages/core/src/tools/vector/export.ts b/packages/core/src/tools/vector/export.tsindex de419bb14..16c650ca2 100644--- a/packages/core/src/tools/vector/export.ts+++ b/packages/core/src/tools/vector/export.ts@@ -27,6 +27,7 @@ export const exportSVG = defineTool({name: 'export_svg',description: 'Export nodes as SVG markup. Returns the SVG string.',execution: { kind: 'async', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({ ...exportInputs }),execute: async (figma, args) => {const { renderNodesToSVG } = await import('#core/io/formats/svg')@@ -44,6 +45,7 @@ export const exportPDF = defineTool({description:'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 }),execute: async (figma, args) => {const { renderNodesToPDF } = await import('#core/io/formats/pdf')@@ -62,6 +64,7 @@ export const exportImage = defineTool({description:'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({...exportInputs,format: v.optional(diff --git a/packages/core/src/tools/vector/path.ts b/packages/core/src/tools/vector/path.tsindex 997d2827f..1754f01c9 100644--- a/packages/core/src/tools/vector/path.ts+++ b/packages/core/src/tools/vector/path.ts@@ -21,6 +21,7 @@ export const pathGet = defineTool({name: 'path_get',description: 'Get vector path data of a node.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: nodeInput,execute: (figma, { id }) => {const raw = figma.graph.getNode(id)diff --git a/packages/core/src/tools/vector/viewport.ts b/packages/core/src/tools/vector/viewport.tsindex 76fee53fc..917356b8f 100644--- a/packages/core/src/tools/vector/viewport.ts+++ b/packages/core/src/tools/vector/viewport.ts@@ -7,6 +7,7 @@ export const viewportGet = defineTool({name: 'viewport_get',description: 'Get current viewport position and zoom level.',execution: { kind: 'sync', mutation: 'none' },+ exposure: { webmcp: false },input: v.object({}),execute: (figma) => {return figma.viewportdiff --git a/packages/docs/programmable/mcp-server.md b/packages/docs/programmable/mcp-server.mdindex 718ca8161..98ac8f390 100644--- a/packages/docs/programmable/mcp-server.md+++ b/packages/docs/programmable/mcp-server.md@@ -9,7 +9,7 @@ OpenPencil includes an MCP (Model Context Protocol) server that lets AI coding tTwo transports: **stdio** for MCP clients, and **Streamable HTTP** for browser extensions and scripts. On macOS and Linux, local clients prefer a private Unix domain socket; Windows and unavailable sockets fall back to localhost TCP.-Tool definitions own native Valibot input schemas, execution/mutation metadata, capabilities, and explicit browser exposure. AI and MCP consume the same schema through Standard Schema; WebMCP derives its JSON Schema from that input. Numeric strings are accepted consistently across adapters, while non-finite values are rejected. Programmatic integrations use MCP SDK v2; custom tools replace the former `params`/`ParamDef` contract with `input` and execution metadata.+Tool definitions own native Valibot input schemas, execution/mutation metadata, capabilities, and optional interface exposure exclusions. Tools are included by default; `exposure: { mcp: false, ai: false, webmcp: false }` can exclude them independently from each adapter. Exposure does not bypass execution support or user permissions: WebMCP still requires supported execution and explicit Off, Inspect, or Edit access. AI and MCP consume the same schema through Standard Schema; WebMCP derives its JSON Schema from that input. Numeric strings are accepted consistently across adapters, while non-finite values are rejected. Programmatic integrations use MCP SDK v2; custom tools replace the former `params`/`ParamDef` contract with `input` and execution metadata.## Browser-native WebMCP (experimental) {#webmcp}diff --git a/packages/mcp/src/tool/manifest.ts b/packages/mcp/src/tool/manifest.tsindex 81117f6d0..bce25edcf 100644--- a/packages/mcp/src/tool/manifest.ts+++ b/packages/mcp/src/tool/manifest.ts@@ -1,5 +1,5 @@import type { ToolDef } from '@open-pencil/core/tools'-import { ALL_TOOLS, toolChangesDocument } from '@open-pencil/core/tools'+import { ALL_TOOLS, toolChangesDocument, isToolExposed } from '@open-pencil/core/tools'import type {ToolAvailability,@@ -31,8 +31,12 @@ function coreToolDescriptor(def: ToolDef): ToolDescriptor {}}+export function getMCPToolDefinitions() {+ return ALL_TOOLS.filter((def) => isToolExposed(def, 'mcp'))+}+export function createToolDescriptors(filesystemEnabled: boolean): ToolDescriptor[] {- const descriptors = ALL_TOOLS.map(coreToolDescriptor)+ const descriptors = getMCPToolDefinitions().map(coreToolDescriptor)descriptors.push({name: 'list_documents',diff --git a/packages/mcp/src/tool/registration.ts b/packages/mcp/src/tool/registration.tsindex 41ebbcbda..61c7fc7c9 100644--- a/packages/mcp/src/tool/registration.ts+++ b/packages/mcp/src/tool/registration.ts@@ -6,11 +6,11 @@ import type { McpServer, ToolCallback, ToolAnnotations } from '@modelcontextprotimport { toStandardJsonSchema as toStandardJSONSchema } from '@valibot/to-json-schema'import * as v from 'valibot'-import { ALL_TOOLS, CODEGEN_PROMPT } from '@open-pencil/core/tools'+import { CODEGEN_PROMPT } from '@open-pencil/core/tools'import type { RPCJSONObject } from '#mcp/json'import { MAX_RESULT_BYTES, fail, ok, resultTooLargeMessage } from '#mcp/result'-import { createToolDescriptors } from '#mcp/tool/manifest'+import { createToolDescriptors, getMCPToolDefinitions } from '#mcp/tool/manifest'import type { ToolDescriptor, ToolEffect, ToolPolicy } from '#mcp/tool/metadata'import { resolveSafePath, writeToolOutput } from '#mcp/tool/output'import { isToolEnabled } from '#mcp/tool/policy'@@ -78,7 +78,7 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption)}- for (const def of ALL_TOOLS) {+ for (const def of getMCPToolDefinitions()) {register(def.name,{diff --git a/src/app/automation/bridge/tool-handlers.ts b/src/app/automation/bridge/tool-handlers.tsindex ba17b06ed..459af8c90 100644--- a/src/app/automation/bridge/tool-handlers.ts+++ b/src/app/automation/bridge/tool-handlers.ts@@ -1,6 +1,11 @@import { renderTreeNode } from '@open-pencil/core/design-jsx'import type { FigmaAPI } from '@open-pencil/core/figma-api'-import { ALL_TOOLS, registerComponentCatalog, isAtomicTool } from '@open-pencil/core/tools'+import {+ ALL_TOOLS,+ registerComponentCatalog,+ isAtomicTool,+ isToolExposed+} from '@open-pencil/core/tools'import type { JSONObject } from '@open-pencil/scene-graph/primitives'import type { AutomationTarget } from '@/app/automation/bridge/target'@@ -46,7 +51,7 @@ export function createAutomationToolHandler(makeFigma: FigmaFactory) {return handleToolRender(target, toolArgs)}- const def = ALL_TOOLS.find((t) => t.name === toolName)+ const def = ALL_TOOLS.find((t) => t.name === toolName && isToolExposed(t, 'mcp'))if (!def) throw new Error(`Unknown tool: ${toolName}`)const store = target.storeconst libraryService = useLibraryService()diff --git a/src/app/automation/webmcp/policy.ts b/src/app/automation/webmcp/policy.tsindex a216370f0..a6fb0e103 100644--- a/src/app/automation/webmcp/policy.ts+++ b/src/app/automation/webmcp/policy.ts@@ -1,6 +1,6 @@import * as v from 'valibot'-import { ALL_TOOLS } from '@open-pencil/core/tools'+import { ALL_TOOLS, isAtomicTool, isToolExposed, type ToolDef } from '@open-pencil/core/tools'export const webmcpModeSchema = v.picklist(['off', 'inspect', 'edit'])export type WebMCPMode = v.InferOutput<typeof webmcpModeSchema>@@ -10,8 +10,12 @@ export function resolveWebMCPMode(value: unknown): WebMCPMode {return result.success ? result.output : 'off'}-export function getWebMCPTools(mode: WebMCPMode) {- return ALL_TOOLS.filter(- (tool) => tool.exposure.webmcp && mode !== 'off' && (mode === 'edit' || !tool.mutates)+export function getWebMCPTools(mode: WebMCPMode, tools: readonly ToolDef[] = ALL_TOOLS) {+ return tools.filter(+ (tool) =>+ isToolExposed(tool, 'webmcp') &&+ (tool.execution.mutation === 'none' || isAtomicTool(tool)) &&+ mode !== 'off' &&+ (mode === 'edit' || !tool.mutates))}diff --git a/tests/engine/mcp/server/index.test.ts b/tests/engine/mcp/server/index.test.tsindex 4f7e4d3a8..e89ade2ae 100644--- a/tests/engine/mcp/server/index.test.ts+++ b/tests/engine/mcp/server/index.test.ts@@ -10,7 +10,7 @@ import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/cliimport { SceneGraph } from '@open-pencil/scene-graph'import { startServer } from '#mcp/server'-import { createToolDescriptors } from '#mcp/tool/manifest'+import { createToolDescriptors, getMCPToolDefinitions } from '#mcp/tool/manifest'import {connectMockBrowser,@@ -114,6 +114,23 @@ function parseResult(result: { content: { type: string; text?: string }[] }): un// MCP tool + session tests// ---------------------------------------------------------------------------+test('MCP exposure exclusions apply to both descriptors and registered tools', async () => {+ const def = getMCPToolDefinitions().find((tool) => tool.name === 'get_page_tree')+ if (!def) throw new Error('Missing tool fixture')+ const previous = def.exposure+ let context: Awaited<ReturnType<typeof createTestClient>> | undefined+ try {+ def.exposure = { ...previous, mcp: false }+ expect(createToolDescriptors(false).some((tool) => tool.name === def.name)).toBe(false)+ context = await createTestClient()+ const { tools } = await context.client.listTools()+ expect(tools.some((tool) => tool.name === def.name)).toBe(false)+ } finally {+ def.exposure = previous+ await context?.close()+ }+})+describe('MCP server', () => {let client: Clientlet graph: SceneGraphdiff --git a/tests/engine/mcp/webmcp-settings.test.ts b/tests/engine/mcp/webmcp-settings.test.tsindex 79c8a6538..2213294bd 100644--- a/tests/engine/mcp/webmcp-settings.test.ts+++ b/tests/engine/mcp/webmcp-settings.test.ts@@ -3,6 +3,8 @@ import { describe, expect, test } from 'bun:test'import { ref } from 'vue'import type { WebMCP } from 'webmcp-types'+import { ALL_TOOLS, isToolExposed, type ToolDef } from '@open-pencil/core/tools'+import { getWebMCPTools, resolveWebMCPMode, type WebMCPMode } from '@/app/automation/webmcp/policy'import { createWebMCPRuntimeService } from '@/app/automation/webmcp/service'@@ -29,6 +31,39 @@ async function ready(service: ReturnType<typeof createWebMCPRuntimeService>) {}describe('WebMCP access preferences', () => {+ test('default inclusion cannot override execution support or user access', () => {+ const base = ALL_TOOLS[0]+ if (!base) throw new Error('Missing tool fixture')+ const read: ToolDef = {+ ...base,+ name: 'read',+ execution: { kind: 'sync', mutation: 'none' },+ mutates: false,+ exposure: {}+ }+ const edit: ToolDef = {+ ...read,+ name: 'edit',+ execution: { kind: 'sync', mutation: 'properties' },+ mutates: true+ }+ const tools: ToolDef[] = [+ read,+ edit,+ { ...read, name: 'excluded', exposure: { webmcp: false } },+ {+ ...edit,+ name: 'structural',+ execution: { kind: 'sync', mutation: 'document' },+ exposure: { webmcp: true }+ },+ { ...edit, name: 'async', execution: { kind: 'async', mutation: 'document' } }+ ]+ expect(getWebMCPTools('off', tools)).toEqual([])+ expect(getWebMCPTools('inspect', tools).map((tool) => tool.name)).toEqual(['read'])+ expect(getWebMCPTools('edit', tools).map((tool) => tool.name)).toEqual(['read', 'edit'])+ })+test('unrecognized stored access fails closed', () => {for (const value of [undefined, null, true, {}, 'all', 'EDIT']) {expect(resolveWebMCPMode(value)).toBe('off')@@ -38,7 +73,7 @@ describe('WebMCP access preferences', () => {expect(getWebMCPTools('inspect').length).toBeGreaterThan(0)expect(getWebMCPTools('inspect').every((tool) => !tool.mutates)).toBe(true)expect(getWebMCPTools('edit').some((tool) => tool.mutates)).toBe(true)- expect(getWebMCPTools('edit').every((tool) => tool.exposure.webmcp)).toBe(true)+ expect(getWebMCPTools('edit').every((tool) => isToolExposed(tool, 'webmcp'))).toBe(true)})test('reconfigures access and revokes retained callbacks immediately', async () => {diff --git a/tests/engine/tools/ai-adapter.test.ts b/tests/engine/tools/ai-adapter.test.tsindex 632374931..32c4d4ac6 100644--- a/tests/engine/tools/ai-adapter.test.ts+++ b/tests/engine/tools/ai-adapter.test.ts@@ -34,6 +34,22 @@ function setup() {}describe('AI adapter', () => {+ test('honors AI exclusions independently of MCP and WebMCP exposure', () => {+ const base = ALL_TOOLS[0]+ if (!base) throw new Error('Missing tool fixture')+ const { figma } = setup()+ const tools = toolsToAI(+ [+ { ...base, name: 'default', exposure: {} },+ { ...base, name: 'hidden', exposure: { ai: false } },+ { ...base, name: 'other-interface', exposure: { webmcp: false, mcp: false } }+ ],+ { getFigma: () => figma },+ { tool }+ )+ expect(Object.keys(tools)).toEqual(['default', 'other-interface'])+ })+test('generates tool for every definition', () => {const { tools } = setup()for (const def of ALL_TOOLS) {diff --git a/tests/engine/tools/registry.test.ts b/tests/engine/tools/registry.test.tsindex c737bf58c..3ad4cc041 100644--- a/tests/engine/tools/registry.test.ts+++ b/tests/engine/tools/registry.test.ts@@ -3,11 +3,20 @@ import { describe, expect, test } from 'bun:test'// eslint-disable-next-line open-pencil/no-mixed-case-acronym-identifiers -- Upstream export spelling.import { toJsonSchema as toJSONSchema } from '@valibot/to-json-schema'-import { isAtomicTool } from '@open-pencil/core/tools'+import { isAtomicTool, isToolExposed } from '@open-pencil/core/tools'import { ALL_TOOLS } from '#tests/helpers/tools'describe('tool definitions', () => {+ test('exposure defaults to inclusion and exclusions affect only the named interface', () => {+ for (const target of ['mcp', 'ai', 'webmcp'] as const) {+ expect(isToolExposed({ exposure: {} }, target)).toBe(true)+ expect(isToolExposed({ exposure: { [target]: true } }, target)).toBe(true)+ expect(isToolExposed({ exposure: { [target]: false } }, target)).toBe(false)+ }+ expect(isToolExposed({ exposure: { webmcp: false, ai: false } }, 'mcp')).toBe(true)+ })+test('all tools have unique names and native input schemas', () => {const names = ALL_TOOLS.map((tool) => tool.name)expect(new Set(names).size).toBe(names.length)@@ -19,11 +28,11 @@ describe('tool definitions', () => {}})- test('browser exposure is explicit and restricted to inspection or atomic property edits', () => {+ test('browser-eligible tools declare document capabilities', () => {for (const tool of ALL_TOOLS) {expect(tool.mutates).toBe(tool.execution.mutation !== 'none')- if (!tool.exposure.webmcp) continue- expect(tool.execution.mutation === 'none' || isAtomicTool(tool)).toBe(true)+ if (!isToolExposed(tool, 'webmcp')) continue+ if (tool.execution.mutation !== 'none' && !isAtomicTool(tool)) continueexpect(tool.capabilities.every((capability) => capability === 'document:read' || capability === 'document:write'