Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to Elasticsearch

Scalekit connector
Open markdown

The Elasticsearch connector lets your AI agent act in each user's Elasticsearch account. Each user connects their own Elasticsearch API key once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 25 tools.

Tools
25
What they doRead · write · destructive
14 · 8 · 314 read8 write3 destructive
Users sign in with

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the Elasticsearch connection

    In AgentKit > Connections, create an Elasticsearch connection. The name you give it is the connection_name your code passes. See Configure connections.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'elasticsearch'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Elasticsearch:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'elasticsearch_aliases_list',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user opens the link once and enters their Elasticsearch credentials there. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • elasticsearch_aliases_listList index aliases in the cluster as JSON.Read-only

    List Aliases

    List index aliases in the cluster as JSON. Returns one row per alias with alias, index, filter, routing and is_write_index. Use Update Aliases to add, move or remove aliases.

    Inputs

    hstring
    Columns to return. Example: alias,index,is_write_index.
    sstring
    Columns to sort by. Example: alias.
  • elasticsearch_cluster_health_getGet the health of the Elasticsearch cluster.Read-only

    Get Cluster Health

    Get the health of the Elasticsearch cluster. Returns status (green, yellow or red), number_of_nodes, active and unassigned shard counts and pending tasks. Use level=indices to get health per index.

    Inputs

    levelstring
    Detail level: cluster (default), indices or shards. Example: indices.one of clusterindicesshards
    timeoutstring
    How long to wait when wait_for_status is set, as a time unit. Elasticsearch defaults to 30s. Example: 10s.
    wait_for_statusstring
    Wait until the cluster reaches at least this status, up to timeout: green, yellow or red. Example: yellow.one of greenyellowred
  • elasticsearch_cluster_info_getGet basic information about the Elasticsearch cluster.Read-only

    Get Cluster Info

    Get basic information about the Elasticsearch cluster. Returns the node name, cluster_name, cluster_uuid and version details (number, build flavor, Lucene version). Use this to test the connection and check the Elasticsearch version.

    Inputs

    This tool takes no inputs.

  • elasticsearch_countCount the documents matching a query in one or more indices.Read-only

    Count Documents

    Count the documents matching a query in one or more indices. Returns count and _shards. Omit query to count every document.

    Inputs

    indexstringrequired
    Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.
    queryobject
    Query DSL object selecting the documents to count. Example: {"match": {"title": "laptop"}}.
  • elasticsearch_document_getGet one document by index and ID.Read-only

    Get Document

    Get one document by index and ID. Returns _index, _id, _version, found and the document in _source. Use Search for anything other than a lookup by ID.

    Inputs

    idstringrequired
    Document ID. Example: sku-1001.
    indexstringrequired
    Name of a single index. Example: products.
    routingstring
    Custom routing value used when the document was indexed. Example: user-42.
    source_includesstring
    Comma-separated source fields to return. Example: title,price.
  • elasticsearch_documents_get_manyGet several documents from an index by ID in one request.Read-only

    Get Multiple Documents

    Get several documents from an index by ID in one request. Returns docs, one entry per ID with found, _version and _source. Use this instead of repeated Get Document calls.

    Inputs

    idsarrayrequired
    Document IDs to fetch. Example: ["sku-1001", "sku-1002"].
    indexstringrequired
    Name of a single index. Example: products.
    source_includesstring
    Comma-separated source fields to return. Example: title,price.
  • elasticsearch_esql_queryRun an ES|QL piped query, for example FROM products | WHERE price > 100 | STATS avg(price) BY brand.Read-only

    ES|QL Query

    Run an ES|QL piped query, for example FROM products | WHERE price > 100 | STATS avg(price) BY brand. Returns columns (name and type) and values as rows. Use this for analytics-style queries; use Search for full-text relevance search.

    Inputs

    querystringrequired
    The ES|QL query. Example: FROM products | WHERE price > 100 | STATS avg_price = AVG(price) BY brand | LIMIT 10.
    columnarboolean
    Set true to return values column by column instead of row by row. Example: false.
    filterobject
    Query DSL filter applied before the ES|QL query. Example: {"range": {"@timestamp": {"gte": "now-1d"}}}.
    paramsarray
    Values for ? placeholders in the query, in order. Example: [100].
  • elasticsearch_field_capabilities_getGet the type and search or aggregation capability of fields across one or more indices.Read-only

    Get Field Capabilities

    Get the type and search or aggregation capability of fields across one or more indices. Returns indices and fields, each field keyed by type with searchable and aggregatable flags. Use this to check whether a field can be sorted or aggregated on.

    Inputs

    fieldsstringrequired
    Comma-separated field names; wildcards allowed. Example: title,price,*_at.
    indexstringrequired
    Index name, or a comma-separated list or wildcard pattern where the API allows it. Example: products.