analytics
Metabase Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Metabase KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.metabase.*.
Use lua_read_doc("integrations.metabase") 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
Metabase workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.metabase.list_dashboards({}))' --json kosmo integrations:lua --eval 'print(docs.read("metabase"))' --json
kosmo integrations:lua --eval 'print(docs.read("metabase.list_dashboards"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local metabase = app.integrations.metabase
local result = metabase.list_dashboards({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.metabase, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.metabase.default.* or app.integrations.metabase.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Metabase, use the narrower 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.
Metabase — Lua API Reference
list_dashboards
List all dashboards available in Metabase.
Parameters
None.
Returns
{
dashboards = {
{ id = 1, name = "Sales Overview", ... },
{ id = 2, name = "Marketing KPIs", ... },
},
count = 2
}
Example
local result = app.integrations.metabase.list_dashboards()
for _, db in ipairs(result.dashboards) do
print(db.id .. ": " .. db.name)
end
get_dashboard
Get a single Metabase dashboard by ID, including all cards, layout, and parameters.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The dashboard ID |
Example
local result = app.integrations.metabase.get_dashboard({ id = 1 })
print("Dashboard: " .. result.name)
print("Cards: " .. #result.ordered_cards)
for _, item in ipairs(result.ordered_cards) do
local card = item.card
if card then
print(" Card " .. card.id .. ": " .. card.name)
end
end
list_cards
List all cards (saved questions) in Metabase.
Parameters
None.
Returns
{
cards = {
{ id = 10, name = "Revenue by Month", display = "bar", ... },
{ id = 11, name = "Active Users", display = "scalar", ... },
},
count = 2
}
Example
local result = app.integrations.metabase.list_cards()
for _, card in ipairs(result.cards) do
print(card.id .. ": " .. card.name .. " (" .. (card.display or "?") .. ")")
end
get_card
Get the full definition of a card (question) by ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The card (question) ID |
Example
local result = app.integrations.metabase.get_card({ id = 10 })
print("Name: " .. result.name)
print("Display: " .. result.display)
print("Database: " .. (result.database_id or "unknown"))
query_card
Execute a saved card (question) and return the query results.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The card (question) ID to execute |
Returns
{
rows = {
{ month = "2026-01", revenue = 42000 },
{ month = "2026-02", revenue = 51000 },
},
rowCount = 2,
columns = { "month", "revenue" }
}
Example
local result = app.integrations.metabase.query_card({ id = 10 })
print("Columns: " .. table.concat(result.columns, ", "))
print("Rows: " .. result.rowCount)
for _, row in ipairs(result.rows) do
print(row.month .. ": $" .. row.revenue)
end
list_databases
List all databases connected to Metabase.
Parameters
None.
Returns
{
databases = {
{ id = 1, name = "Production DB", engine = "postgres", ... },
{ id = 2, name = "Analytics Warehouse", engine = "bigquery", ... },
},
count = 2
}
Example
local result = app.integrations.metabase.list_databases()
for _, db in ipairs(result.databases) do
print(db.id .. ": " .. db.name .. " (" .. db.engine .. ")")
end
get_database
Get detailed metadata for a database, including tables and fields.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The database ID |
Example
local result = app.integrations.metabase.get_database({ id = 1 })
print("Database: " .. result.name)
print("Engine: " .. result.engine)
for _, table in ipairs(result.tables or {}) do
print(" Table: " .. table.name .. " (" .. #table.fields .. " fields)")
for _, field in ipairs(table.fields or {}) do
print(" - " .. field.name .. " (" .. field.base_type .. ")")
end
end
get_current_user
Get the currently authenticated Metabase user profile.
Parameters
None.
Example
local result = app.integrations.metabase.get_current_user()
print("User: " .. result.common_name)
print("Email: " .. result.email)
Multi-Account Usage
If you have multiple Metabase instances configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.metabase.function_name({...})
-- Explicit default (portable across setups)
app.integrations.metabase.default.function_name({...})
-- Named accounts
app.integrations.metabase.production.function_name({...})
app.integrations.metabase.staging.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Metabase — Lua API Reference
## list_dashboards
List all dashboards available in Metabase.
### Parameters
None.
### Returns
```lua
{
dashboards = {
{ id = 1, name = "Sales Overview", ... },
{ id = 2, name = "Marketing KPIs", ... },
},
count = 2
}
```
### Example
```lua
local result = app.integrations.metabase.list_dashboards()
for _, db in ipairs(result.dashboards) do
print(db.id .. ": " .. db.name)
end
```
---
## get_dashboard
Get a single Metabase dashboard by ID, including all cards, layout, and parameters.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The dashboard ID |
### Example
```lua
local result = app.integrations.metabase.get_dashboard({ id = 1 })
print("Dashboard: " .. result.name)
print("Cards: " .. #result.ordered_cards)
for _, item in ipairs(result.ordered_cards) do
local card = item.card
if card then
print(" Card " .. card.id .. ": " .. card.name)
end
end
```
---
## list_cards
List all cards (saved questions) in Metabase.
### Parameters
None.
### Returns
```lua
{
cards = {
{ id = 10, name = "Revenue by Month", display = "bar", ... },
{ id = 11, name = "Active Users", display = "scalar", ... },
},
count = 2
}
```
### Example
```lua
local result = app.integrations.metabase.list_cards()
for _, card in ipairs(result.cards) do
print(card.id .. ": " .. card.name .. " (" .. (card.display or "?") .. ")")
end
```
---
## get_card
Get the full definition of a card (question) by ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The card (question) ID |
### Example
```lua
local result = app.integrations.metabase.get_card({ id = 10 })
print("Name: " .. result.name)
print("Display: " .. result.display)
print("Database: " .. (result.database_id or "unknown"))
```
---
## query_card
Execute a saved card (question) and return the query results.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The card (question) ID to execute |
### Returns
```lua
{
rows = {
{ month = "2026-01", revenue = 42000 },
{ month = "2026-02", revenue = 51000 },
},
rowCount = 2,
columns = { "month", "revenue" }
}
```
### Example
```lua
local result = app.integrations.metabase.query_card({ id = 10 })
print("Columns: " .. table.concat(result.columns, ", "))
print("Rows: " .. result.rowCount)
for _, row in ipairs(result.rows) do
print(row.month .. ": $" .. row.revenue)
end
```
---
## list_databases
List all databases connected to Metabase.
### Parameters
None.
### Returns
```lua
{
databases = {
{ id = 1, name = "Production DB", engine = "postgres", ... },
{ id = 2, name = "Analytics Warehouse", engine = "bigquery", ... },
},
count = 2
}
```
### Example
```lua
local result = app.integrations.metabase.list_databases()
for _, db in ipairs(result.databases) do
print(db.id .. ": " .. db.name .. " (" .. db.engine .. ")")
end
```
---
## get_database
Get detailed metadata for a database, including tables and fields.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | integer | yes | The database ID |
### Example
```lua
local result = app.integrations.metabase.get_database({ id = 1 })
print("Database: " .. result.name)
print("Engine: " .. result.engine)
for _, table in ipairs(result.tables or {}) do
print(" Table: " .. table.name .. " (" .. #table.fields .. " fields)")
for _, field in ipairs(table.fields or {}) do
print(" - " .. field.name .. " (" .. field.base_type .. ")")
end
end
```
---
## get_current_user
Get the currently authenticated Metabase user profile.
### Parameters
None.
### Example
```lua
local result = app.integrations.metabase.get_current_user()
print("User: " .. result.common_name)
print("Email: " .. result.email)
```
---
## Multi-Account Usage
If you have multiple Metabase instances configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.metabase.function_name({...})
-- Explicit default (portable across setups)
app.integrations.metabase.default.function_name({...})
-- Named accounts
app.integrations.metabase.production.function_name({...})
app.integrations.metabase.staging.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.metabase.list_dashboards({})
print(result) Functions
list_dashboards Read
List all dashboards available in Metabase. Returns dashboard IDs, names, and basic metadata. Use metabase_get_dashboard to retrieve the full dashboard with cards.
- Lua path
app.integrations.metabase.list_dashboards- Full name
metabase.metabase_list_dashboards
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_dashboard Read
Get a single Metabase dashboard by ID, including all cards (questions), layout, and parameters. Use metabase_list_dashboards to find dashboard IDs.
- Lua path
app.integrations.metabase.get_dashboard- Full name
metabase.metabase_get_dashboard
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The dashboard ID. |
list_cards Read
List all cards (questions/saved questions) in Metabase. Returns card IDs, names, collection info, and display types. Use metabase_get_card for full definitions or metabase_query_card to run a card.
- Lua path
app.integrations.metabase.list_cards- Full name
metabase.metabase_list_cards
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_card Read
Get the full definition of a Metabase card (question) by ID, including the query, display settings, and parameters. Use metabase_list_cards to find card IDs.
- Lua path
app.integrations.metabase.get_card- Full name
metabase.metabase_get_card
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The card (question) ID. |
query_card Read
Execute a saved Metabase card (question) and return the query results as rows. Use metabase_list_cards or metabase_get_card to find card IDs. The card must be a question (not a model or metric).
- Lua path
app.integrations.metabase.query_card- Full name
metabase.metabase_query_card
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The card (question) ID to execute. |
list_databases Read
List all databases connected to Metabase. Returns database IDs, names, engine types, and metadata. Use metabase_get_database to retrieve tables and fields for a specific database.
- Lua path
app.integrations.metabase.list_databases- Full name
metabase.metabase_list_databases
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_database Read
Get detailed metadata for a Metabase database by ID, including its tables, fields, and schema information. Use metabase_list_databases to find database IDs.
- Lua path
app.integrations.metabase.get_database- Full name
metabase.metabase_get_database
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer | yes | The database ID. |
get_current_user Read
Get the currently authenticated Metabase user profile, including name, email, and group memberships. Useful for verifying which account the integration is using.
- Lua path
app.integrations.metabase.get_current_user- Full name
metabase.metabase_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||