Elasticsearch

by cr7258

100 stars
544 downloads
Not rated
GitHub

About

Enables natural language interaction with Elasticsearch clusters for querying, indexing, and management operations via Docker-deployed infrastructure.

Details

Author
cr7258
Repository
cr7258/elasticsearch-mcp-server
GitHub stars
100
Downloads
544
License
Apache License 2.0
Categories
Database, Other, Search, Infrastructure, Developer Tools, Design, Workplace, File Management, AI
Tags
#integration

- Tools for index, document, cluster, alias, and analyzer operations
- Multi‑cluster configuration with named clusters and a default target
- Authentication via username/password or API key (Elasticsearch)
- Option to disable high‑risk write operations
- Both stdio and SSE transport support
- Bearer token authentication for HTTP transports

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Elasticsearch
    Command (node, npx, python, etc.) uvx
    Arguments
    • Argument 1 elasticsearch-mcp-server
    Environment
    • DEFAULT_CLUSTER prod
    • ELASTICSEARCH_CLUSTERS {"prod": {"hosts": ["https://prod-es:9200"], "api_key": "<PROD_API_KEY>", "verify_certs": true}, "staging": {"hosts": ["https://staging-es:9200"], "username": "elastic", "password": "<STAGING_PASSWORD>"}}

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install via uvx (automatically from PyPI) or clone the repo and run with uv. Configure environment variables for host, authentication (username/password or API key), and optional multi-cluster settings. Add the configuration to your MCP client (e.g., Claude Desktop) using either the stdio or SSE transport.

general_api_request

Perform a general HTTP API request. Use this tool for any Elasticsearch/OpenSearch API that does not have a dedicated tool.

list_indices

List all indices.

get_index

Returns information (mappings, settings, aliases) about one or more indices.

create_index

Create a new index.

delete_index

Delete an index.

create_data_stream

Create a new data stream (requires matching index template).

get_data_stream

Get information about one or more data streams.

delete_data_stream

Delete one or more data streams and their backing indices.

search_documents

Search for documents.

index_document

Creates or updates a document in the index.

get_document

Get a document by ID.

delete_document

Delete a document by ID.

delete_by_query

Deletes documents matching the provided query.

get_cluster_health

Returns basic information about the health of the cluster.

get_cluster_stats

Returns high-level overview of cluster statistics.

list_aliases

List all aliases.

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 using a specified analyzer or custom analysis chain. Useful for debugging search queries and understanding how text is tokenized.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "elasticsearch": {
            "env": {
                "DEFAULT_CLUSTER": "prod",
                "ELASTICSEARCH_CLUSTERS": "{\"prod\": {\"hosts\": [\"https://prod-es:9200\"], \"api_key\": \"<PROD_API_KEY>\", \"verify_certs\": true}, \"staging\": {\"hosts\": [\"https://staging-es:9200\"], \"username\": \"elastic\", \"password\": \"<STAGING_PASSWORD>\"}}"
            },
            "args": [
                "elasticsearch-mcp-server"
            ],
            "command": "uvx"
        }
    }
}

Linux

{
    "env": {
        "DEFAULT_CLUSTER": "prod",
        "ELASTICSEARCH_CLUSTERS": "{\"prod\": {\"hosts\": [\"https://prod-es:9200\"], \"api_key\": \"<PROD_API_KEY>\", \"verify_certs\": true}, \"staging\": {\"hosts\": [\"https://staging-es:9200\"], \"username\": \"elastic\", \"password\": \"<STAGING_PASSWORD>\"}}"
    },
    "args": [
        "elasticsearch-mcp-server"
    ],
    "command": "uvx"
}

Macos

{
    "env": {
        "DEFAULT_CLUSTER": "prod",
        "ELASTICSEARCH_CLUSTERS": "{\"prod\": {\"hosts\": [\"https://prod-es:9200\"], \"api_key\": \"<PROD_API_KEY>\", \"verify_certs\": true}, \"staging\": {\"hosts\": [\"https://staging-es:9200\"], \"username\": \"elastic\", \"password\": \"<STAGING_PASSWORD>\"}}"
    },
    "args": [
        "elasticsearch-mcp-server"
    ],
    "command": "uvx"
}

