Skip to main content
Glama
Elasticsearch MCP Server

Elasticsearch MCP Server

by awesimon

Elasticsearch MCP Server

English | 中文

MCP Server for connecting to your Elasticsearch cluster directly from any MCP Client (like Claude Desktop, Cursor).

This server connects agents to your Elasticsearch data using the Model Context Protocol. It allows you to interact with your Elasticsearch indices through natural language conversations.

Demo

Elasticsearch MCP Demo

Related MCP server: Elasticsearch MCP Server

Feature Overview

Available Features

Cluster Management

  • elasticsearch_health: Get Elasticsearch cluster health status, optionally including index-level details

Index Operations

  • list_indices: List available Elasticsearch indices, support regex

  • create_index: Create Elasticsearch index with optional settings and mappings

  • reindex: Reindex data from a source index to a target index with optional query and script

Mapping Management

  • get_mappings: Get field mappings for a specific Elasticsearch index

  • create_mapping: Create or update mapping structure for an Elasticsearch index

Search & Data Operations

  • search: Perform an Elasticsearch search with the provided query DSL

  • bulk: Bulk data into an Elasticsearch index

Template Management

  • create_index_template: Create or update an index template

  • get_index_template: Get information about index templates

  • delete_index_template: Delete an index template

How It Works

  1. The MCP Client analyzes your request and determines which Elasticsearch operations are needed.

  2. The MCP server carries out these operations (listing indices, fetching mappings, performing searches).

  3. The MCP Client processes the results and presents them in a user-friendly format.

Getting Started

Prerequisites

  • Elasticsearch 8.x (recommended; this is the current primary compatibility target)

  • An Elasticsearch instance

  • Elasticsearch authentication credentials (API key or username/password)

  • MCP Client (e.g. Claude Desktop, Cursor)

NOTE

This project depends on the Node.js client@elastic/elasticsearch@^8.17.1. That client dependency is not a minimum Elasticsearch server version. Elastic's official compatibility matrix aligns client and server major versions and describes forward compatibility with higher minor versions within the same major version. This repository does not claim that every Elasticsearch 8.x minor or patch release has been validated; npm test currently runs TypeScript compilation only and does not establish Elasticsearch server compatibility. Elasticsearch 7.x, 9.x, and other major versions have not been validated.

Installation & Setup

Using the Published NPM Package

TIP

The easiest way to use Elasticsearch MCP Server is through the published npm package.

  1. Configure MCP Client

    • Open your MCP Client. See the list of MCP Clients, here we are configuring Claude Desktop.

    • Go to Settings > Developer > MCP Servers

    • Click Edit Config and add a new MCP Server with the following configuration:

    {
      "mcpServers": {
        "elasticsearch-mcp": {
          "command": "npx",
          "args": [
            "-y",
            "@awesome-ai/elasticsearch-mcp"
          ],
          "env": {
            "ES_HOST": "your-elasticsearch-host",
            "ES_API_KEY": "your-api-key"
          }
        }
      }
    }
  2. Start a Conversation

    • Open a new conversation in your MCP Client.

    • The MCP server should connect automatically.

    • You can now ask questions about your Elasticsearch data.

Configuration Options

The Elasticsearch MCP Server supports configuration options to connect to your Elasticsearch:

NOTE

You must provide either an API key or both username and password for authentication.

Environment Variable

Description

Required

ES_HOST

Your Elasticsearch instance URL(s) - supports single URL or comma-separated multiple URLs (also supports legacy HOST)

Yes

ES_API_KEY

Elasticsearch API key for authentication (also supports legacy API_KEY)

No

ES_USERNAME

Elasticsearch username for basic authentication (also supports legacy USERNAME)

No

ES_PASSWORD

Elasticsearch password for basic authentication (also supports legacy PASSWORD)

No

ES_CA_CERT

Path to custom CA certificate for Elasticsearch SSL/TLS (also supports legacy CA_CERT)

No

Multiple URLs Configuration

You can configure multiple Elasticsearch nodes for high availability and load balancing:

{
  "mcpServers": {
    "elasticsearch-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@awesome-ai/elasticsearch-mcp"
      ],
      "env": {
        "ES_HOST": "https://es-node1:9200,https://es-node2:9200,https://es-node3:9200",
        "ES_API_KEY": "your-api-key"
      }
    }
  }
}

The client will automatically handle failover and load balancing between the configured nodes.

Local Development

NOTE

