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.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only Google Search Console and Google Analytics for AI agents.
Google Search Console, GA4 and Bing Webmaster data for SEO and AI-search work. 20 read-only tools.
Read-only search of 2,189 AI agent tools (MCP servers, x402 APIs) with daily automated trust scores.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
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.737 npm3MIT
- 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