elasticsearch-mcp
Works against Elastic Cloud-hosted clusters as well as self-managed ones, connecting via cluster URL with API key, basic auth, or a custom CA bundle for self-signed TLS.
Provides six read-only tools for exploring and querying an Elasticsearch cluster (7.x, 8.x, 9.x): listing indices and shards with patterns, fetching index mappings, running Query DSL searches with aggregations, executing ES|QL queries, and checking cluster health. Errors are returned with Elasticsearch's own reason so the agent can correct its query.
Click on "Deploy 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-mcp What indices do I have, and which is the largest?"
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
Read-only Elasticsearch for any AI agent: plug it in as an MCP server, or as an Agent Skill where MCP isn't allowed.
Works with
Ask your agent "Which hosts logged the most errors today?" and it finds the index, reads the mappings and runs the query itself. One small Python package gives every agent the same six read-only tools, two ways:
flowchart LR
agent["Your agent<br/>Claude Code · Codex · Cursor<br/>OpenCode · Gemini CLI · VS Code"]
agent -- "MCP over stdio" --> mcp["elasticsearch-mcp<br/>MCP server"]
agent -- "Agent Skill: shell commands" --> cli["elasticsearch-mcp COMMAND<br/>CLI"]
mcp --> tools["6 read-only tools"]
cli --> tools
tools -- "REST API" --> es[("Elasticsearch<br/>7 · 8 · 9 · Elastic Cloud")]Quick start
You need uv, your cluster's URL and an API key (here's a read-only key).
Add the server to your agent. For Claude Code:
claude mcp add --scope user elasticsearch -e ES_URL=https://your-cluster:9200 -e ES_API_KEY=your-key -- uvx --from git+https://github.com/aniketshukla1/elasticsearch-mcp elasticsearch-mcpOther agents: MCP setup. MCP not allowed: Agent Skill.
Restart the agent.
Ask: "What indices do I have, and which is the largest?"
No cluster yet? Develop locally starts one in Docker with sample data.
Related MCP server: Kibana MCP Server
Use it as an MCP server
Every client launches the same command and passes the settings as environment variables:
uvx --from git+https://github.com/aniketshukla1/elasticsearch-mcp elasticsearch-mcpclaude mcp add --scope user elasticsearch -e ES_URL=https://your-cluster:9200 -e ES_API_KEY=your-key -- uvx --from git+https://github.com/aniketshukla1/elasticsearch-mcp elasticsearch-mcpKeep the name elasticsearch before the -e flags, or -e swallows it.
codex mcp add elasticsearch --env ES_URL=https://your-cluster:9200 --env ES_API_KEY=your-key -- uvx --from git+https://github.com/aniketshukla1/elasticsearch-mcp elasticsearch-mcpAdd this to ~/.cursor/mcp.json, ~/.gemini/settings.json or claude_desktop_config.json:
{
"mcpServers": {
"elasticsearch": {
"command": "uvx",
"args": ["--from", "git+https://github.com/aniketshukla1/elasticsearch-mcp", "elasticsearch-mcp"],
"env": { "ES_URL": "https://your-cluster:9200", "ES_API_KEY": "your-key" }
}
}
}Desktop apps may not see your shell's PATH. If the server doesn't start, use the full path from which uvx as command. Cursor asks you to approve the server the first time.
Add this to ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"elasticsearch": {
"type": "local",
"command": ["uvx", "--from", "git+https://github.com/aniketshukla1/elasticsearch-mcp", "elasticsearch-mcp"],
"environment": { "ES_URL": "https://your-cluster:9200", "ES_API_KEY": "your-key" }
}
}
}code --add-mcp '{"name":"elasticsearch","command":"uvx","args":["--from","git+https://github.com/aniketshukla1/elasticsearch-mcp","elasticsearch-mcp"],"env":{"ES_URL":"https://your-cluster:9200","ES_API_KEY":"your-key"}}'If code opens Cursor (Cursor can install its own code command), run VS Code's CLI by its full path: "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code".
The server also ships an MCP prompt, elasticsearch(question). Clients that support MCP prompts, such as Claude Code and VS Code, list it as a slash command.
Use it as an Agent Skill
Some setups don't allow MCP servers. The skill in skills/elasticsearch teaches the agent to run the same six tools as shell commands, or as plain curl calls when uv isn't installed. It follows the open Agent Skills format, so one folder works in every agent that supports skills.
Install it for your user, in the agents you pick, with the skills installer (drop -g to install into the current project only):
npx skills add aniketshukla1/elasticsearch-mcp -gOr copy the folder into one agent's skills directory:
Agent | Skills directory |
Claude Code |
|
Codex |
|
Cursor |
|
OpenCode |
|
Gemini CLI |
|
GitHub Copilot |
|
git clone https://github.com/aniketshukla1/elasticsearch-mcp
cp -r elasticsearch-mcp/skills/elasticsearch ~/.claude/skills/The skill reads the same environment variables as the server. Ask about your data and the agent loads it; in Claude Code you can also type /elasticsearch. The commands work by hand too:
uvx --from git+https://github.com/aniketshukla1/elasticsearch-mcp elasticsearch-mcp list-indices 'logs-*'
uvx --from git+https://github.com/aniketshukla1/elasticsearch-mcp elasticsearch-mcp esql 'FROM logs-* | STATS n = COUNT(*) BY host.name | LIMIT 5'Tools
MCP tool | CLI command | Elasticsearch API |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Results are Elasticsearch's own compact JSON. Errors come back with Elasticsearch's reason, so the agent can fix its query.
Settings
Variable | Meaning |
| Cluster URL. Default |
| Preferred. The |
| Basic auth, used when |
| CA bundle path for self-signed TLS, such as |
Read-only by design
No tool or command writes, deletes or changes settings: there is nothing to call. To make sure nothing else can either (a curl from the skill's fallback, say), give the agent a key that can't write. This role covers all six tools; narrow names to the indices the agent should see:
POST /_security/api_key
{
"name": "mcp-read-only",
"role_descriptors": {
"mcp_read_only": {
"cluster": ["monitor"],
"indices": [{ "names": ["*"], "privileges": ["read", "view_index_metadata", "monitor"] }]
}
}
}Use the encoded value from the response as ES_API_KEY.
Develop locally
cp .env.example .env # then set ES_PASSWORD
docker compose up -d --wait # Elasticsearch 9.5.5 on 127.0.0.1:9200
uv run --env-file .env tests/test_e2e.py # end-to-end test of the MCP server and the CLIThe test seeds the mcp-demo-products index, then checks every tool and the prompt over MCP and every CLI command, once with a read-only API key and once with the password. To point an agent at your checkout instead of GitHub, use this command:
uv run --directory /path/to/elasticsearch-mcp --env-file .env elasticsearch-mcpelasticsearch-mcp/
├── src/elasticsearch_mcp/
│ ├── server.py MCP server: six read-only tools and the elasticsearch prompt
│ └── cli.py the elasticsearch-mcp command: serves MCP, or runs one tool from the shell
├── skills/elasticsearch/
│ └── SKILL.md Agent Skill for agents without MCP
├── tests/test_e2e.py end-to-end test against a real cluster
├── assets/logo.svg
├── docker-compose.yml local Elasticsearch
└── .env.example settings templateLicense
Available Tools
6 toolscluster_healthBRead-only
Cluster health: status (green, yellow or red), node count and shard counts.
Inputs: no named parameters.
esqlARead-only
Run an ES|QL query (Elasticsearch 8.11+), for example 'FROM logs-* | STATS errors = COUNT(*) BY host.name | SORT errors DESC | LIMIT 10'. Returns columns and rows.
Inputs: query (required).
get_mappingsARead-only
Get the field names and types of an index or pattern. Read them before writing a search or ES|QL query.
Inputs: index (required).
get_shardsARead-only
Show shards for indices matching a pattern: primary or replica, state, docs, size and node.
Inputs: index.
list_indicesARead-only
List indices matching a pattern such as "logs-*" or "a,b", with health, status, doc count and size.
Inputs: pattern.
searchARead-only
Run a Query DSL search. body is the full _search request body, for example
{"query": {"match": {"title": "shoes"}}, "size": 5}. Aggregations, sort and _source filtering work as
usual; omit body to get the first 10 documents.
Inputs: index (required), body.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a recognizable target: index metadata (list_indices, get_mappings), querying (search, esql), shard inspection (get_shards), and cluster status (cluster_health). The only mild overlap is search vs. esql, but the descriptions clearly differentiate Query DSL from ES|QL syntax, so an agent can pick correctly.
The set follows a verb_noun convention (list_indices, get_mappings, get_shards, cluster_health is the only noun-only name). Minor deviation, but overall readable and predictable.
Six tools is well-scoped for a read-only Elasticsearch inspection server; each tool covers a distinct aspect (indices, mappings, search, ES|QL, shards, cluster health) without redundancy.
Covers the core read/query lifecycle: discover indices, inspect schema, run DSL and ES|QL queries, and check shard/cluster status. Gaps exist (no fetch-document-by-id, no write/index/delete operations), but these are minor for a read-oriented toolset and workable via search.
Maintenance
Related MCP Connectors
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Read-only Google Search Console and Google Analytics for AI agents.
Read-only search of 2,189 AI agent tools (MCP servers, x402 APIs) with daily automated trust scores.
Query your AI agent traces, root-cause verdicts and issues, and run investigations, from your agent.
Related MCP Servers
- AlicenseCqualityDmaintenanceEnables AI agents to interact with INFINI Easysearch (compatible with Elasticsearch/OpenSearch APIs) through 121 tools covering cluster management, index operations, document manipulation, search queries, snapshots, and monitoring.1004MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to interact with Kibana dashboards, visualizations, and Elasticsearch data through read-only resources and executable tools for searching logs, exporting dashboards, and querying data.74MIT
- FlicenseBqualityNot gradedmaintenanceProvides comprehensive tools for managing Elasticsearch clusters, including security management, search operations, and index administration. It enables users to monitor cluster health, handle InfoSec tasks, and execute complex queries using Elasticsearch Query DSL and ES|QL.37-
- AlicenseNot gradedqualityDmaintenanceProvides tools to query Elasticsearch indices, retrieve mappings, execute searches, and get cluster health stats.4MIT