data
Elastic CLI for AI Agents
Use the Elastic CLI from KosmoKrator to call Elastic tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Elastic CLI Setup
Elastic can be configured headlessly with `kosmokrator integrations:configure elastic`.
# 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 elastic --enable --read allow --write ask --json
kosmokrator integrations:doctor elastic --json
kosmokrator integrations:status --json Credentials
Authentication type: Username and password basic. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
api_key | ELASTIC_API_KEY | Secret secret | no | API Key |
username | ELASTIC_USERNAME | Text string | no | Username |
password | ELASTIC_PASSWORD | Secret secret | no | Password |
url | ELASTIC_URL | URL url | no | Elasticsearch URL |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call elastic.elastic_list_indices '{}' --json kosmo integrations:elastic elastic_list_indices '{}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs elastic --json
kosmo integrations:docs elastic.elastic_list_indices --json
kosmo integrations:schema elastic.elastic_list_indices --json
kosmo integrations:search "Elastic" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
elastic.elastic_list_indices
List all indices in the Elasticsearch cluster. Returns index names, health status, document counts, and sizes.
read - Parameters
- none
kosmo integrations:call elastic.elastic_list_indices '{}' --json kosmo integrations:elastic elastic_list_indices '{}' --json elastic.elastic_get_index
Get detailed information about a specific Elasticsearch index, including mappings, settings, and aliases.
read - Parameters
- index
kosmo integrations:call elastic.elastic_get_index '{"index":"example_index"}' --json kosmo integrations:elastic elastic_get_index '{"index":"example_index"}' --json elastic.elastic_create_index
Create a new Elasticsearch index with optional settings and mappings.
write - Parameters
- index, settings
kosmo integrations:call elastic.elastic_create_index '{"index":"example_index","settings":"example_settings"}' --json kosmo integrations:elastic elastic_create_index '{"index":"example_index","settings":"example_settings"}' --json elastic.elastic_search_documents
Search for documents in an Elasticsearch index. Supports full query DSL including match, term, bool, and aggregation queries.
read - Parameters
- index, query, size, from
kosmo integrations:call elastic.elastic_search_documents '{"index":"example_index","query":"example_query","size":1,"from":1}' --json kosmo integrations:elastic elastic_search_documents '{"index":"example_index","query":"example_query","size":1,"from":1}' --json elastic.elastic_index_document
Create or update a document in an Elasticsearch index. Provide an ID to update an existing document, or omit it to let Elasticsearch auto-generate one.
write - Parameters
- index, document, id
kosmo integrations:call elastic.elastic_index_document '{"index":"example_index","document":"example_document","id":"example_id"}' --json kosmo integrations:elastic elastic_index_document '{"index":"example_index","document":"example_document","id":"example_id"}' --json elastic.elastic_get_document
Retrieve a single document from an Elasticsearch index by its ID.
read - Parameters
- index, id
kosmo integrations:call elastic.elastic_get_document '{"index":"example_index","id":"example_id"}' --json kosmo integrations:elastic elastic_get_document '{"index":"example_index","id":"example_id"}' --json elastic.elastic_cluster_health
Get the health status of the Elasticsearch cluster, including status (green/yellow/red), number of nodes, and shard information.
read - Parameters
- none
kosmo integrations:call elastic.elastic_cluster_health '{}' --json kosmo integrations:elastic elastic_cluster_health '{}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
elastic.elastic_list_indices 0 parameters
kosmo integrations:schema elastic.elastic_list_indices --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
elastic.elastic_get_index 1 parameters
kosmo integrations:schema elastic.elastic_get_index --json | Parameter | Type | Required | Description |
|---|---|---|---|
index | string | yes | The name of the index to retrieve. |
elastic.elastic_create_index 2 parameters
kosmo integrations:schema elastic.elastic_create_index --json | Parameter | Type | Required | Description |
|---|---|---|---|
index | string | yes | The name for the new index. |
settings | object | no | Optional index settings and mappings. Example: {"settings": {"number_of_shards": 1}, "mappings": {"properties": {"title": {"type": "text"}}}} |
elastic.elastic_search_documents 4 parameters
kosmo integrations:schema elastic.elastic_search_documents --json | Parameter | Type | Required | Description |
|---|---|---|---|
index | string | yes | The index to search in. |
query | object | no | The Elasticsearch query object. Example: {"match": {"title": "search term"}}. Defaults to match_all if omitted. |
size | integer | no | Maximum number of results to return (default: 10). |
from | integer | no | Starting offset for pagination (default: 0). |
elastic.elastic_index_document 3 parameters
kosmo integrations:schema elastic.elastic_index_document --json | Parameter | Type | Required | Description |
|---|---|---|---|
index | string | yes | The target index name. |
document | object | yes | The document body to index. Example: {"title": "My Document", "content": "Hello world"} |
id | string | no | Optional document ID. If provided, the document is created or replaced with this ID. If omitted, Elasticsearch auto-generates an ID. |
elastic.elastic_get_document 2 parameters
kosmo integrations:schema elastic.elastic_get_document --json | Parameter | Type | Required | Description |
|---|---|---|---|
index | string | yes | The index containing the document. |
id | string | yes | The document ID to retrieve. |
elastic.elastic_cluster_health 0 parameters
kosmo integrations:schema elastic.elastic_cluster_health --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
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.