# elasticsearch-mcp-server

Connects an agent to Elasticsearch and OpenSearch tools for document search, index inspection, and cluster management. Useful when coding tasks depend on search data.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 313
- Author: cr7258
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/cr7258/elasticsearch-mcp-server
- Updated: 2026-10-19
- HTML: https://affpapa.org/en/nevibecode/mcp/elasticsearch-mcp-server

## What it 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.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `ELASTICSEARCH_HOSTS`, `ELASTICSEARCH_API_KEY`, `ELASTICSEARCH_USERNAME`, `ELASTICSEARCH_PASSWORD`, `ELASTICSEARCH_VERIFY_CERTS` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
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-server
```
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>

### Codex

**Platform CLI**
```bash
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-server
```
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>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "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>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "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>

### Gemini CLI

**Platform CLI**
```bash
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-server
```
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>

## When to use it
- 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
- Search `logs-*` for documents matching this error query.
- Show the mappings and settings for the `products` index.
- Analyze this text with the specified analyzer and return its tokens.

## Similar
- [World Monitor](https://affpapa.org/en/nevibecode/mcp/world-monitor.md) — MCP server · ★ 89408
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89433
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16717
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40409
- [dbx](https://affpapa.org/en/nevibecode/mcp/dbx.md) — MCP server · ★ 27669
- [Metabase](https://affpapa.org/en/nevibecode/mcp/metabase.md) — MCP server · ★ 49845

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
