Variables
用于创建和管理设计变量和模式的工具
此分类共 5 个工具。
variable_collections
Section titled “variable_collections”CRUD endpoint for variable collections + mode management. create → {items: [{name}]} → {results: [{id, modes, defaultModeId}]} get → {id, fields?} → collection object list → {fields?, offset?, limit?} → paginated stubs delete → {id} or {items: [{id}]} → 'ok' or {results: ['ok', ...]} add_mode → {items: [{collectionId, name}]} → {results: [{modeId, modes}]} rename_mode → {items: [{collectionId, modeId, name}]} → {results: [{modes}]} remove_mode → {items: [{collectionId, modeId}]} → {results: [{modes}]}
| Parameter | Type | Required | Description |
|---|---|---|---|
method | "create" | "get" | "list" | "delete" | "add_mode" | "rename_mode" | "remove_mode" | ✓ | |
id | string | ✗ | Resource ID (get, delete) |
fields | string[] | ✗ | Property whitelist (get/list). Identity fields (id, name, type) always included. Omit for stubs on list, full detail on get. Pass ["*"] for all fields. |
offset | number | ✗ | Skip N items for pagination (default 0) |
limit | number | ✗ | Max items per page (default 100) |
items | array | ✗ | create: [{name}]. delete (batch): [{id}]. add_mode: [{collectionId, name}]. rename_mode: [{collectionId, modeId, name}]. remove_mode: [{collectionId, modeId}]. |
JSON Schema
{
"type": "object",
"properties": {
"method": {
"type": "string",
"enum": [
"create",
"get",
"list",
"delete",
"add_mode",
"rename_mode",
"remove_mode"
]
},
"id": {
"description": "Resource ID (get, delete)",
"type": "string"
},
"fields": {
"description": "Property whitelist (get/list). Identity fields (id, name, type) always included. Omit for stubs on list, full detail on get. Pass [\"*\"] for all fields.",
"type": "array",
"items": {
"type": "string"
}
},
"offset": {
"description": "Skip N items for pagination (default 0)",
"type": "number"
},
"limit": {
"description": "Max items per page (default 100)",
"type": "number"
},
"items": {
"description": "create: [{name}]. delete (batch): [{id}]. add_mode: [{collectionId, name}]. rename_mode: [{collectionId, modeId, name}]. remove_mode: [{collectionId, modeId}].",
"type": "array",
"items": {}
}
},
"required": [
"method"
]
} 返回值 仅供参考 — 不包含在工具定义中
无参数
示例返回
{
"totalCount": 2,
"returned": 2,
"offset": 0,
"limit": 100,
"items": [
{
"id": "VariableCollectionId:1:0",
"name": "Colors"
},
{
"id": "VariableCollectionId:2:0",
"name": "Spacing"
}
]
} 返回值 JSON Schema
{
"type": "object",
"description": "Response varies by method. create → {results: [{id, modes, defaultModeId}]}. get → collection object (field-filterable). list → paginated stubs. delete → 'ok' or {results: ['ok', ...]}. add_mode → {results: [{modeId, modes}]}. rename_mode/remove_mode → {results: [{modes}]}."
} variables
Section titled “variables”CRUD endpoint for design variables. create → {items: [{collectionId, name, resolvedType}]} → {results: [{id}]} get → {id, fields?} → variable object (full detail) list → {type?, collectionId?, fields?, offset?, limit?} → paginated stubs (fields for detail) update → {items: [{id, modeId, value}]} → {results: ['ok', ...]}
| Parameter | Type | Required | Description |
|---|---|---|---|
method | "create" | "get" | "list" | "update" | ✓ | |
id | string | ✗ | Resource ID (get, delete) |
fields | string[] | ✗ | Property whitelist (get/list). Identity fields (id, name, type) always included. Omit for stubs on list, full detail on get. Pass ["*"] for all fields. |
offset | number | ✗ | Skip N items for pagination (default 0) |
limit | number | ✗ | Max items per page (default 100) |
items | array | ✗ | create: [{collectionId, name, resolvedType}]. update: [{id, modeId, value}]. |
type | "COLOR" | "FLOAT" | "STRING" | "BOOLEAN" | ✗ | Filter list by variable type. |
collectionId | string | ✗ | Filter list by collection ID. |
JSON Schema
{
"type": "object",
"properties": {
"method": {
"type": "string",
"enum": [
"create",
"get",
"list",
"update"
]
},
"id": {
"description": "Resource ID (get, delete)",
"type": "string"
},
"fields": {
"description": "Property whitelist (get/list). Identity fields (id, name, type) always included. Omit for stubs on list, full detail on get. Pass [\"*\"] for all fields.",
"type": "array",
"items": {
"type": "string"
}
},
"offset": {
"description": "Skip N items for pagination (default 0)",
"type": "number"
},
"limit": {
"description": "Max items per page (default 100)",
"type": "number"
},
"items": {
"description": "create: [{collectionId, name, resolvedType}]. update: [{id, modeId, value}].",
"type": "array",
"items": {}
},
"type": {
"description": "Filter list by variable type.",
"type": "string",
"enum": [
"COLOR",
"FLOAT",
"STRING",
"BOOLEAN"
]
},
"collectionId": {
"description": "Filter list by collection ID.",
"type": "string"
}
},
"required": [
"method"
]
} 返回值 仅供参考 — 不包含在工具定义中
无参数
示例返回
{
"totalCount": 3,
"returned": 3,
"offset": 0,
"limit": 100,
"items": [
{
"id": "VariableID:1:6",
"name": "primary",
"resolvedType": "COLOR",
"variableCollectionId": "VariableCollectionId:1:0"
},
{
"id": "VariableID:1:7",
"name": "secondary",
"resolvedType": "COLOR",
"variableCollectionId": "VariableCollectionId:1:0"
},
{
"id": "VariableID:2:1",
"name": "sm",
"resolvedType": "FLOAT",
"variableCollectionId": "VariableCollectionId:2:0"
}
]
} 返回值 JSON Schema
{
"type": "object",
"description": "Response varies by method. create → {results: [{id}]}. get → variable object (full detail, field-filterable). list → paginated stubs (use fields for detail). update → {results: ['ok', ...]}."
} set_variable_binding
Section titled “set_variable_binding”Bind variables to node properties. Common fields: 'fills/0/color', 'strokes/0/color', 'opacity', 'topLeftRadius', 'itemSpacing'. Batch: pass multiple items.
| Parameter | Type | Required | Description |
|---|---|---|---|
items | object[] | ✓ | Array of {nodeId, field, variableId} |
↳ nodeId | string | ✓ | Node ID |
↳ field | string | ✓ | Property field (e.g., 'opacity', 'fills/0/color') |
↳ variableId | string | ✓ | Variable ID (use full ID from create_variable response, e.g. VariableID:1:6) |
JSON Schema
{
"type": "object",
"properties": {
"items": {
"description": "Array of {nodeId, field, variableId}",
"type": "array",
"items": {
"type": "object",
"properties": {
"nodeId": {
"type": "string",
"description": "Node ID"
},
"field": {
"type": "string",
"description": "Property field (e.g., 'opacity', 'fills/0/color')"
},
"variableId": {
"type": "string",
"description": "Variable ID (use full ID from create_variable response, e.g. VariableID:1:6)"
}
},
"required": [
"nodeId",
"field",
"variableId"
]
}
}
},
"required": [
"items"
]
} 返回值 仅供参考 — 不包含在工具定义中
| Field | Type | Description |
|---|---|---|
results | ("ok" | error)[] | Per-item results. |
↳ error | string | Error message for this item |
warnings | string[] | Deduplicated warnings hoisted from individual results |
示例返回
{
"results": [
"ok"
]
} 返回值 JSON Schema
{
"type": "object",
"properties": {
"results": {
"type": "array",
"description": "Per-item results.",
"items": {
"oneOf": [
{
"type": "string",
"const": "ok"
},
{
"title": "error",
"type": "object",
"properties": {
"error": {
"type": "string",
"description": "Error message for this item"
}
},
"required": [
"error"
]
}
]
}
},
"warnings": {
"type": "array",
"description": "Deduplicated warnings hoisted from individual results",
"items": {
"type": "string"
}
}
},
"required": [
"results"
]
} set_explicit_variable_mode
Section titled “set_explicit_variable_mode”Pin a variable collection mode on a frame (e.g. show Dark mode). Batch: pass multiple items.
| Parameter | Type | Required | Description |
|---|---|---|---|
items | object[] | ✓ | Array of {nodeId, collectionId, modeId} |
↳ nodeId | string | ✓ | Node ID |
↳ collectionId | string | ✓ | Variable collection ID |
↳ modeId | string | ✓ | Mode ID to pin (e.g. Dark mode) |
JSON Schema
{
"type": "object",
"properties": {
"items": {
"description": "Array of {nodeId, collectionId, modeId}",
"type": "array",
"items": {
"type": "object",
"properties": {
"nodeId": {
"type": "string",
"description": "Node ID"
},
"collectionId": {
"type": "string",
"description": "Variable collection ID"
},
"modeId": {
"type": "string",
"description": "Mode ID to pin (e.g. Dark mode)"
}
},
"required": [
"nodeId",
"collectionId",
"modeId"
]
}
}
},
"required": [
"items"
]
} 返回值 仅供参考 — 不包含在工具定义中
| Field | Type | Description |
|---|---|---|
results | ("ok" | error)[] | Per-item results. |
↳ error | string | Error message for this item |
warnings | string[] | Deduplicated warnings hoisted from individual results |
示例返回
{
"results": [
"ok"
]
} 返回值 JSON Schema
{
"type": "object",
"properties": {
"results": {
"type": "array",
"description": "Per-item results.",
"items": {
"oneOf": [
{
"type": "string",
"const": "ok"
},
{
"title": "error",
"type": "object",
"properties": {
"error": {
"type": "string",
"description": "Error message for this item"
}
},
"required": [
"error"
]
}
]
}
},
"warnings": {
"type": "array",
"description": "Deduplicated warnings hoisted from individual results",
"items": {
"type": "string"
}
}
},
"required": [
"results"
]
} get_node_variables
Section titled “get_node_variables”Get variable bindings on a node. Returns which variables are bound to fills, strokes, opacity, corner radius, etc.
| Parameter | Type | Required | Description |
|---|---|---|---|
nodeId | string | ✓ | Node ID |
JSON Schema
{
"type": "object",
"properties": {
"nodeId": {
"type": "string",
"description": "Node ID"
}
},
"required": [
"nodeId"
]
} 返回值 仅供参考 — 不包含在工具定义中
| Field | Type | Description |
|---|---|---|
nodeId | string | |
boundVariables | object | Field → variable binding(s) |
explicitVariableModes | object | Collection ID → pinned mode ID |
示例返回
{
"nodeId": "1:2",
"boundVariables": {
"fills": [
{
"variableId": "VariableID:1:6"
}
]
},
"explicitVariableModes": {
"VariableCollectionId:1:0": "1:1"
}
} 返回值 JSON Schema
{
"type": "object",
"properties": {
"nodeId": {
"type": "string"
},
"boundVariables": {
"type": "object",
"description": "Field → variable binding(s)"
},
"explicitVariableModes": {
"type": "object",
"description": "Collection ID → pinned mode ID"
}
},
"required": [
"nodeId"
]
}