home / mcp / elasticsearch mcp server

Elasticsearch MCP Server

Provides Elasticsearch and OpenSearch interactions for indexing, searching, and cluster management through a configurable MCP runtime.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "cr7258-elasticsearch-mcp-server": {
      "command": "uvx",
      "args": [
        "elasticsearch-mcp-server"
      ],
      "env": {
        "OPENSEARCH_HOSTS": "https://localhost:9200",
        "ELASTICSEARCH_HOSTS": "https://localhost:9200",
        "OPENSEARCH_PASSWORD": "admin",
        "OPENSEARCH_USERNAME": "admin",
        "ELASTICSEARCH_API_KEY": "YOUR_ELASTICSEARCH_API_KEY",
        "ELASTICSEARCH_PASSWORD": "test123",
        "ELASTICSEARCH_USERNAME": "elastic"
      }
    }
  }
}

You can use this MCP server to interact with Elasticsearch or OpenSearch clusters, performing index, document, and cluster operations through a consolidated set of tools. It enables searching, indexing, and managing your data and cluster health via a configurable runtime that supports both local development and production deployments.

How to use

You will connect to the MCP server using an MCP-compatible client. Start the MCP server in stdio mode to run locally, then configure your client to invoke the available tools for Elasticsearch or OpenSearch operations. Use the provided credentials or API keys to authenticate with your cluster, and select the appropriate tools for tasks such as listing indices, indexing documents, searching content, and managing data streams or aliases.

How to install

Prerequisites: you need Python installed to run the MCP server components, as well as a running Elasticsearch or OpenSearch cluster you can connect to. You also need a terminal with access to the uvx or uv runtime if you plan to run the MCP server from the command line.

Configuration and security

Configure access to your Elasticsearch and OpenSearch clusters through environment variables in your runtime. You can enable basic authentication or API key authentication for Elasticsearch, and provide the appropriate host URLs. For HTTP transports, you can enable an API key and protect the MCP server with a Bearer token. It is recommended to set a strong MCP_API_KEY in production to prevent unauthorized access.

Examples of available tools

General, index, document, and cluster operations are exposed as tools you can call through your MCP client. These tools provide concrete actions such as:

Troubleshooting tips

If you cannot reach your cluster, verify network connectivity, SSL verification settings, and correct host URLs in your environment variables. Check authentication credentials and ensure the MCP_API_KEY is set when using HTTP transports. Review server logs for any startup or connection errors and confirm the MCP server start command used in your environment matches the tooling configuration.

Available tools

general_api_request

Perform a general HTTP API request for Elasticsearch/OpenSearch APIs without a dedicated tool.

list_indices

List all indices in the connected cluster.

get_index

Retrieve information about one or more indices, including mappings, settings, and aliases.

create_index

Create a new index with the specified mappings and settings.

delete_index

Delete a specified index.

create_data_stream

Create a new data stream tied to a matching index template.

get_data_stream

Retrieve information about data streams.

delete_data_stream

Delete one or more data streams and their backing indices.

search_documents

Search for documents within an index or data stream.

index_document

Create or update a document in the index.

get_document

Retrieve a document by its ID.

delete_document

Delete a document by its ID.

delete_by_query

Delete documents matching a given query.

get_cluster_health

Return basic health information about the cluster.

get_cluster_stats

Return high-level statistics about the cluster.

list_aliases

List all aliases in the cluster.

get_alias

Get alias information for a specific index.

put_alias

Create or update an alias for a specific index.

delete_alias

Delete an alias for a specific index.

analyze_text

Analyze text with a specified analyzer or custom analysis chain to understand tokenization.

Elasticsearch MCP Server - cr7258/elasticsearch-mcp-server