Home / MCP / Elasticsearch MCP Server
Provides Elasticsearch/OpenSearch MCP endpoints for indexing, searching, and managing clusters.
Configuration
View docs{
"mcpServers": {
"elasticsearch": {
"command": "uvx",
"args": [
"elasticsearch-mcp-server"
],
"env": {
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
"ELASTICSEARCH_USERNAME": "elastic",
"ELASTICSEARCH_PASSWORD": "test123",
"ELASTICSEARCH_API_KEY": "YOUR_API_KEY",
"OPENSEARCH_HOSTS": "https://localhost:9200",
"OPENSEARCH_USERNAME": "admin",
"OPENSEARCH_PASSWORD": "admin"
}
}
}
}You can run an MCP server that exposes Elasticsearch/OpenSearch functionality to clients. It lets you search documents, manage indices and data streams, and inspect cluster health through a defined set of tools. This guide shows practical steps to run the server, connect with an MCP client, and secure your setup.
Connect to the MCP server from your client to perform common Elasticsearch/OpenSearch operations. You can search documents, index or update documents, manage indices and data streams, and inspect cluster health and statistics. Use dedicated tools for each operation, or fall back to a general API request tool for any API call that isn’t covered by a specific tool.
Prerequisites: you need either Node.js/UVX tooling or Python-based runtime tooling as described below. Choose one of the two deployment methods that matches your workflow.
# Prereqs: ensure you have a runtime capable of running MCP servers
# Option A: Run MCP server config with uvx (Node environment)
# You will configure environment vars for Elasticsearch/OpenSearch endpoints.
# Option B: Run MCP server config with uv (local development)Use uvx to run the MCP server configuration directly. This approach installs and runs the MCP server package from the registry and uses your environment variables to connect to Elasticsearch or OpenSearch.
# Example: Elasticsearch with username/password using uvx
{
"mcpServers": {
"elasticsearch-mcp-server": {
"command": "uvx",
"args": [
"elasticsearch-mcp-server"
],
"env": {
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
"ELASTICSEARCH_USERNAME": "elastic",
"ELASTICSEARCH_PASSWORD": "test123"
}
}
}
}{
"mcpServers": {
"elasticsearch-mcp-server": {
"command": "uvx",
"args": [
"elasticsearch-mcp-server"
],
"env": {
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
"ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"
}
}
}
}{
"mcpServers": {
"opensearch-mcp-server": {
"command": "uvx",
"args": [
"opensearch-mcp-server"
],
"env": {
"OPENSEARCH_HOSTS": "https://localhost:9200",
"OPENSEARCH_USERNAME": "admin",
"OPENSEARCH_PASSWORD": "admin"
}
}
}
}If you are using API keys for OpenSearch, the same pattern applies by providing OPENSEARCH_HOSTS and OPENSEARCH_API_KEY in the environment.
If you prefer development on your machine, clone the MCP server sources and run uv with the directory path to the server. This requires you to point to your local server source when starting.
# Example: Elasticsearch with username/password using uv
{
"mcpServers": {
"elasticsearch-mcp-server": {
"command": "uv",
"args": [
"--directory",
"path/to/elasticsearch-mcp-server",
"run",
"elasticsearch-mcp-server"
],
"env": {
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
"ELASTICSEARCH_USERNAME": "elastic",
"ELASTICSEARCH_PASSWORD": "test123"
}
}
}
}{
"mcpServers": {
"elasticsearch-mcp-server": {
"command": "uv",
"args": [
"--directory",
"path/to/elasticsearch-mcp-server",
"run",
"elasticsearch-mcp-server"
],
"env": {
"ELASTICSEARCH_HOSTS": "https://localhost:9200",
"ELASTICSEARCH_API_KEY": "<YOUR_ELASTICSEARCH_API_KEY>"
}
}
}
}{
"mcpServers": {
"opensearch-mcp-server": {
"command": "uv",
"args": [
"--directory",
"path/to/elasticsearch-mcp-server",
"run",
"opensearch-mcp-server"
],
"env": {
"OPENSEARCH_HOSTS": "https://localhost:9200",
"OPENSEARCH_USERNAME": "admin",
"OPENSEARCH_PASSWORD": "admin"
}
}
}
}If you are using API keys for OpenSearch, provide OPENSEARCH_HOSTS and OPENSEARCH_API_KEY in the environment.
Perform a general HTTP API request for Elasticsearch/OpenSearch API calls that do not have a dedicated tool.
List all indices in the cluster.
Return mappings, settings, and aliases for one or more indices.
Create a new index.
Delete an index.
Create a new data stream (requires matching index template).
Get information about one or more data streams.
Delete one or more data streams and their backing indices.
Search for documents in an index.
Create or update a document in an index.
Retrieve a document by its ID.
Delete a document by its ID.
Delete documents that match a given query.
Return basic health information about the cluster.
Provide a high-level overview of cluster statistics.
List all index aliases.
Get information about an alias for a specific index.
Create or update an alias for a specific index.
Delete an alias for a specific index.