es_mcp_server
Elasticsearch MCP Server in Python
claude mcp add --transport stdio sajitsasi-es_mcp_server python es_mcp_server.py \ --env ES_API_KEY="your_elasticsearch_api_key" \ --env ES_CLOUD_ID="your_elasticsearch_cloud_id"
How to use
This MCP server exposes a set of Elasticsearch resources and tools that let you explore and interact with your Elasticsearch clusters through the Model Context Protocol. The server implements tools for listing indices, retrieving index mappings, and performing searches against your cluster. Specifically, you can use the tools: list_indices to enumerate all indices in the cluster, get_mappings to fetch the mappings for a given index, search to run a full Elasticsearch DSL query, search_with_query_string to perform a simple query string search, and get_index_stats to obtain basic statistics for a chosen index. The resources expose endpoints such as elasticsearch://indices, elasticsearch://index/{index_name}, and elasticsearch://mapping/{index_name} to retrieve structured information about your cluster.
To use these capabilities within Claude or any MCP-enabled client, configure the MCP server in your environment (via the provided configuration script or manual environment variables), then access the resources through the access_mcp_resource tooling. For example, use elasticsearch://indices to see all indices, elasticsearch://index/{index_name} for detailed index information, and elasticsearch://mapping/{index_name} to inspect field definitions and mappings. The server handles authentication and connection to your Elasticsearch cluster using the ES_CLOUD_ID and ES_API_KEY credentials you provide, and returns structured JSON with the requested data or informative error messages when something goes wrong.
How to install
Prerequisites:
- Python 3.7+
- pip (Python package manager)
- Access to an Elasticsearch cluster (Cloud ID and API Key required)
- MCP SDK (as part of the project dependencies)
Step-by-step installation:
-
Clone the repository: git clone https://github.com/yourusername/elasticsearch-mcp-server.git cd elasticsearch-mcp-server
-
Create and activate a virtual environment (recommended): python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install dependencies: pip install -r requirements.txt
-
Configure environment variables (example): cp .env.example .env
Edit .env and add your credentials, or export directly:
export ES_CLOUD_ID=your_elasticsearch_cloud_id export ES_API_KEY=your_elasticsearch_api_key
-
Run the MCP server locally: python es_mcp_server.py
-
Optional: Test the server using provided test scripts (if available in the repo).
-
If you use Claude integration, ensure the configure_mcp_server.py script or equivalent setup updates your MCP settings with the Elasticsearch MCP server configuration.
Additional notes
Tips and common issues:
- Ensure your ES_CLOUD_ID and ES_API_KEY are valid and have the proper permissions to access the cluster.
- If you encounter connection or authentication errors, double-check network access, firewall rules, and that the API key has the required roles.
- The server relies on the Elasticsearch Python client; keeping dependencies up to date can prevent compatibility issues.
- When testing, provide realistic index names and query DSL payloads to exercise the tools effectively.
- If you modify environment variables, restart the MCP server to apply changes.
- This server exposes endpoints to query indices and mappings; large clusters may return large mapping definitions, so consider filtering results when testing.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP