elasticsearch7-mcp
Allows interaction with an Elasticsearch 7.x cluster, including searching and retrieving documents, managing indices, mappings, aliases, and templates, reindexing data, checking cluster health and tasks, and optionally performing read-only diagnostics or destructive admin operations.
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., "@elasticsearch7-mcpcheck cluster health and show the last 5 docs in logs-*"
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 7.x MCP Server
MCP Server for connecting to your Elasticsearch cluster directly from any MCP Client (like Claude Desktop, Cursor).
This fork targets Elasticsearch 7.x only. It pins the @elastic/elasticsearch 7.17 client,
whose product check accepts servers older than 7.14. For an Elasticsearch 8.x cluster, use the
upstream project @awesome-ai/elasticsearch-mcp,
which this fork is derived from — the 8.x client cannot talk to a 7.x server, and vice versa.
This server connects agents to your Elasticsearch data using the Model Context Protocol. It allows you to interact with your Elasticsearch indices through natural language conversations.
Feature Overview
Tools come in three sets. Only the first is always exposed; the other two are
opt-in through an environment variable, so a production deployment can offer
diagnostics without offering deletes. Gating happens at registration: a disabled
tool never appears in tools/list, so the model cannot call it and it costs
nothing in the agent's context.
Always available — read and write data
Cluster
elasticsearch_health: cluster health, optionally down to index levelcluster_info: cluster name, Elasticsearch version and build flavour
Index operations
list_indices: list indices, filtered by an Elasticsearch wildcard (log-*)create_index: create an index with optional settings and mappingsreindex: copy an index, optionally filtered by a query or transformed by a scriptget_aliases: which aliases point at which indices
Mappings
get_mappings: the fields of an index, as dotted paths with their types, then the raw mappingcreate_mapping: create or update the mapping of an index
Search and data
search: run a query DSL search, with highlighting injected over every text field — nested ones included — unless the query brings its ownhighlightcount: how many documents match, without transferring anyget_document: fetch one document by idbulk: index many documents at once
Templates
create_index_template: create or update a composable index templateget_index_template: read index templates
Tasks
get_task: progress of a long-running task, such as the onereindexreturns
ES_ADMIN_TOOLS=true — diagnostics (read-only)
These only read, so they are safe to enable in production — and are the point of this set: an agent can then explain why an index is unhealthy without anyone logging into the cluster.
explain_allocation: why a shard is unassigned, with each allocator's decisionlist_shards: shard-level state, leading with the copies that are notSTARTEDlist_nodes: heap, CPU, load and disk pressure per nodeget_index_stats: per-index counters — size, segments, indexing, search, mergesget_index_settings: an index's settings (refresh_interval, replicas, read-only blocks)get_cluster_settings: cluster settings that were overridden at runtimelist_tasks: what the cluster is currently running
ES_ALLOW_DESTRUCTIVE=true — irreversible
Intended for a staging environment, and off by default so production cannot reach them at all.
delete_index: delete an index and its datadelete_document: delete one document by iddelete_by_query: delete every document matching a query — asynchronous, it returns a task id and the deletion continues in the backgrounddelete_index_template: delete an index template
Even with the flag on, these refuse a wildcard, a comma-separated list, * and
_all: they act on one named index at a time. A model that mistakes logs-*
for a single index gets a refusal instead of an emptied cluster.
How It Works
The MCP Client analyzes your request and determines which Elasticsearch operations are needed.
The MCP server carries out these operations (listing indices, fetching mappings, performing searches).
The MCP Client processes the results and presents them in a user-friendly format.
Related MCP server: Elasticsearch 7.x MCP Server
Getting Started
Prerequisites
An Elasticsearch 7.x instance (tested against 7.8; the 7.17 client supports 6.8 through 7.x)
Elasticsearch credentials — an API key, or a username and password
An MCP client: Claude Code, Claude Desktop, Codex, Cursor, or anything else that speaks MCP over stdio
Authenticate to GitHub Packages, once
This package is published toGitHub Packages, not npmjs.com, and GitHub
Packages requires a token even for public packages. Until you add one, every
install below fails with a 401. Put it in your user-level ~/.npmrc:
@agrica:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKENYOUR_GITHUB_TOKEN is a personal access token with the read:packages scope.
Keep it in your own ~/.npmrc rather than a project file — a token committed
to a repository is a leaked token, and some package managers refuse to read one
from there at all.
Connect it to your client
Every example below sets ES_HOST and ES_API_KEY. Swap in
ES_USERNAME/ES_PASSWORD for basic auth, add ES_ADMIN_TOOLS=true to get
the diagnostic tools, and set ES_INSTANCE_LABEL when more than one instance is
declared — see Configuration Options.
claude mcp add elasticsearch7 \
--env ES_HOST=https://your-cluster:9200 \
--env ES_API_KEY=your-api-key \
--env ES_ADMIN_TOOLS=true \
-- npx -y @agrica/elasticsearch7-mcpThen /mcp in a session lists the server and its tools.
Two details that are easy to get wrong:
Everything after
--is the command that runs the server; without it, Claude Code would try to parse-yas one of its own flags.Do not put the server name straight after
--env— the CLI reads it as anotherKEY=valuepair and rejects it. Above, the name comes first, which is why it works.
The server is added at local scope, so it loads in the current project only. Add
--scope user to get it everywhere, or --scope project to write it into
.mcp.json and share it with your team — mind that a committed .mcp.json
would carry your API key, so prefer user scope for credentials.
Edit claude_desktop_config.json — Settings > Developer > Edit Config opens
it, or find it at %APPDATA%\Claude\ on Windows and
~/Library/Application Support/Claude/ on macOS:
{
"mcpServers": {
"elasticsearch7": {
"command": "npx",
"args": ["-y", "@agrica/elasticsearch7-mcp"],
"env": {
"ES_HOST": "https://your-cluster:9200",
"ES_API_KEY": "your-api-key",
"ES_ADMIN_TOOLS": "true"
}
}
}
}Restart Claude Desktop afterwards; it only reads that file at startup.
codex mcp add elasticsearch7 \
--env ES_HOST=https://your-cluster:9200 \
--env ES_API_KEY=your-api-key \
-- npx -y @agrica/elasticsearch7-mcpOr write it into ~/.codex/config.toml by hand. Note that Codex spells the
table mcp_servers with an underscore, and that the environment goes in its own
sub-table rather than inline:
[mcp_servers.elasticsearch7]
command = "npx"
args = ["-y", "@agrica/elasticsearch7-mcp"]
[mcp_servers.elasticsearch7.env]
ES_HOST = "https://your-cluster:9200"
ES_API_KEY = "your-api-key"
ES_ADMIN_TOOLS = "true"/mcp inside Codex confirms the server is loaded.
The server is a plain stdio MCP server, so anything on the
MCP client list works. It needs three
things: the command npx, the arguments -y @agrica/elasticsearch7-mcp, and the
ES_* variables in its environment. It never listens on a port, and writes
nothing but MCP protocol to stdout — diagnostics go to stderr.
Configuration Options
The Elasticsearch MCP Server supports configuration options to connect to your Elasticsearch:
You must provide either an API key or both username and password for authentication.
Environment Variable | Description | Required |
| Your Elasticsearch instance URL(s) - supports single URL or comma-separated multiple URLs (also supports legacy | Yes |
| Elasticsearch API key for authentication (also supports legacy | No |
| Elasticsearch username for basic authentication (also supports legacy | No |
| Elasticsearch password for basic authentication (also supports legacy | No |
| Path to custom CA certificate for Elasticsearch SSL/TLS (also supports legacy | No |
| Per-request timeout in milliseconds. Default | No |
| Retries per request. Default | No |
| Ceiling on one tool result. Default | No |
| Free-text name of this deployment, e.g. | No |
|
| No |
|
| No |
ES_ADMIN_TOOLS and ES_ALLOW_DESTRUCTIVE have no un-prefixed legacy alias,
unlike the connection variables above. That is deliberate: a bare ADMIN_TOOLS
or ALLOW_DESTRUCTIVE in an environment is far too easy to set by accident for
something that decides whether deletes are reachable.
Both accept true or 1; anything else, including an unset variable, means off.
Result size
A tool result is capped at 32 KB (ES_MAX_RESULT_BYTES). This matters on a
logging cluster: before the cap, one list_shards call over a year of daily
indices returned 385 KB — around 96 000 tokens — in a single answer, which is
more than most sessions can hold.
When a result is trimmed it says so, says how much went, and says how to ask a smaller question. Three tools shape their answers around it:
list_indicesandlist_shardsreturn a readable summary; the same rows as text are behindverbose.searchcapssizeat 100 per call and tells you thefromto page with.get_mappingslists the fields first and the raw mapping second, so a thousand-field index still answers the question it was asked.
Four tools — list_indices, list_shards, get_index_settings and
get_mappings — also return their answer as typed structured output, so a
client can read the rows instead of parsing the text. It is assembled from
whatever room the readable answer left, and reports returned against total
so a partial listing is visible as a number.
Run pnpm run measure against the built output to see the current figures for
your own configuration.
Labelling several instances
Most setups declare this server more than once — one entry per cluster. The
entries are otherwise identical, so a client shows two servers with the same
name and nothing to tell them apart. ES_INSTANCE_LABEL becomes the server's
display title, and it is the natural place to say which environment an entry
reaches:
{
"mcpServers": {
"es7-prod": {
"command": "npx",
"args": ["-y", "@agrica/elasticsearch7-mcp"],
"env": {
"ES_HOST": "https://es-prod:9200",
"ES_API_KEY": "prod-key",
"ES_INSTANCE_LABEL": "production",
"ES_ADMIN_TOOLS": "true"
}
},
"es7-staging": {
"command": "npx",
"args": ["-y", "@agrica/elasticsearch7-mcp"],
"env": {
"ES_HOST": "https://es-staging:9200",
"ES_API_KEY": "staging-key",
"ES_INSTANCE_LABEL": "staging",
"ES_ADMIN_TOOLS": "true",
"ES_ALLOW_DESTRUCTIVE": "true"
}
}
}
}That pair is the intended shape: diagnostics on both, deletes only on staging. Production keeps the tools that explain an unhealthy index and never exposes one that can remove data — the model cannot call what was never registered.
The label is also printed to stderr at startup, which is where to look when a client reports a connection but you cannot tell which cluster answered.
Multiple URLs Configuration
You can configure multiple Elasticsearch nodes for high availability and load balancing:
{
"mcpServers": {
"elasticsearch7-mcp": {
"command": "npx",
"args": [
"-y",
"@agrica/elasticsearch7-mcp"
],
"env": {
"ES_HOST": "https://es-node1:9200,https://es-node2:9200,https://es-node3:9200",
"ES_API_KEY": "your-api-key"
}
}
}
}The client will automatically handle failover and load balancing between the configured nodes.
Running with Docker
Each release publishes a multi-arch image (linux/amd64, linux/arm64) to the
GitHub Container Registry:
docker pull ghcr.io/agrica/elasticsearch7-mcp:latestThe server speaks stdio, so the container needs an interactive stdin and no published port. In an MCP client:
{
"mcpServers": {
"elasticsearch7-mcp": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-e", "ES_HOST",
"-e", "ES_API_KEY",
"ghcr.io/agrica/elasticsearch7-mcp:latest"
],
"env": {
"ES_HOST": "your-elasticsearch-host",
"ES_API_KEY": "your-api-key"
}
}
}
}Like the npm package, the image lives in GitHub Packages: pulling it requires a
token with theread:packages scope, even though the repository is public.
The image needs no port published and no volume: it speaks stdio, and the MCP client owns its stdin and stdout.
Example Queries
Here are some natural language queries you can try with your MCP Client.
Cluster Management
"What is the health status of my Elasticsearch cluster?"
"How many active nodes are in my cluster?"
Index Operations
"What indices do I have in my Elasticsearch cluster?"
"Create a new index called 'users' with 3 shards and 1 replica."
"Reindex data from 'old_index' to 'new_index'."
Mapping Management
"Show me the field mappings for the 'products' index."
"Add a keyword type field called 'tags' to the 'products' index."
Search & Data Operations
"Find all orders over $500 from last month."
"Which products received the most 5-star reviews?"
"Bulk import these customer records into the 'customers' index."
Template Management
"Create an index template for logs with pattern 'logs-*'."
"Show me all my index templates."
Diagnostics (needs ES_ADMIN_TOOLS=true)
"The 'logs-2026' index is yellow — why are its shards unassigned?"
"Is any node close to a disk watermark?"
"Which of my indices is the largest, and how much of it is deleted documents?"
"Has anyone disabled shard allocation on this cluster?"
"Is a reindex still running?"
Destructive (needs ES_ALLOW_DESTRUCTIVE=true)
"Delete the 'smoke-test-source' index."
"Remove every document older than 2024 from 'logs-archive'."
Troubleshooting
Symptom | Cause |
| No GitHub Packages token in your user-level |
|
|
The client connects, but a diagnostic or delete tool is missing | That set is gated. Set |
| Working as intended: destructive tools take one concrete index name, never a pattern, even with the flag on. |
A connection error mentioning the product check | The cluster is 8.x, or unreachable. This build talks to 7.x only. |
Found a bug or want a tool that is missing? Open an issue on the GitHub repository. To work on the code, start from CONTRIBUTING.md.
This server cannot be installed
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
- AlicenseAqualityAmaintenanceFacilitates interaction with Elasticsearch clusters by allowing users to perform index operations, document searches, and cluster management via a Model Context Protocol server and natural language commands.20303Apache 2.0
- AlicenseCqualityDmaintenanceProvides an MCP protocol interface for interacting with Elasticsearch 7.x databases, supporting comprehensive search functionality including aggregations, highlighting, and sorting.311Apache 2.0

Elasticsearch MCP Serverofficial
AlicenseBqualityDmaintenanceConnects Claude and other MCP clients to Elasticsearch data, allowing users to interact with their Elasticsearch indices through natural language conversations.31,599705Apache 2.0- AlicenseBqualityDmaintenanceEnables interaction with Elasticsearch clusters for health checks, index management, document CRUD operations, and search via natural language.108MIT
Related MCP Connectors
Official Microsoft MCP Server to query Microsoft Entra data using natural language
GibsonAI MCP server: manage your databases with natural language
Personal assistant MCP server with search, execute, packages, jobs, secrets, and integrations.
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/agrica/elasticsearch7-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server