KosmoKrator

other

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.

7 functions 5 read 2 write Username and password auth

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 use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
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

Call Elastic Headlessly

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

kosmo integrations:call elastic.elastic_list_indices '{}' --json

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

kosmo integrations:elastic elastic_list_indices '{}' --json

Agent Discovery Commands

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

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 Elastic.

elastic.elastic_list_indices

Read read

List all indices in the Elasticsearch cluster. Returns index names, health status, document counts, and sizes.

Parameters
none

Generic CLI call

kosmo integrations:call elastic.elastic_list_indices '{}' --json

Provider shortcut

kosmo integrations:elastic elastic_list_indices '{}' --json

elastic.elastic_get_index

Read read

Get detailed information about a specific Elasticsearch index, including mappings, settings, and aliases.

Parameters
index

Generic CLI call

kosmo integrations:call elastic.elastic_get_index '{"index":"example_index"}' --json

Provider shortcut

kosmo integrations:elastic elastic_get_index '{"index":"example_index"}' --json

elastic.elastic_create_index

Write write

Create a new Elasticsearch index with optional settings and mappings.

Parameters
index, settings

Generic CLI call

kosmo integrations:call elastic.elastic_create_index '{"index":"example_index","settings":"example_settings"}' --json

Provider shortcut

kosmo integrations:elastic elastic_create_index '{"index":"example_index","settings":"example_settings"}' --json

elastic.elastic_search_documents

Read read

Search for documents in an Elasticsearch index. Supports full query DSL including match, term, bool, and aggregation queries.

Parameters
index, query, size, from

Generic CLI call

kosmo integrations:call elastic.elastic_search_documents '{"index":"example_index","query":"example_query","size":1,"from":1}' --json

Provider shortcut

kosmo integrations:elastic elastic_search_documents '{"index":"example_index","query":"example_query","size":1,"from":1}' --json

elastic.elastic_index_document

Write write

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.

Parameters
index, document, id

Generic CLI call

kosmo integrations:call elastic.elastic_index_document '{"index":"example_index","document":"example_document","id":"example_id"}' --json

Provider shortcut

kosmo integrations:elastic elastic_index_document '{"index":"example_index","document":"example_document","id":"example_id"}' --json

elastic.elastic_get_document

Read read

Retrieve a single document from an Elasticsearch index by its ID.

Parameters
index, id

Generic CLI call

kosmo integrations:call elastic.elastic_get_document '{"index":"example_index","id":"example_id"}' --json

Provider shortcut

kosmo integrations:elastic elastic_get_document '{"index":"example_index","id":"example_id"}' --json

elastic.elastic_cluster_health

Read read

Get the health status of the Elasticsearch cluster, including status (green/yellow/red), number of nodes, and shard information.

Parameters
none

Generic CLI call

kosmo integrations:call elastic.elastic_cluster_health '{}' --json

Provider shortcut

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

List all indices in the Elasticsearch cluster. Returns index names, health status, document counts, and sizes.

Operation
Read read
Schema command
kosmo integrations:schema elastic.elastic_list_indices --json
ParameterTypeRequiredDescription
No parameters.

elastic.elastic_get_index

Get detailed information about a specific Elasticsearch index, including mappings, settings, and aliases.

Operation
Read read
Schema command
kosmo integrations:schema elastic.elastic_get_index --json
ParameterTypeRequiredDescription
index string yes The name of the index to retrieve.

elastic.elastic_create_index

Create a new Elasticsearch index with optional settings and mappings.

Operation
Write write
Schema command
kosmo integrations:schema elastic.elastic_create_index --json
ParameterTypeRequiredDescription
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

Search for documents in an Elasticsearch index. Supports full query DSL including match, term, bool, and aggregation queries.

Operation
Read read
Schema command
kosmo integrations:schema elastic.elastic_search_documents --json
ParameterTypeRequiredDescription
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

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.

Operation
Write write
Schema command
kosmo integrations:schema elastic.elastic_index_document --json
ParameterTypeRequiredDescription
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

Retrieve a single document from an Elasticsearch index by its ID.

Operation
Read read
Schema command
kosmo integrations:schema elastic.elastic_get_document --json
ParameterTypeRequiredDescription
index string yes The index containing the document.
id string yes The document ID to retrieve.

elastic.elastic_cluster_health

Get the health status of the Elasticsearch cluster, including status (green/yellow/red), number of nodes, and shard information.

Operation
Read read
Schema command
kosmo integrations:schema elastic.elastic_cluster_health --json
ParameterTypeRequiredDescription
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.