elasticsearch-mcp-server — Claude Code MCP server: features and setup
Connects an agent to Elasticsearch and OpenSearch tools for document search, index inspection, and cluster management. Useful when coding tasks depend on search data.
claude mcp add --env ELASTICSEARCH_HOSTS=<ELASTICSEARCH_HOSTS> --env ELASTICSEARCH_API_KEY=<ELASTICSEARCH_API_KEY> --env ELASTICSEARCH_USERNAME=<ELASTICSEARCH_USERNAME> --env ELASTICSEARCH_PASSWORD=<ELASTICSEARCH_PASSWORD> --env ELASTICSEARCH_VERIFY_CERTS=<ELASTICSEARCH_VERIFY_CERTS> --transport stdio elasticsearch-mcp-server -- uvx elasticsearch-mcp-serverWhat elasticsearch-mcp-server does
The server exposes tools to search, retrieve, add, and delete documents. An agent can inspect indices and aliases, create indices and data streams, check cluster health and statistics, and analyze how text is tokenized. A general HTTP API request tool covers Elasticsearch or OpenSearch endpoints without a dedicated tool.
Set connection details with environment variables: provide host addresses and either username and password or an Elasticsearch API key. Named multi-cluster configurations can be passed inline as JSON or loaded from a JSON file. Tool calls can target a cluster with the optional cluster parameter.
With an HTTP transport, leaving MCP_API_KEY unset makes the MCP server accessible without authentication. Configure the key before exposing it over a network. Claude Code starts the server with uvx; provide the credentials and host settings for the cluster you want to use.
What it helps with
- search Elasticsearch documents by query
- inspect an index’s mappings and settings
- add or remove a document by ID
- check cluster health and statistics
- inspect how an analyzer tokenizes text
Example prompts for the agent
- Search
logs-*for documents matching this error query. - Show the mappings and settings for the
productsindex. - Analyze this text with the specified analyzer and return its tokens.
How to install elasticsearch-mcp-server
Platform CLI
claude mcp add --env ELASTICSEARCH_HOSTS=<ELASTICSEARCH_HOSTS> --env ELASTICSEARCH_API_KEY=<ELASTICSEARCH_API_KEY> --env ELASTICSEARCH_USERNAME=<ELASTICSEARCH_USERNAME> --env ELASTICSEARCH_PASSWORD=<ELASTICSEARCH_PASSWORD> --env ELASTICSEARCH_VERIFY_CERTS=<ELASTICSEARCH_VERIFY_CERTS> --transport stdio elasticsearch-mcp-server -- uvx elasticsearch-mcp-serverReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from elasticsearch-mcp-server <command>
Platform CLI
codex mcp add elasticsearch-mcp-server --env ELASTICSEARCH_HOSTS=<ELASTICSEARCH_HOSTS> --env ELASTICSEARCH_API_KEY=<ELASTICSEARCH_API_KEY> --env ELASTICSEARCH_USERNAME=<ELASTICSEARCH_USERNAME> --env ELASTICSEARCH_PASSWORD=<ELASTICSEARCH_PASSWORD> --env ELASTICSEARCH_VERIFY_CERTS=<ELASTICSEARCH_VERIFY_CERTS> -- uvx elasticsearch-mcp-serverReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from elasticsearch-mcp-server <command>
Config file
{
"mcpServers": {
"elasticsearch-mcp-server": {
"command": "uvx",
"args": [
"elasticsearch-mcp-server"
],
"env": {
"ELASTICSEARCH_HOSTS": "<ELASTICSEARCH_HOSTS>",
"ELASTICSEARCH_API_KEY": "<ELASTICSEARCH_API_KEY>",
"ELASTICSEARCH_USERNAME": "<ELASTICSEARCH_USERNAME>",
"ELASTICSEARCH_PASSWORD": "<ELASTICSEARCH_PASSWORD>",
"ELASTICSEARCH_VERIFY_CERTS": "<ELASTICSEARCH_VERIFY_CERTS>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from elasticsearch-mcp-server <command>
Config file
{
"servers": {
"elasticsearch-mcp-server": {
"type": "stdio",
"command": "uvx",
"args": [
"elasticsearch-mcp-server"
],
"env": {
"ELASTICSEARCH_HOSTS": "<ELASTICSEARCH_HOSTS>",
"ELASTICSEARCH_API_KEY": "<ELASTICSEARCH_API_KEY>",
"ELASTICSEARCH_USERNAME": "<ELASTICSEARCH_USERNAME>",
"ELASTICSEARCH_PASSWORD": "<ELASTICSEARCH_PASSWORD>",
"ELASTICSEARCH_VERIFY_CERTS": "<ELASTICSEARCH_VERIFY_CERTS>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from elasticsearch-mcp-server <command>
Platform CLI
gemini mcp add -e ELASTICSEARCH_HOSTS=<ELASTICSEARCH_HOSTS> -e ELASTICSEARCH_API_KEY=<ELASTICSEARCH_API_KEY> -e ELASTICSEARCH_USERNAME=<ELASTICSEARCH_USERNAME> -e ELASTICSEARCH_PASSWORD=<ELASTICSEARCH_PASSWORD> -e ELASTICSEARCH_VERIFY_CERTS=<ELASTICSEARCH_VERIFY_CERTS> elasticsearch-mcp-server uvx elasticsearch-mcp-serverReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from elasticsearch-mcp-server <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about elasticsearch-mcp-server
How do I install elasticsearch-mcp-server in Claude Code?
Run `claude mcp add elasticsearch-mcp-server -e ELASTICSEARCH_API_KEY=<ELASTICSEARCH_API_KEY> -e ELASTICSEARCH_PASSWORD=<ELASTICSEARCH_PASSWORD> -- uvx elasticsearch-mcp-server`. Set the Elasticsearch credentials before starting it.
What does elasticsearch-mcp-server do?
It gives an agent tools for Elasticsearch and OpenSearch. Those tools search and manage documents, inspect indices and aliases, and retrieve cluster information.
Can it connect to multiple clusters?
Yes. Configure named clusters with ELASTICSEARCH_CLUSTERS or OPENSEARCH_CLUSTERS, or point ELASTICSEARCH_CLUSTERS_FILE or OPENSEARCH_CLUSTERS_FILE to a JSON file. Pass cluster in a tool call to target one.