KosmoKrator

productivity

Figma Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Figma KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.figma.*. Use lua_read_doc("integrations.figma") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Figma workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.figma.delete_comment({file_key = "example_file_key", comment_id = "example_comment_id"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("figma"))' --json
kosmo integrations:lua --eval 'print(docs.read("figma.delete_comment"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local figma = app.integrations.figma
local result = figma.delete_comment({file_key = "example_file_key", comment_id = "example_comment_id"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.figma, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.figma.default.* or app.integrations.figma.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Figma, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Figma — Lua API Reference

figma_list_files

List Figma files accessible to the authenticated user.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of files to return (default: 30)
pageintegernoPage number for pagination (default: 1)

Example

local result = app.integrations.figma.figma_list_files({
  limit = 10,
  page = 1
})

for _, file in ipairs(result.files) do
  print(file.name .. " — " .. file.key)
end

figma_get_file

Get a Figma file by key. Returns the document tree with pages and nodes.

Parameters

NameTypeRequiredDescription
file_keystringyesThe Figma file key (from the file URL)
idsstringnoComma-separated list of node IDs to return
depthintegernoMax depth of the document tree to return
geometrystringnoSet to “path” to include vector path data
plugin_datastringnoComma-separated list of plugin IDs to include data for

Example

local result = app.integrations.figma.figma_get_file({
  file_key = "abc123def456",
  depth = 2
})

print("File: " .. result.name)
for _, page in ipairs(result.document.children) do
  print("  Page: " .. page.name)
end

figma_list_projects

List all projects in a Figma team.

Parameters

NameTypeRequiredDescription
team_idstringyesThe Figma team ID

Example

local result = app.integrations.figma.figma_list_projects({
  team_id = "12345"
})

for _, project in ipairs(result.projects) do
  print(project.id .. ": " .. project.name)
end

figma_list_components

List all components in a Figma file.

Parameters

NameTypeRequiredDescription
file_keystringyesThe Figma file key

Example

local result = app.integrations.figma.figma_list_components({
  file_key = "abc123def456"
})

for _, comp in ipairs(result.meta.components) do
  print(comp.name .. " — " .. comp.key)
end

figma_get_component

Get a Figma component by its key.

Parameters

NameTypeRequiredDescription
component_keystringyesThe component key

Example

local result = app.integrations.figma.figma_get_component({
  component_key = "abc123componentkey"
})

print(result.name .. ": " .. (result.description or "no description"))

figma_list_comments

List all comments on a Figma file. Includes authors, positions, and reply threads.

Parameters

NameTypeRequiredDescription
file_keystringyesThe Figma file key

Example

local result = app.integrations.figma.figma_list_comments({
  file_key = "abc123def456"
})

for _, comment in ipairs(result.comments) do
  print(comment.user.handle .. ": " .. comment.message)
end

figma_get_current_user

Get the authenticated Figma user profile. Returns name, email, and account details.

Example

local result = app.integrations.figma.figma_get_current_user({})
print("Logged in as: " .. result.email)

Extended Tools

figma_get_file_nodes

Get specific nodes from a Figma file by node IDs.

NameTypeRequiredDescription
file_keystringyesThe Figma file key
idsstringyesComma-separated list of node IDs
depthintegernoMax depth of nodes to return
geometrystringnoSet to “path” to include vector data

figma_get_file_images

Export images from Figma nodes. Returns image download URLs.

NameTypeRequiredDescription
file_keystringyesThe Figma file key
idsstringyesComma-separated node IDs to export
formatstringnoImage format: png, jpg, svg, pdf (default: png)
scalenumbernoScale factor (1, 2, 3)

figma_get_image_fills

Get image fill metadata for a Figma file.

NameTypeRequiredDescription
file_keystringyesThe Figma file key

figma_post_comment

Post a comment on a Figma file.

NameTypeRequiredDescription
file_keystringyesThe Figma file key
messagestringyesThe comment text
client_metastringnoJSON position metadata (x, y)
comment_idstringnoReply to this comment ID

figma_delete_comment

Delete a comment from a Figma file.

NameTypeRequiredDescription
file_keystringyesThe Figma file key
comment_idstringyesThe comment ID to delete

figma_get_project_files

List all files in a Figma project.

NameTypeRequiredDescription
project_idstringyesThe Figma project ID
branch_databooleannoInclude branch metadata

figma_get_styles

List all styles in a Figma file.

NameTypeRequiredDescription
file_keystringyesThe Figma file key

figma_get_style

Get a Figma style by key.

NameTypeRequiredDescription
style_keystringyesThe style key

figma_list_team_components

List published components in a Figma team.

NameTypeRequiredDescription
team_idstringyesThe Figma team ID
max_depthintegernoMaximum depth of component tree

Multi-Account Usage

If you have multiple Figma accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.figma.function_name({...})

-- Explicit default (portable across setups)
app.integrations.figma.default.function_name({...})

-- Named accounts
app.integrations.figma.work.function_name({...})
app.integrations.figma.personal.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Figma — Lua API Reference

## figma_list_files

List Figma files accessible to the authenticated user.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of files to return (default: 30) |
| `page` | integer | no | Page number for pagination (default: 1) |

### Example

```lua
local result = app.integrations.figma.figma_list_files({
  limit = 10,
  page = 1
})

for _, file in ipairs(result.files) do
  print(file.name .. " — " .. file.key)
end
```

---

## figma_get_file

Get a Figma file by key. Returns the document tree with pages and nodes.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key (from the file URL) |
| `ids` | string | no | Comma-separated list of node IDs to return |
| `depth` | integer | no | Max depth of the document tree to return |
| `geometry` | string | no | Set to "path" to include vector path data |
| `plugin_data` | string | no | Comma-separated list of plugin IDs to include data for |

### Example

```lua
local result = app.integrations.figma.figma_get_file({
  file_key = "abc123def456",
  depth = 2
})

print("File: " .. result.name)
for _, page in ipairs(result.document.children) do
  print("  Page: " .. page.name)
end
```

---

## figma_list_projects

List all projects in a Figma team.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `team_id` | string | yes | The Figma team ID |

### Example

```lua
local result = app.integrations.figma.figma_list_projects({
  team_id = "12345"
})

for _, project in ipairs(result.projects) do
  print(project.id .. ": " .. project.name)
end
```

---

## figma_list_components

List all components in a Figma file.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |

### Example

```lua
local result = app.integrations.figma.figma_list_components({
  file_key = "abc123def456"
})

for _, comp in ipairs(result.meta.components) do
  print(comp.name .. " — " .. comp.key)
end
```

---

## figma_get_component

Get a Figma component by its key.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `component_key` | string | yes | The component key |

### Example

```lua
local result = app.integrations.figma.figma_get_component({
  component_key = "abc123componentkey"
})

print(result.name .. ": " .. (result.description or "no description"))
```

---

## figma_list_comments

List all comments on a Figma file. Includes authors, positions, and reply threads.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |

### Example

```lua
local result = app.integrations.figma.figma_list_comments({
  file_key = "abc123def456"
})

for _, comment in ipairs(result.comments) do
  print(comment.user.handle .. ": " .. comment.message)
end
```

---

## figma_get_current_user

Get the authenticated Figma user profile. Returns name, email, and account details.

### Example

```lua
local result = app.integrations.figma.figma_get_current_user({})
print("Logged in as: " .. result.email)
```

---

## Extended Tools

### figma_get_file_nodes

Get specific nodes from a Figma file by node IDs.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |
| `ids` | string | yes | Comma-separated list of node IDs |
| `depth` | integer | no | Max depth of nodes to return |
| `geometry` | string | no | Set to "path" to include vector data |

### figma_get_file_images

Export images from Figma nodes. Returns image download URLs.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |
| `ids` | string | yes | Comma-separated node IDs to export |
| `format` | string | no | Image format: png, jpg, svg, pdf (default: png) |
| `scale` | number | no | Scale factor (1, 2, 3) |

### figma_get_image_fills

Get image fill metadata for a Figma file.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |

### figma_post_comment

Post a comment on a Figma file.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |
| `message` | string | yes | The comment text |
| `client_meta` | string | no | JSON position metadata (x, y) |
| `comment_id` | string | no | Reply to this comment ID |

### figma_delete_comment

Delete a comment from a Figma file.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |
| `comment_id` | string | yes | The comment ID to delete |

### figma_get_project_files

List all files in a Figma project.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_id` | string | yes | The Figma project ID |
| `branch_data` | boolean | no | Include branch metadata |

### figma_get_styles

List all styles in a Figma file.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_key` | string | yes | The Figma file key |

### figma_get_style

Get a Figma style by key.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `style_key` | string | yes | The style key |

### figma_list_team_components

List published components in a Figma team.

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `team_id` | string | yes | The Figma team ID |
| `max_depth` | integer | no | Maximum depth of component tree |

---

## Multi-Account Usage

If you have multiple Figma accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.figma.function_name({...})

-- Explicit default (portable across setups)
app.integrations.figma.default.function_name({...})

-- Named accounts
app.integrations.figma.work.function_name({...})
app.integrations.figma.personal.function_name({...})
```

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.figma.delete_comment({file_key = "example_file_key", comment_id = "example_comment_id"})
print(result)

Functions

delete_comment Write

Delete a comment from a Figma file.

Lua path
app.integrations.figma.delete_comment
Full name
figma.figma_delete_comment
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
comment_id string yes The comment ID to delete.
get_comments Read

List all comments on a Figma file.

Lua path
app.integrations.figma.get_comments
Full name
figma.figma_get_comments
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
get_component Read

Get a Figma component by its key.

Lua path
app.integrations.figma.get_component
Full name
figma.figma_get_component
ParameterTypeRequiredDescription
component_key string yes The component key.
get_components Read

List all components in a Figma file.

Lua path
app.integrations.figma.get_components
Full name
figma.figma_get_components
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
get_current_user Read

Get the authenticated Figma user profile. Returns name, email, and account details.

Lua path
app.integrations.figma.get_current_user
Full name
figma.figma_get_current_user
ParameterTypeRequiredDescription
No parameters.
get_file Read

Get a Figma file by key. Returns the document tree with pages and nodes.

Lua path
app.integrations.figma.get_file
Full name
figma.figma_get_file
ParameterTypeRequiredDescription
file_key string yes The Figma file key (from the file URL).
ids string no Comma-separated list of node IDs to return.
depth integer no Max depth of the document tree to return.
geometry string no Set to "path" to include vector path data.
plugin_data string no Comma-separated list of plugin IDs to include data for.
get_file_images Read

Export images from Figma nodes in a file. Returns image download URLs.

Lua path
app.integrations.figma.get_file_images
Full name
figma.figma_get_file_images
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
ids string yes Comma-separated list of node IDs to export.
format string no Image format: png, jpg, svg, or pdf. Defaults to png.
scale number no Image scale factor (e.g. 1, 2, 3). Defaults to 1.
svg_include_id_token boolean no If true, include id attribute for SVG root.
get_file_nodes Read

Get specific nodes from a Figma file by node IDs.

Lua path
app.integrations.figma.get_file_nodes
Full name
figma.figma_get_file_nodes
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
ids string yes Comma-separated list of node IDs to retrieve.
depth integer no Max depth of nodes to return.
geometry string no Set to "path" to include vector path data.
get_image_fills Read

Get image fill metadata for a Figma file. Returns image URLs for all image fills.

Lua path
app.integrations.figma.get_image_fills
Full name
figma.figma_get_image_fills
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
get_me Read

Get the authenticated Figma user profile.

Lua path
app.integrations.figma.get_me
Full name
figma.figma_get_me
ParameterTypeRequiredDescription
No parameters.
get_project_files Read

List all files in a Figma project.

Lua path
app.integrations.figma.get_project_files
Full name
figma.figma_get_project_files
ParameterTypeRequiredDescription
project_id string yes The Figma project ID.
branch_data boolean no If true, include branch metadata for each file.
get_style Read

Get a Figma style by its key.

Lua path
app.integrations.figma.get_style
Full name
figma.figma_get_style
ParameterTypeRequiredDescription
style_key string yes The style key.
get_styles Read

List all styles in a Figma file.

Lua path
app.integrations.figma.get_styles
Full name
figma.figma_get_styles
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
get_team_projects Read

List all projects in a Figma team.

Lua path
app.integrations.figma.get_team_projects
Full name
figma.figma_get_team_projects
ParameterTypeRequiredDescription
team_id string yes The Figma team ID.
list_comments Read

List all comments on a Figma file. Includes authors, positions, and reply threads.

Lua path
app.integrations.figma.list_comments
Full name
figma.figma_list_comments
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
list_components Read

List all components in a Figma file. Returns component names, keys, and descriptions.

Lua path
app.integrations.figma.list_components
Full name
figma.figma_list_components
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
list_files Read

List Figma files accessible to the authenticated user. Returns file names, keys, and thumbnails with pagination support.

Lua path
app.integrations.figma.list_files
Full name
figma.figma_list_files
ParameterTypeRequiredDescription
limit integer no Maximum number of files to return (default: 30).
page integer no Page number for pagination (default: 1).
list_projects Read

List all projects in a Figma team. Returns project names and IDs.

Lua path
app.integrations.figma.list_projects
Full name
figma.figma_list_projects
ParameterTypeRequiredDescription
team_id string yes The Figma team ID.
list_team_components Read

List published components in a Figma team.

Lua path
app.integrations.figma.list_team_components
Full name
figma.figma_list_team_components
ParameterTypeRequiredDescription
team_id string yes The Figma team ID.
max_depth integer no Maximum depth of component tree to return.
post_comment Read

Post a comment on a Figma file. Can be a top-level comment or a reply.

Lua path
app.integrations.figma.post_comment
Full name
figma.figma_post_comment
ParameterTypeRequiredDescription
file_key string yes The Figma file key.
message string yes The comment text.
client_meta string no JSON object with position metadata (x, y) for the comment.
comment_id string no If provided, this comment is a reply to the given comment ID.