跳转到内容

Variables

用于创建和管理设计变量和模式的工具

此分类共 5 个工具。

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}]}

ParameterTypeRequiredDescription
method"create" | "get" | "list" | "delete" | "add_mode" | "rename_mode" | "remove_mode"
idstringResource ID (get, delete)
fieldsstring[]Property whitelist (get/list). Identity fields (id, name, type) always included. Omit for stubs on list, full detail on get. Pass ["*"] for all fields.
offsetnumberSkip N items for pagination (default 0)
limitnumberMax items per page (default 100)
itemsarraycreate: [{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}]}."
}

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', ...]}

ParameterTypeRequiredDescription
method"create" | "get" | "list" | "update"
idstringResource ID (get, delete)
fieldsstring[]Property whitelist (get/list). Identity fields (id, name, type) always included. Omit for stubs on list, full detail on get. Pass ["*"] for all fields.
offsetnumberSkip N items for pagination (default 0)
limitnumberMax items per page (default 100)
itemsarraycreate: [{collectionId, name, resolvedType}]. update: [{id, modeId, value}].
type"COLOR" | "FLOAT" | "STRING" | "BOOLEAN"Filter list by variable type.
collectionIdstringFilter 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', ...]}."
}
edit

Bind variables to node properties. Common fields: 'fills/0/color', 'strokes/0/color', 'opacity', 'topLeftRadius', 'itemSpacing'. Batch: pass multiple items.

ParameterTypeRequiredDescription
itemsobject[]Array of {nodeId, field, variableId}
nodeIdstringNode ID
fieldstringProperty field (e.g., 'opacity', 'fills/0/color')
variableIdstringVariable 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"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
results("ok" | error)[]Per-item results.
errorstringError message for this item
warningsstring[]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"
  ]
}
edit

Pin a variable collection mode on a frame (e.g. show Dark mode). Batch: pass multiple items.

ParameterTypeRequiredDescription
itemsobject[]Array of {nodeId, collectionId, modeId}
nodeIdstringNode ID
collectionIdstringVariable collection ID
modeIdstringMode 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"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
results("ok" | error)[]Per-item results.
errorstringError message for this item
warningsstring[]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 variable bindings on a node. Returns which variables are bound to fills, strokes, opacity, corner radius, etc.

ParameterTypeRequiredDescription
nodeIdstringNode ID
JSON Schema
{
  "type": "object",
  "properties": {
    "nodeId": {
      "type": "string",
      "description": "Node ID"
    }
  },
  "required": [
    "nodeId"
  ]
}

返回值 仅供参考 — 不包含在工具定义中

FieldTypeDescription
nodeIdstring
boundVariablesobjectField → variable binding(s)
explicitVariableModesobjectCollection 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"
  ]
}