data
Mastodon Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Mastodon KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.mastodon.*.
Use lua_read_doc("integrations.mastodon") 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
Mastodon workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.mastodon.list_statuses({timeline = "example_timeline", limit = 1, max_id = "example_max_id", since_id = "example_since_id"}))' --json kosmo integrations:lua --eval 'print(docs.read("mastodon"))' --json
kosmo integrations:lua --eval 'print(docs.read("mastodon.list_statuses"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local mastodon = app.integrations.mastodon
local result = mastodon.list_statuses({timeline = "example_timeline", limit = 1, max_id = "example_max_id", since_id = "example_since_id"})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.mastodon, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.mastodon.default.* or app.integrations.mastodon.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Mastodon, 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.
Mastodon — Lua API Reference
list_statuses
Browse statuses (toots) from a Mastodon timeline.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
timeline | string | no | Timeline to retrieve: "home" (default), "local", or "public" |
limit | integer | no | Max statuses to return (1–40, default: 20) |
max_id | string | no | Return results older than this status ID (pagination) |
since_id | string | no | Return results newer than this status ID (pagination) |
Examples
Home timeline
local result = app.integrations.mastodon.list_statuses({
timeline = "home",
limit = 10
})
for _, status in ipairs(result.statuses) do
print(status.account.display_name .. ": " .. status.content)
end
Public timeline with pagination
local result = app.integrations.mastodon.list_statuses({
timeline = "public",
limit = 40,
max_id = last_seen_id
})
get_status
Retrieve a single status (toot) by its ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The ID of the status to retrieve |
Example
local status = app.integrations.mastodon.get_status({ id = "1234567890" })
print(status.account.username .. " posted: " .. status.content)
print("Boosts: " .. status.reblogs_count .. ", Favs: " .. status.favourites_count)
create_status
Publish a new status (toot) on Mastodon.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
status | string | yes | The text content of the status |
visibility | string | no | "public" (default), "unlisted", "private", or "direct" |
in_reply_to_id | string | no | ID of the status to reply to |
spoiler_text | string | no | Content warning text |
sensitive | boolean | no | Whether the status contains sensitive media |
language | string | no | ISO 639-1 language code (e.g., "en", "nl") |
Examples
Simple post
local result = app.integrations.mastodon.create_status({
status = "Hello from the API!"
})
print("Posted: " .. result.url)
Post with content warning
local result = app.integrations.mastodon.create_status({
status = "Spoilers for the latest episode...",
spoiler_text = "TV Show Spoilers",
visibility = "unlisted"
})
Reply to a status
local result = app.integrations.mastodon.create_status({
status = "Great point! I agree.",
in_reply_to_id = "1234567890"
})
list_accounts
List followers of a Mastodon account.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The account ID whose followers to list |
limit | integer | no | Max accounts to return (1–80, default: 40) |
max_id | string | no | Return results older than this account ID (pagination) |
Example
local result = app.integrations.mastodon.list_accounts({
id = "123456",
limit = 20
})
for _, follower in ipairs(result.followers) do
print(follower.display_name .. " (@" .. follower.acct .. ")")
print(" Followers: " .. follower.followers_count)
end
get_account
Retrieve a Mastodon account profile by ID.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string | yes | The account ID to retrieve |
Example
local account = app.integrations.mastodon.get_account({ id = "123456" })
print(account.display_name .. " (@" .. account.username .. ")")
print("Bio: " .. account.note)
print("Followers: " .. account.followers_count)
print("Following: " .. account.following_count)
print("Statuses: " .. account.statuses_count)
get_current_user
Get the authenticated user’s Mastodon profile.
Parameters
None.
Example
local me = app.integrations.mastodon.get_current_user({})
print("Logged in as @" .. me.username)
print("Display name: " .. me.display_name)
print("Default visibility: " .. (me.source.privacy or "public"))
generic_api
Use generic API tools for Mastodon endpoints that do not have a dedicated wrapper.
Paths must start with /api/ and are relative to the configured instance URL.
local notifications = app.integrations.mastodon.api_get({
path = "/api/v1/notifications",
params = { limit = 20 }
})
local favourite = app.integrations.mastodon.api_post({
path = "/api/v1/statuses/123456/favourite",
body = {}
})
local update = app.integrations.mastodon.api_put({
path = "/api/v1/statuses/123456",
body = { status = "Edited text" }
})
local deleted = app.integrations.mastodon.api_delete({
path = "/api/v1/statuses/123456",
body = {}
})
Generic tools return the raw Mastodon JSON response. Use the official Mastodon API docs for endpoint-specific params, scopes, and response shapes.
Multi-Account Usage
If you have multiple Mastodon accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.mastodon.function_name({...})
-- Explicit default (portable across setups)
app.integrations.mastodon.default.function_name({...})
-- Named accounts
app.integrations.mastodon.work.function_name({...})
app.integrations.mastodon.personal.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Mastodon — Lua API Reference
## list_statuses
Browse statuses (toots) from a Mastodon timeline.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `timeline` | string | no | Timeline to retrieve: `"home"` (default), `"local"`, or `"public"` |
| `limit` | integer | no | Max statuses to return (1–40, default: 20) |
| `max_id` | string | no | Return results older than this status ID (pagination) |
| `since_id` | string | no | Return results newer than this status ID (pagination) |
### Examples
#### Home timeline
```lua
local result = app.integrations.mastodon.list_statuses({
timeline = "home",
limit = 10
})
for _, status in ipairs(result.statuses) do
print(status.account.display_name .. ": " .. status.content)
end
```
#### Public timeline with pagination
```lua
local result = app.integrations.mastodon.list_statuses({
timeline = "public",
limit = 40,
max_id = last_seen_id
})
```
---
## get_status
Retrieve a single status (toot) by its ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The ID of the status to retrieve |
### Example
```lua
local status = app.integrations.mastodon.get_status({ id = "1234567890" })
print(status.account.username .. " posted: " .. status.content)
print("Boosts: " .. status.reblogs_count .. ", Favs: " .. status.favourites_count)
```
---
## create_status
Publish a new status (toot) on Mastodon.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `status` | string | yes | The text content of the status |
| `visibility` | string | no | `"public"` (default), `"unlisted"`, `"private"`, or `"direct"` |
| `in_reply_to_id` | string | no | ID of the status to reply to |
| `spoiler_text` | string | no | Content warning text |
| `sensitive` | boolean | no | Whether the status contains sensitive media |
| `language` | string | no | ISO 639-1 language code (e.g., `"en"`, `"nl"`) |
### Examples
#### Simple post
```lua
local result = app.integrations.mastodon.create_status({
status = "Hello from the API!"
})
print("Posted: " .. result.url)
```
#### Post with content warning
```lua
local result = app.integrations.mastodon.create_status({
status = "Spoilers for the latest episode...",
spoiler_text = "TV Show Spoilers",
visibility = "unlisted"
})
```
#### Reply to a status
```lua
local result = app.integrations.mastodon.create_status({
status = "Great point! I agree.",
in_reply_to_id = "1234567890"
})
```
---
## list_accounts
List followers of a Mastodon account.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The account ID whose followers to list |
| `limit` | integer | no | Max accounts to return (1–80, default: 40) |
| `max_id` | string | no | Return results older than this account ID (pagination) |
### Example
```lua
local result = app.integrations.mastodon.list_accounts({
id = "123456",
limit = 20
})
for _, follower in ipairs(result.followers) do
print(follower.display_name .. " (@" .. follower.acct .. ")")
print(" Followers: " .. follower.followers_count)
end
```
---
## get_account
Retrieve a Mastodon account profile by ID.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The account ID to retrieve |
### Example
```lua
local account = app.integrations.mastodon.get_account({ id = "123456" })
print(account.display_name .. " (@" .. account.username .. ")")
print("Bio: " .. account.note)
print("Followers: " .. account.followers_count)
print("Following: " .. account.following_count)
print("Statuses: " .. account.statuses_count)
```
---
## get_current_user
Get the authenticated user's Mastodon profile.
### Parameters
None.
### Example
```lua
local me = app.integrations.mastodon.get_current_user({})
print("Logged in as @" .. me.username)
print("Display name: " .. me.display_name)
print("Default visibility: " .. (me.source.privacy or "public"))
```
---
## generic_api
Use generic API tools for Mastodon endpoints that do not have a dedicated wrapper.
Paths must start with `/api/` and are relative to the configured instance URL.
```lua
local notifications = app.integrations.mastodon.api_get({
path = "/api/v1/notifications",
params = { limit = 20 }
})
local favourite = app.integrations.mastodon.api_post({
path = "/api/v1/statuses/123456/favourite",
body = {}
})
local update = app.integrations.mastodon.api_put({
path = "/api/v1/statuses/123456",
body = { status = "Edited text" }
})
local deleted = app.integrations.mastodon.api_delete({
path = "/api/v1/statuses/123456",
body = {}
})
```
Generic tools return the raw Mastodon JSON response. Use the official Mastodon
API docs for endpoint-specific params, scopes, and response shapes.
---
## Multi-Account Usage
If you have multiple Mastodon accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.mastodon.function_name({...})
-- Explicit default (portable across setups)
app.integrations.mastodon.default.function_name({...})
-- Named accounts
app.integrations.mastodon.work.function_name({...})
app.integrations.mastodon.personal.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.mastodon.list_statuses({timeline = "example_timeline", limit = 1, max_id = "example_max_id", since_id = "example_since_id"})
print(result) Functions
list_statuses Read
Browse statuses (toots) from a Mastodon timeline. Use "home" for your home feed, "public" for the federated timeline, or "local" for the local instance timeline. Supports pagination.
- Lua path
app.integrations.mastodon.list_statuses- Full name
mastodon.mastodon_list_statuses
| Parameter | Type | Required | Description |
|---|---|---|---|
timeline | string | no | Timeline to retrieve: "home" (default), "local", or "public". |
limit | integer | no | Maximum number of statuses to return (1–40, default: 20). |
max_id | string | no | Return results older than this status ID (for pagination). |
since_id | string | no | Return results newer than this status ID (for pagination). |
get_status Read
Retrieve a single Mastodon status (toot) by its ID. Returns the full post content, author details, and engagement metrics.
- Lua path
app.integrations.mastodon.get_status- Full name
mastodon.mastodon_get_status
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The ID of the status to retrieve. |
create_status Write
Publish a new status (toot) on Mastodon. Supports content warnings, visibility controls (public, unlisted, private, direct), replies, and language settings.
- Lua path
app.integrations.mastodon.create_status- Full name
mastodon.mastodon_create_status
| Parameter | Type | Required | Description |
|---|---|---|---|
status | string | yes | The text content of the status. |
visibility | string | no | Visibility: "public" (default), "unlisted", "private", or "direct". |
in_reply_to_id | string | no | ID of the status to reply to. |
spoiler_text | string | no | Content warning text (marks the status as sensitive). |
sensitive | boolean | no | Whether the status contains sensitive media. |
language | string | no | ISO 639-1 language code (e.g., "en", "nl", "fr"). |
list_accounts Read
List followers of a Mastodon account. Returns account profiles with display names, bios, and follower counts. Supports pagination.
- Lua path
app.integrations.mastodon.list_accounts- Full name
mastodon.mastodon_list_accounts
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The account ID whose followers to list. |
limit | integer | no | Maximum number of accounts to return (1–80, default: 40). |
max_id | string | no | Return results older than this account ID (for pagination). |
get_account Read
Retrieve a Mastodon account profile by ID. Returns display name, bio, follower counts, and other profile details.
- Lua path
app.integrations.mastodon.get_account- Full name
mastodon.mastodon_get_account
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The account ID to retrieve. |
get_current_user Read
Get the authenticated user's Mastodon profile. Returns display name, bio, follower/following counts, and other account details.
- Lua path
app.integrations.mastodon.get_current_user- Full name
mastodon.mastodon_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
api_get Read
Call any Mastodon GET API endpoint relative to the configured instance, such as /api/v1/notifications.
- Lua path
app.integrations.mastodon.api_get- Full name
mastodon.mastodon_api_get
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | API path beginning with /api/. |
params | object | no | Query parameters. |
api_post Write
Call any Mastodon POST API endpoint relative to the configured instance.
- Lua path
app.integrations.mastodon.api_post- Full name
mastodon.mastodon_api_post
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | API path beginning with /api/. |
body | object | no | JSON request body. |
api_put Write
Call any Mastodon PUT API endpoint relative to the configured instance.
- Lua path
app.integrations.mastodon.api_put- Full name
mastodon.mastodon_api_put
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | API path beginning with /api/. |
body | object | no | JSON request body. |
api_delete Write
Call any Mastodon DELETE API endpoint relative to the configured instance.
- Lua path
app.integrations.mastodon.api_delete- Full name
mastodon.mastodon_api_delete
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | API path beginning with /api/. |
body | object | no | JSON request body. |