If you want to modify or extend the MCP Server, follow these local development steps.

  1. Use the correct Node.js version

    nvm use
  2. Install Dependencies

    npm install
  3. Build the Project

    npm run build
  4. Run locally in Claude Desktop App

    • Open Claude Desktop App

    • Go to Settings > Developer > MCP Servers

    • Click Edit Config and add a new MCP Server with the following configuration:

    {
      "mcpServers": {
        "elasticsearch-mcp": {
          "command": "node",
          "args": [
            "/path/to/your/project/dist/index.js"
          ],
          "env": {
            "ES_HOST": "your-elasticsearch-host",
            "ES_API_KEY": "your-api-key"
          }
        }
      }
    }
  5. Run locally in Cursor Editor

    • Open Cursor Editor

    • Go to Cursor Settings > MCP

    • Click Add new global MCP Server and add a new MCP Server with the following configuration:

    {
      "mcpServers": {
        "elasticsearch-mcp": {
          "command": "node",
          "args": [
            "/path/to/your/project/dist/index.js"
          ],
          "env": {
            "ES_HOST": "your-elasticsearch-host",
            "ES_API_KEY": "your-api-key"
          }
        }
      }
    }
  6. Debugging with MCP Inspector

    ES_HOST=your-elasticsearch-url ES_API_KEY=your-api-key npm run inspector

    This will start the MCP Inspector, allowing you to debug and analyze requests. You should see:

    Starting MCP inspector...
    ⚙️ Proxy server listening on port 6277
    🔍 MCP Inspector is up and running at http://127.0.0.1:6274 🚀

Example Queries

TIP

Here are some natural language queries you can try with your MCP Client.

Cluster Management

  • "What is the health status of my Elasticsearch cluster?"

  • "How many active nodes are in my cluster?"

Index Operations

  • "What indices do I have in my Elasticsearch cluster?"

  • "Create a new index called 'users' with 3 shards and 1 replica."

  • "Reindex data from 'old_index' to 'new_index'."

Mapping Management

  • "Show me the field mappings for the 'products' index."

  • "Add a keyword type field called 'tags' to the 'products' index."

Search & Data Operations

  • "Find all orders over $500 from last month."

  • "Which products received the most 5-star reviews?"

  • "Bulk import these customer records into the 'customers' index."

Template Management

  • "Create an index template for logs with pattern 'logs-*'."

  • "Show me all my index templates."

  • "Delete the 'outdated_template' index template."

If you encounter issues, feel free to open an issue on the GitHub repository.

Available Tools

11 tools
bulkD

Bulk data into an Elasticsearch index

Inputs: index (required), documents (required), idField.

create_indexB

Create an Elasticsearch index, optionally configure settings and mappings

Inputs: index (required), settings, mappings.

create_index_templateB

Create or update an Elasticsearch index template

Inputs: name (required), indexPatterns (required), template (required), priority, +1 more.

create_mappingB

Create or update the mapping structure of an Elasticsearch index

Inputs: index (required), mappings (required).

delete_index_templateC

Delete an Elasticsearch index template

Inputs: name (required).

elasticsearch_healthB

Get the health status of the Elasticsearch cluster, optionally include index-level details

Inputs: includeIndices.

get_index_templateB

Get information about Elasticsearch index templates

Inputs: name.

get_mappingsB

Get field mappings for a specific Elasticsearch index

Inputs: index (required).

list_indicesA

List all available Elasticsearch indices, support regex

Inputs: pattern.

reindexB

Reindex data from a source index to a target index

Inputs: sourceIndex (required), destIndex (required), query, script.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool targets a distinct Elasticsearch resource and action (e.g., create_index, create_mapping, search, bulk). There is no overlap or ambiguity; tools are clearly differentiated by their purpose.

    Naming Consistency4/5

    Most tools follow a verb_noun pattern with underscores (e.g., create_index, get_mappings). However, 'elasticsearch_health' deviates by starting with a noun instead of a verb, causing a minor inconsistency.

    Tool Count5/5

    With 11 tools, the server covers a reasonable breadth of Elasticsearch operations (index management, search, mapping, templates) without being excessive. The count fits well within the typical 3-15 range for a focused server.

    Completeness2/5

    The tool set lacks essential operations like deleting an index and document-level CRUD (get, delete by ID). While bulk and search are present, agents cannot perform complete lifecycle management, leading to significant gaps.

    Maintenance

    ActivityMaintained
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      A
      maintenance
      Facilitates interaction with Elasticsearch clusters by allowing users to perform index operations, document searches, and cluster management via a Model Context Protocol server and natural language commands.
      20
      320
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables LLMs to interact with Elasticsearch clusters, allowing them to manage indices and execute search queries using natural language.
      2
      -
    • A
      license
      B
      quality
      D
      maintenance
      Connects Claude and other MCP clients to Elasticsearch data, allowing users to interact with their Elasticsearch indices through natural language conversations.
      3
      735
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      Connects to Elasticsearch databases using the Model Context Protocol, allowing users to query and interact with their Elasticsearch indices through natural language conversations.
      4
      Apache 2.0