data
Fauna Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Fauna KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.fauna.*.
Use lua_read_doc("integrations.fauna") 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
Fauna workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.fauna.list_databases({}))' --json kosmo integrations:lua --eval 'print(docs.read("fauna"))' --json
kosmo integrations:lua --eval 'print(docs.read("fauna.list_databases"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local fauna = app.integrations.fauna
local result = fauna.list_databases({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.fauna, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.fauna.default.* or app.integrations.fauna.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Fauna, 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.
Fauna — Lua API Reference
All tools are accessed via app.integrations.fauna.{tool_key}({params}).
fauna_list_databases
List all databases in the current Fauna context. Returns database names and their metadata including creation time and references.
Parameters
This tool takes no parameters.
Example
local result = app.integrations.fauna.fauna_list_databases()
for _, db in ipairs(result.data) do
print(db.name)
end
fauna_get_database
Get details of a specific Fauna database by name. Returns database metadata including name, reference, creation time, and configured options.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Database name |
Example
local db = app.integrations.fauna.fauna_get_database({
name = "my_database"
})
print(db.name)
print(db.ts)
fauna_create_database
Create a new Fauna database. Provide a database name and optional configuration. Requires a server or admin key. Returns the created database metadata.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Database name |
data_col | string | no | Region group for the database (e.g., "us-east-1") |
typecheck | boolean | no | Enable typechecking for the database |
Example
local result = app.integrations.fauna.fauna_create_database({
name = "my_new_database"
})
print("Created database: " .. result.name)
fauna_query_fql
Execute a Fauna Query Language (FQL) expression. Provide the query as a JSON-encoded FQL expression. Supports all FQL operations including document reads, writes, indexes, and complex queries.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
query | string | yes | JSON-encoded FQL query expression |
Example
local result = app.integrations.fauna.fauna_query_fql({
query = '{"paginate": {"match": {"index": "all_users"}}, "size": 10}'
})
for _, item in ipairs(result.data) do
print(item.id)
end
fauna_list_collections
List all collections in the current Fauna database. Returns collection names and their metadata including references and creation time.
Parameters
This tool takes no parameters.
Example
local result = app.integrations.fauna.fauna_list_collections()
for _, coll in ipairs(result.data) do
print(coll.name)
end
fauna_get_collection
Get details of a specific Fauna collection by name. Returns collection metadata including name, reference, creation time, and configured options.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | yes | Collection name |
Example
local coll = app.integrations.fauna.fauna_get_collection({
name = "users"
})
print(coll.name)
print(coll.ts)
fauna_get_current_user
Get the current authenticated Fauna key identity. Verifies the configured bearer token and returns the associated key identity information.
Parameters
This tool takes no parameters.
Example
local user = app.integrations.fauna.fauna_get_current_user()
print("Identity: " .. tostring(user))
Multi-Account Usage
If you have multiple Fauna accounts configured, use account-specific namespaces:
-- Default account (always works)
app.integrations.fauna.function_name({...})
-- Explicit default (portable across setups)
app.integrations.fauna.default.function_name({...})
-- Named accounts
app.integrations.fauna.production.function_name({...})
app.integrations.fauna.staging.function_name({...})
All functions are identical across accounts — only the credentials differ.
Raw agent markdown
# Fauna — Lua API Reference
All tools are accessed via `app.integrations.fauna.{tool_key}({params})`.
---
## fauna_list_databases
List all databases in the current Fauna context. Returns database names and their metadata including creation time and references.
### Parameters
This tool takes no parameters.
### Example
```lua
local result = app.integrations.fauna.fauna_list_databases()
for _, db in ipairs(result.data) do
print(db.name)
end
```
---
## fauna_get_database
Get details of a specific Fauna database by name. Returns database metadata including name, reference, creation time, and configured options.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Database name |
### Example
```lua
local db = app.integrations.fauna.fauna_get_database({
name = "my_database"
})
print(db.name)
print(db.ts)
```
---
## fauna_create_database
Create a new Fauna database. Provide a database name and optional configuration. Requires a server or admin key. Returns the created database metadata.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Database name |
| `data_col` | string | no | Region group for the database (e.g., `"us-east-1"`) |
| `typecheck` | boolean | no | Enable typechecking for the database |
### Example
```lua
local result = app.integrations.fauna.fauna_create_database({
name = "my_new_database"
})
print("Created database: " .. result.name)
```
---
## fauna_query_fql
Execute a Fauna Query Language (FQL) expression. Provide the query as a JSON-encoded FQL expression. Supports all FQL operations including document reads, writes, indexes, and complex queries.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `query` | string | yes | JSON-encoded FQL query expression |
### Example
```lua
local result = app.integrations.fauna.fauna_query_fql({
query = '{"paginate": {"match": {"index": "all_users"}}, "size": 10}'
})
for _, item in ipairs(result.data) do
print(item.id)
end
```
---
## fauna_list_collections
List all collections in the current Fauna database. Returns collection names and their metadata including references and creation time.
### Parameters
This tool takes no parameters.
### Example
```lua
local result = app.integrations.fauna.fauna_list_collections()
for _, coll in ipairs(result.data) do
print(coll.name)
end
```
---
## fauna_get_collection
Get details of a specific Fauna collection by name. Returns collection metadata including name, reference, creation time, and configured options.
### Parameters
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Collection name |
### Example
```lua
local coll = app.integrations.fauna.fauna_get_collection({
name = "users"
})
print(coll.name)
print(coll.ts)
```
---
## fauna_get_current_user
Get the current authenticated Fauna key identity. Verifies the configured bearer token and returns the associated key identity information.
### Parameters
This tool takes no parameters.
### Example
```lua
local user = app.integrations.fauna.fauna_get_current_user()
print("Identity: " .. tostring(user))
```
---
## Multi-Account Usage
If you have multiple Fauna accounts configured, use account-specific namespaces:
```lua
-- Default account (always works)
app.integrations.fauna.function_name({...})
-- Explicit default (portable across setups)
app.integrations.fauna.default.function_name({...})
-- Named accounts
app.integrations.fauna.production.function_name({...})
app.integrations.fauna.staging.function_name({...})
```
All functions are identical across accounts — only the credentials differ. local result = app.integrations.fauna.list_databases({})
print(result) Functions
list_databases Read
List all databases in the current Fauna context. Returns database names and their metadata including creation time and references.
- Lua path
app.integrations.fauna.list_databases- Full name
fauna.fauna_list_databases
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_database Read
Get details of a specific Fauna database by name. Returns database metadata including name, reference, creation time, and configured options.
- Lua path
app.integrations.fauna.get_database- Full name
fauna.fauna_get_database
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Database name. |
create_database Write
Create a new Fauna database. Provide a database name and optional configuration. Requires a server or admin key. Returns the created database metadata.
- Lua path
app.integrations.fauna.create_database- Full name
fauna.fauna_create_database
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Database name. |
data_col | string | no | Region group for the database (e.g., "us-east-1"). |
typecheck | boolean | no | Enable typechecking for the database. |
query_fql action
Execute a Fauna Query Language (FQL) expression. Provide the query as a JSON-encoded FQL expression. Supports all FQL operations including document reads, writes, indexes, and complex queries.
- Lua path
app.integrations.fauna.query_fql- Full name
fauna.fauna_query_fql
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | yes | JSON-encoded FQL query expression. |
list_collections Read
List all collections in the current Fauna database. Returns collection names and their metadata including references and creation time.
- Lua path
app.integrations.fauna.list_collections- Full name
fauna.fauna_list_collections
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_collection Read
Get details of a specific Fauna collection by name. Returns collection metadata including name, reference, creation time, and configured options.
- Lua path
app.integrations.fauna.get_collection- Full name
fauna.fauna_get_collection
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Collection name. |
get_current_user Read
Get the current authenticated Fauna key identity. Verifies the configured bearer token and returns the associated key identity information.
- Lua path
app.integrations.fauna.get_current_user- Full name
fauna.fauna_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||