KosmoKrator

data

Directus CLI for AI Agents

Use the Directus CLI from KosmoKrator to call Directus tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

7 functions 4 read 3 write Bearer token auth

Directus CLI Setup

Directus can be configured headlessly with `kosmokrator integrations:configure directus`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure directus --set access_token="$DIRECTUS_ACCESS_TOKEN" --set url="$DIRECTUS_URL" --enable --read allow --write ask --json
kosmokrator integrations:doctor directus --json
kosmokrator integrations:status --json

Credentials

Authentication type: Bearer token bearer_token. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
access_token DIRECTUS_ACCESS_TOKEN Secret secret yes Access Token
url DIRECTUS_URL URL url yes Instance URL

Call Directus Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call directus.directus_list_items '{
  "collection": "example_collection",
  "limit": 1,
  "offset": 1,
  "sort": "example_sort",
  "filter": "example_filter",
  "fields": "example_fields",
  "search": "example_search",
  "page": 1
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:directus directus_list_items '{
  "collection": "example_collection",
  "limit": 1,
  "offset": 1,
  "sort": "example_sort",
  "filter": "example_filter",
  "fields": "example_fields",
  "search": "example_search",
  "page": 1
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs directus --json
kosmo integrations:docs directus.directus_list_items --json
kosmo integrations:schema directus.directus_list_items --json
kosmo integrations:search "Directus" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Directus.

directus.directus_list_items

Read read

List items in a Directus collection with optional filtering, sorting, and pagination. Returns an array of items from the specified collection.

Parameters
collection, limit, offset, sort, filter, fields, search, page, meta

Generic CLI call

kosmo integrations:call directus.directus_list_items '{"collection":"example_collection","limit":1,"offset":1,"sort":"example_sort","filter":"example_filter","fields":"example_fields","search":"example_search","page":1}' --json

Provider shortcut

kosmo integrations:directus directus_list_items '{"collection":"example_collection","limit":1,"offset":1,"sort":"example_sort","filter":"example_filter","fields":"example_fields","search":"example_search","page":1}' --json

directus.directus_get_item

Read read

Retrieve a single item from a Directus collection by its primary key ID.

Parameters
collection, id, fields

Generic CLI call

kosmo integrations:call directus.directus_get_item '{"collection":"example_collection","id":"example_id","fields":"example_fields"}' --json

Provider shortcut

kosmo integrations:directus directus_get_item '{"collection":"example_collection","id":"example_id","fields":"example_fields"}' --json

directus.directus_create_item

Write write

Create a new item in a Directus collection with the provided field values.

Parameters
collection, data

Generic CLI call

kosmo integrations:call directus.directus_create_item '{"collection":"example_collection","data":"example_data"}' --json

Provider shortcut

kosmo integrations:directus directus_create_item '{"collection":"example_collection","data":"example_data"}' --json

directus.directus_update_item

Write write

Update an existing item in a Directus collection by its primary key ID.

Parameters
collection, id, data

Generic CLI call

kosmo integrations:call directus.directus_update_item '{"collection":"example_collection","id":"example_id","data":"example_data"}' --json

Provider shortcut

kosmo integrations:directus directus_update_item '{"collection":"example_collection","id":"example_id","data":"example_data"}' --json

directus.directus_delete_item

Write write

Delete an item from a Directus collection by its primary key ID. This action cannot be undone.

Parameters
collection, id

Generic CLI call

kosmo integrations:call directus.directus_delete_item '{"collection":"example_collection","id":"example_id"}' --json

Provider shortcut

kosmo integrations:directus directus_delete_item '{"collection":"example_collection","id":"example_id"}' --json

directus.directus_list_collections

Read read

List all available collections (tables) in the Directus instance. Returns collection names and metadata.

Parameters
none

Generic CLI call

kosmo integrations:call directus.directus_list_collections '{}' --json

Provider shortcut

kosmo integrations:directus directus_list_collections '{}' --json

directus.directus_get_current_user

Read read

Get the profile of the currently authenticated Directus user. Useful for verifying the connection and understanding user permissions.

Parameters
fields

Generic CLI call

kosmo integrations:call directus.directus_get_current_user '{"fields":"example_fields"}' --json

Provider shortcut

kosmo integrations:directus directus_get_current_user '{"fields":"example_fields"}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

directus.directus_list_items

List items in a Directus collection with optional filtering, sorting, and pagination. Returns an array of items from the specified collection.

Operation
Read read
Schema command
kosmo integrations:schema directus.directus_list_items --json
ParameterTypeRequiredDescription
collection string yes The collection name to query (e.g. "articles", "products").
limit integer no Maximum number of items to return (default: 100, max depends on instance).
offset integer no Number of items to skip for pagination.
sort string no Sort field(s). Prefix with "-" for descending (e.g. "-date_created").
filter object no Directus filter object for querying. E.g. {"status": {"_eq": "published"}}.
fields string no Comma-separated list of fields to include in the response.
search string no Search query to filter items across searchable fields.
page integer no Page number for pagination (alternative to offset).
meta string no Metadata to include. Use "total_count" to get total matching items.

directus.directus_get_item

Retrieve a single item from a Directus collection by its primary key ID.

Operation
Read read
Schema command
kosmo integrations:schema directus.directus_get_item --json
ParameterTypeRequiredDescription
collection string yes The collection name (e.g. "articles", "products").
id string yes The primary key of the item to retrieve.
fields string no Comma-separated list of fields to include in the response.

directus.directus_create_item

Create a new item in a Directus collection with the provided field values.

Operation
Write write
Schema command
kosmo integrations:schema directus.directus_create_item --json
ParameterTypeRequiredDescription
collection string yes The collection name (e.g. "articles", "products").
data object yes Object containing the field values for the new item. Keys are field names, values are the field data.

directus.directus_update_item

Update an existing item in a Directus collection by its primary key ID.

Operation
Write write
Schema command
kosmo integrations:schema directus.directus_update_item --json
ParameterTypeRequiredDescription
collection string yes The collection name (e.g. "articles", "products").
id string yes The primary key of the item to update.
data object yes Object containing the field values to update. Keys are field names, values are the new data.

directus.directus_delete_item

Delete an item from a Directus collection by its primary key ID. This action cannot be undone.

Operation
Write write
Schema command
kosmo integrations:schema directus.directus_delete_item --json
ParameterTypeRequiredDescription
collection string yes The collection name (e.g. "articles", "products").
id string yes The primary key of the item to delete.

directus.directus_list_collections

List all available collections (tables) in the Directus instance. Returns collection names and metadata.

Operation
Read read
Schema command
kosmo integrations:schema directus.directus_list_collections --json
ParameterTypeRequiredDescription
No parameters.

directus.directus_get_current_user

Get the profile of the currently authenticated Directus user. Useful for verifying the connection and understanding user permissions.

Operation
Read read
Schema command
kosmo integrations:schema directus.directus_get_current_user --json
ParameterTypeRequiredDescription
fields string no Comma-separated list of user fields to include (e.g. "id,email,first_name,last_name,role").

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.