elasticsearch-mcp
Provides tools for interacting with Elasticsearch clusters, including query execution, DSL generation and explanation, index and cluster health, mapping analysis, snapshot management, and reindexing operations.
Supports OpenSearch clusters via the same REST API tools, enabling querying, diagnostics, mapping, and cluster operations in OpenSearch environments.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@elasticsearch-mcpCheck cluster health and list any unassigned shards"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
elasticsearch-mcp
MCP server for Elasticsearch, built directly on the REST API (no elasticsearch-py dependency, so it also works against OpenSearch and managed clusters that only expose HTTP).
21 tools covering query, diagnostics, mapping, and cluster operations. Read-only by default; every write path is gated.
Install
git clone <your-repo> elasticsearch-mcp && cd elasticsearch-mcp
uv sync # or: pip install -e ".[dev]"
cp .env.example .env
pytest -qRelated MCP server: OpenSearch MCP Server
Register with Claude Code / Claude Desktop
{
"mcpServers": {
"elasticsearch": {
"command": "uv",
"args": ["--directory", "/abs/path/elasticsearch-mcp", "run", "elasticsearch-mcp"],
"env": {
"ES_MCP_HOSTS": "https://es.internal:9200",
"ES_MCP_API_KEY": "base64-encoded-api-key",
"ES_MCP_INDEX_ALLOW": "logs-*,metrics-*",
"ES_MCP_READ_ONLY": "true"
}
}
}
}Remote / shared deployment instead of stdio:
elasticsearch-mcp --transport streamable-httpTools
Query
Tool | What it does |
| Execute Query DSL. Size capped, timeout injected, deep paging rejected, |
| Structured spec to valid DSL, validated against the index, returns a field catalog |
|
|
| Match count without fetching hits |
Diagnostics
Tool | What it does |
| Status, shard counts, pending tasks, optional per-node heap/disk/CPU/rejections |
| Per index: docs, store, segments, avg query and index latency, merges |
|
|
| Indices ranked by avg query latency, running search tasks, thread-pool rejections, slowlog thresholds |
Mapping
Tool | What it does |
| Indices and aliases with doc counts and size |
| Flattened |
| Token output of an analyzer, for debugging zero-hit match queries |
| Additive mapping changes (write-gated) |
Operations
Tool | What it does |
| Snapshot inventory and progress |
| Snapshot selected indices, async by default |
| Restore, with pre-flight check for existing open indices and rename support |
| Async reindex with query, pipeline, script, slicing, throttling; returns a task id |
| Poll or kill long-running tasks |
| Version, distribution, and the active safety policy |
Configuration
All variables use the ES_MCP_ prefix, read from the environment or .env.
Variable | Default | Purpose |
|
| Comma separated; failover across them |
| – | Pick one auth mode |
|
| TLS |
|
| Retries cover 429/502/503/504 and connect errors, with jittered backoff and |
|
| Master switch for all write tools |
|
| Second gate for restore, reindex, put_mapping |
|
| Glob allow-list |
|
| Glob deny-list; deny wins |
|
| Hit caps |
|
| Rejects bucket explosions |
|
| Per-query guards |
|
| Token control |
| unset | JSONL record of every tool call and outcome |
|
| Logs go to stderr, never stdout (stdio transport) |
Safety model
Four independent layers, all failing closed:
Index policy — allow-list and deny-list checked on every call; deny wins; wildcard writes across the whole cluster refused.
Read-only — mutating tools refuse unless
READ_ONLY=false.Destructive gate — restore, reindex, and put_mapping additionally need
ALLOW_DESTRUCTIVE=trueand an explicitconfirm=trueargument in the call itself.Query limits — size clamp, agg bucket cap, agg nesting depth cap, deep-paging rejection, injected search timeout.
Tools return errors as readable text (ERROR (run_query): ...) rather than raising, so the model can correct itself instead of stalling.
Recommended production posture: a dedicated ES API key with read on exactly the allowed indices, READ_ONLY=true, and a separate write-enabled instance only if you actually need reindex/restore from the assistant.
Extending
Add a module under src/es_mcp/tools/, expose register(server, ctx), wire it in server.build_server. Use ctx.guard for policy checks and ctx.render for output so limits apply automatically.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityCmaintenanceAn MCP server that enables interaction with Elasticsearch and OpenSearch clusters for searching documents and managing indices. It provides tools for cluster health monitoring, index configuration, and general API requests.16Apache 2.0
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to interact with OpenSearch clusters to monitor cluster health, manage indices, and perform data searches. It provides a standardized interface for real-time OpenSearch operations within MCP-compatible environments like Open WebUI.
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to interact with OpenSearch clusters for searching indices, retrieving mappings, and managing shards through the MCP protocol.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceRead-only MCP server for exploring and searching OpenSearch clusters, enabling log analysis, index exploration, and query execution.MIT
Related MCP Connectors
Search, document and execute authenticated API calls across 700+ apps via one MCP server
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Read-only Remote MCP for externally grounded AI agent trust receipts.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/baburajr/elasticsearch_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server