MCP Official Registry A Model Context Protocol (MCP) server implementation that provides Elasticsearch and OpenSearch interaction. This server enables searching documents, analyzing indices, and managing cluster through a set of tools. - generalapirequest: Perform a general HTTP API request. Use this tool for any Elasticsearch/OpenSearch API that does not have a dedicated tool. - listindices: List
Add this skill
npx mdskills install cr7258/elasticsearch-mcp-serverComprehensive MCP server providing robust Elasticsearch/OpenSearch integration with extensive operations
12<!-- mcp-name: io.github.cr7258/elasticsearch-mcp-server -->34# Elasticsearch/OpenSearch MCP Server56[](https://mseep.ai/app/cr7258-elasticsearch-mcp-server)78[](https://archestra.ai/mcp-catalog/cr7258__elasticsearch-mcp-server)910[MCP Official Registry]( https://registry.modelcontextprotocol.io/v0/servers?search=io.github.cr7258/elasticsearch-mcp-server)1112## Overview1314A Model Context Protocol (MCP) server implementation that provides Elasticsearch and OpenSearch interaction. This server enables searching documents, analyzing indices, and managing cluster through a set of tools.1516<a href="https://glama.ai/mcp/servers/b3po3delex"><img width="380" height="200" src="https://glama.ai/mcp/servers/b3po3delex/badge" alt="Elasticsearch MCP Server" /></a>1718## Demo1920https://github.com/user-attachments/assets/f7409e31-fac4-4321-9c94-b0ff2ea7ff152122## Features2324### General Operations2526- `general_api_request`: Perform a general HTTP API request. Use this tool for any Elasticsearch/OpenSearch API that does not have a dedicated tool.2728### Index Operations2930- `list_indices`: List all indices.31- `get_index`: Returns information (mappings, settings, aliases) about one or more indices.32- `create_index`: Create a new index.33- `delete_index`: Delete an index.34- `create_data_stream`: Create a new data stream (requires matching index template).35- `get_data_stream`: Get information about one or more data streams.36- `delete_data_stream`: Delete one or more data streams and their backing indices.3738### Document Operations3940- `search_documents`: Search for documents.41- `index_document`: Creates or updates a document in the index.42- `get_document`: Get a document by ID.43- `delete_document`: Delete a document by ID.44- `delete_by_query`: Deletes documents matching the provided query.4546### Cluster Operations4748- `get_cluster_health`: Returns basic information about the health of the cluster.49- `get_cluster_stats`: Returns high-level overview of cluster statistics.5051### Alias Operations5253- `list_aliases`: List all aliases.54- `get_alias`: Get alias information for a specific index.55- `put_alias`: Create or update an alias for a specific index.56- `delete_alias`: Delete an alias for a specific index.5758### Analyzer Operations5960- `analyze_text`: Analyze text using a specified analyzer or custom analysis chain. Useful for debugging search queries and understanding how text is tokenized.6162## Configure Environment Variables6364The MCP server supports the following environment variables:6566### Basic Authentication (Username/Password)67- `ELASTICSEARCH_USERNAME`: Username for basic authentication68- `ELASTICSEARCH_PASSWORD`: Password for basic authentication69- `OPENSEARCH_USERNAME`: Username for OpenSearch basic authentication70- `OPENSEARCH_PASSWORD`: Password for OpenSearch basic authentication7172### API Key Authentication (Elasticsearch only) - Recommended73- `ELASTICSEARCH_API_KEY`: API key for [Elasticsearch](https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys) or [Elastic Cloud](https://www.elastic.co/docs/deploy-manage/api-keys/elastic-cloud-api-keys) Authentication.7475### Connection Settings76- `ELASTICSEARCH_HOSTS` / `OPENSEARCH_HOSTS`: Comma-separated list of hosts (default: `https://localhost:9200`)77- `VERIFY_CERTS`: Whether to verify SSL certificates (default: `false`)78- `REQUEST_TIMEOUT`: Request timeout in seconds (optional, uses client default if not set)7980### MCP Server Authentication (HTTP Transports Only)8182When running the MCP server with HTTP-based transports (SSE or Streamable HTTP), you can enable Bearer token authentication to protect the server from unauthorized access.8384- `MCP_API_KEY`: API key for MCP server authentication. Clients must include `Authorization: Bearer <MCP_API_KEY>` header.8586**Important Security Notes:**87- Authentication is **only applicable** for HTTP transports (`sse`, `streamable-http`). The `stdio` transport uses local process communication and doesn't require authentication.88- If `MCP_API_KEY` is **not set**, the MCP server will be accessible **without authentication**. This is a security risk when exposing the server over a network.89- For production deployments with HTTP transports, **always set `MCP_API_KEY`**.9091```bash92# Generate a secure API key (example using openssl)93export MCP_API_KEY=$(openssl rand -base64 32)9495# Or set a custom API key96export MCP_API_KEY="your-secure-api-key-here"97```9899### Disable High-Risk Operations100101- `DISABLE_HIGH_RISK_OPERATIONS`: Set to `true` to disable all write operations (default: `false`)102- `DISABLE_OPERATIONS`: Comma-separated list of specific operations to disable (optional, uses default write operations list if not set)103104When `DISABLE_HIGH_RISK_OPERATIONS` is set to true, all MCP tools that perform write operations are completely hidden from the MCP client. In this mode, the following MCP tools are disabled by default.105106- **Index Operations:**107 - `create_index`108 - `delete_index`109110- **Document Operations:**111 - `index_document`112 - `delete_document`113 - `delete_by_query`114115- **Data Stream Operations:**116 - `create_data_stream`117 - `delete_data_stream`118119- **Alias Operations:**120 - `put_alias`121 - `delete_alias`122123- **General API Operations:**124 - `general_api_request`125126Optionally, you can specify a comma-separated list of operations to disable in the `DISABLE_OPERATIONS` environment variable.127128```bash129# Disable High-Risk Operations130export DISABLE_HIGH_RISK_OPERATIONS=true131# Disable specific operations only132export DISABLE_OPERATIONS="delete_index,delete_document,delete_by_query"133```134135## Start Elasticsearch/OpenSearch Cluster136137Start the Elasticsearch/OpenSearch cluster using Docker Compose:138139```bash140# For Elasticsearch141docker-compose -f docker-compose-elasticsearch.yml up -d142143# For OpenSearch144docker-compose -f docker-compose-opensearch.yml up -d145```146147The default Elasticsearch username is `elastic` and password is `test123`. The default OpenSearch username is `admin` and password is `admin`.148149You can access Kibana/OpenSearch Dashboards from http://localhost:5601.150151## Stdio152153### Option 1: Using uvx154155Using `uvx` will automatically install the package from PyPI, no need to clone the repository locally. Add the following configuration to 's config file `claude_desktop_config.json`.156157```json158// For Elasticsearch with username/password159{160 "mcpServers": {161 "elasticsearch-mcp-server": {162 "command": "uvx",163 "args": [164 "elasticsearch-mcp-server"165 ],166 "env": {167 "ELASTICSEARCH_HOSTS": "https://localhost:9200",168 "ELASTICSEARCH_USERNAME": "elastic",169 "ELASTICSEARCH_PASSWORD": "test123"170 }171 }172 }173}174175// For Elasticsearch with API key176{177 "mcpServers": {178 "elasticsearch-mcp-server": {179 "command": "uvx",180 "args": [181 "elasticsearch-mcp-server"182 ],183 "env": {184 "ELASTICSEARCH_HOSTS": "https://localhost:9200",185 "ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"186 }187 }188 }189}190191// For OpenSearch192{193 "mcpServers": {194 "opensearch-mcp-server": {195 "command": "uvx",196 "args": [197 "opensearch-mcp-server"198 ],199 "env": {200 "OPENSEARCH_HOSTS": "https://localhost:9200",201 "OPENSEARCH_USERNAME": "admin",202 "OPENSEARCH_PASSWORD": "admin"203 }204 }205 }206}207```208209### Option 2: Using uv with local development210211Using `uv` requires cloning the repository locally and specifying the path to the source code. Add the following configuration to Claude Desktop's config file `claude_desktop_config.json`.212213```json214// For Elasticsearch with username/password215{216 "mcpServers": {217 "elasticsearch-mcp-server": {218 "command": "uv",219 "args": [220 "--directory",221 "path/to/elasticsearch-mcp-server",222 "run",223 "elasticsearch-mcp-server"224 ],225 "env": {226 "ELASTICSEARCH_HOSTS": "https://localhost:9200",227 "ELASTICSEARCH_USERNAME": "elastic",228 "ELASTICSEARCH_PASSWORD": "test123"229 }230 }231 }232}233234// For Elasticsearch with API key235{236 "mcpServers": {237 "elasticsearch-mcp-server": {238 "command": "uv",239 "args": [240 "--directory",241 "path/to/elasticsearch-mcp-server",242 "run",243 "elasticsearch-mcp-server"244 ],245 "env": {246 "ELASTICSEARCH_HOSTS": "https://localhost:9200",247 "ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"248 }249 }250 }251}252253// For OpenSearch254{255 "mcpServers": {256 "opensearch-mcp-server": {257 "command": "uv",258 "args": [259 "--directory",260 "path/to/elasticsearch-mcp-server",261 "run",262 "opensearch-mcp-server"263 ],264 "env": {265 "OPENSEARCH_HOSTS": "https://localhost:9200",266 "OPENSEARCH_USERNAME": "admin",267 "OPENSEARCH_PASSWORD": "admin"268 }269 }270 }271}272```273274## SSE275276### Option 1: Using uvx277278```bash279# export environment variables (with username/password)280export ELASTICSEARCH_HOSTS="https://localhost:9200"281export ELASTICSEARCH_USERNAME="elastic"282export ELASTICSEARCH_PASSWORD="test123"283284# OR export environment variables (with API key)285export ELASTICSEARCH_HOSTS="https://localhost:9200"286export ELASTICSEARCH_API_KEY="<YOUR_ELASTICSEARCH_API_KEY>"287288# By default, the SSE MCP server will serve on http://127.0.0.1:8000/sse289uvx elasticsearch-mcp-server --transport sse290291# The host, port, and path can be specified using the --host, --port, and --path options292uvx elasticsearch-mcp-server --transport sse --host 0.0.0.0 --port 8000 --path /sse293```294295### Option 2: Using uv296297```bash298# By default, the SSE MCP server will serve on http://127.0.0.1:8000/sse299uv run src/server.py elasticsearch-mcp-server --transport sse300301# The host, port, and path can be specified using the --host, --port, and --path options302uv run src/server.py elasticsearch-mcp-server --transport sse --host 0.0.0.0 --port 8000 --path /sse303```304305## Streamable HTTP306307### Option 1: Using uvx308309```bash310# export environment variables (with username/password)311export ELASTICSEARCH_HOSTS="https://localhost:9200"312export ELASTICSEARCH_USERNAME="elastic"313export ELASTICSEARCH_PASSWORD="test123"314315# OR export environment variables (with API key)316export ELASTICSEARCH_HOSTS="https://localhost:9200"317export ELASTICSEARCH_API_KEY="<YOUR_ELASTICSEARCH_API_KEY>"318319# By default, the Streamable HTTP MCP server will serve on http://127.0.0.1:8000/mcp320uvx elasticsearch-mcp-server --transport streamable-http321322# The host, port, and path can be specified using the --host, --port, and --path options323uvx elasticsearch-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000 --path /mcp324```325326### Option 2: Using uv327328```bash329# By default, the Streamable HTTP MCP server will serve on http://127.0.0.1:8000/mcp330uv run src/server.py elasticsearch-mcp-server --transport streamable-http331332# The host, port, and path can be specified using the --host, --port, and --path options333uv run src/server.py elasticsearch-mcp-server --transport streamable-http --host 0.0.0.0 --port 8000 --path /mcp334```335336## Compatibility337338The MCP server is compatible with Elasticsearch 7.x, 8.x, and 9.x. By default, it uses the Elasticsearch 8.x client (without a suffix).339340| MCP Server | Elasticsearch |341| --- | --- |342| elasticsearch-mcp-server-es7 | Elasticsearch 7.x |343| elasticsearch-mcp-server | Elasticsearch 8.x |344| elasticsearch-mcp-server-es9 | Elasticsearch 9.x |345| opensearch-mcp-server | OpenSearch 1.x, 2.x, 3.x |346347 To use the Elasticsearch 7.x client, run the `elasticsearch-mcp-server-es7` variant. For Elasticsearch 9.x, use `elasticsearch-mcp-server-es9`. For example:348349```bash350uvx elasticsearch-mcp-server-es7351```352353If you want to run different Elasticsearch variants (e.g., 7.x or 9.x) locally, simply update the `elasticsearch` dependency version in `pyproject.toml`, then start the server with:354355```bash356uv run src/server.py elasticsearch-mcp-server357```358359## License360361This project is licensed under the Apache License Version 2.0 - see the [LICENSE](LICENSE) file for details.362
Full transparency — inspect the skill content before installing.