Windows

{
    "env": {
        "DEFAULT_CLUSTER": "prod",
        "ELASTICSEARCH_CLUSTERS": "{\"prod\": {\"hosts\": [\"https://prod-es:9200\"], \"api_key\": \"<PROD_API_KEY>\", \"verify_certs\": true}, \"staging\": {\"hosts\": [\"https://staging-es:9200\"], \"username\": \"elastic\", \"password\": \"<STAGING_PASSWORD>\"}}"
    },
    "args": [
        "/c",
        "uvx",
        "elasticsearch-mcp-server"
    ],
    "command": "cmd"
}

API Key Authentication (Elasticsearch only) - Recommended

- ELASTICSEARCH_API_KEY: API key for](https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff15)ElasticsearchorElastic CloudAuthentication.

- ELASTICSEARCH_HOSTS/OPENSEARCH_HOSTS: Comma-separated list of hosts (default:https://localhost:9200)
- ELASTICSEARCH_CLUSTERS/OPENSEARCH_CLUSTERS: Inline JSON object for named cluster configurations. When set, tools can target a specific cluster with the optionalclusterparameter.
- ELASTICSEARCH_CLUSTERS_FILE/OPENSEARCH_CLUSTERS_FILE: Path to a JSON file with the clusters object. Recommended when the configuration is embedded inside another JSON file (e.g. the MCP client config) because it avoids JSON-in-JSON escaping. Takes precedence over the inline variable when both are set.
- DEFAULT_CLUSTER: Default cluster name to use when multi-cluster configuration is set and a tool call omitscluster(defaults to the first configured cluster).
- VERIFY_CERTS: Whether to verify SSL certificates (default:false)
- REQUEST_TIMEOUT: Request timeout in seconds (optional, uses client default if not set)

By default, the server uses a single Elasticsearch cluster fromELASTICSEARCH_HOSTS,ELASTICSEARCH_USERNAME,ELASTICSEARCH_PASSWORD, andELASTICSEARCH_API_KEY, or a single OpenSearch cluster fromOPENSEARCH_HOSTS,OPENSEARCH_USERNAME, andOPENSEARCH_PASSWORD. To configure multiple named clusters, setELASTICSEARCH_CLUSTERS(orOPENSEARCH_CLUSTERS) to a JSON object inside the MCP server configuration. Because the value is a JSON string embedded in another JSON file, the inner quotes need to be escaped:

{ "mcpServers": { "elasticsearch-mcp-server": { "command": "uvx", "args": [ "elasticsearch-mcp-server" ], "env": { "ELASTICSEARCH_CLUSTERS": "{\"prod\": {\"hosts\": [\"https://prod-es:9200\"], \"api_key\": \"<PROD_API_KEY>\", \"verify_certs\": true}, \"staging\": {\"hosts\": [\"https://staging-es:9200\"], \"username\": \"elastic\", \"password\": \"<STAGING_PASSWORD>\"}}", "DEFAULT_CLUSTER": "prod" } } } }

For better readability, pointELASTICSEARCH_CLUSTERS_FILE(orOPENSEARCH_CLUSTERS_FILE) at a standalone JSON file instead. The value is just a path so it avoids the JSON-in-JSON escaping:

{ "mcpServers": { "elasticsearch-mcp-server": { "command": "uvx", "args": [ "elasticsearch-mcp-server" ], "env": { "ELASTICSEARCH_CLUSTERS_FILE": "/etc/mcp/es-clusters.json", "DEFAULT_CLUSTER": "prod" } } } }
{ "prod": { "hosts": ["https://prod-es:9200"], "api_key": "<PROD_API_KEY>", "verify_certs": true }, "staging": { "hosts": ["https://staging-es:9200"], "username": "elastic", "password": "<STAGING_PASSWORD>" } }

Every tool accepts an optionalclusterparameter. If omitted, the server usesDEFAULT_CLUSTER. WhenDEFAULT_CLUSTERis not set, the first cluster in the JSON object is used as the default. A tool call targeting a specific cluster looks like:

{ "cluster": "staging", "index": "logs-*", "body": { "query": { "match_all": {} } } }
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.