# Elasticsearch MCP Server
> [!CAUTION]
> This MCP server is deprecated and will only receive critical security updates going forward.
> It has been superseded by the [Elastic Agent Builder](https://ela.st/agent-builder-docs) [MCP endpoint...
# Elasticsearch MCP Server
> [!CAUTION]
> This MCP server is deprecated and will only receive critical security updates going forward.
> It has been superseded by the [Elastic Agent Builder](https://ela.st/agent-builder-docs) [MCP endpoint](https://ela.st/agent-builder-mcp), which is available in Elastic 9.2.0+ and Elasticsearch Serverless projects.
## Use the Elasticsearch MCP Server for AI Agents
The Elasticsearch MCP Server connects your AI agents to Elasticsearch data using the [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro) (MCP).
It enables natural language interactions with your Elasticsearch indices, allowing agents to query, analyze, and retrieve data without custom APIs.
Follow these steps to deploy and configure the Elasticsearch MCP Server container image from AWS Marketplace.
### Before you begin
Before you start, ensure you have:
- An Elasticsearch cluster (version 8.x or 9.x) accessible from your AWS environment
- Elasticsearch authentication credentials:
- An [API key](https://www.elastic.co/docs/deploy-manage/api-keys), or
- A [username](https://www.elastic.co/docs/deploy-manage/users-roles) and password pair
- Docker installed and running in your AWS environment (for example, on an EC2 instance or in a container service)
- An MCP client configured (such as Claude Desktop, Cursor, VS Code, or another MCP-compatible tool)
- Network connectivity between your deployment environment and your Elasticsearch cluster
> [!NOTE]
>
> These instructions apply to Elasticsearch MCP Server 0.4.0 and later.
> For versions 0.3.1 and earlier, refer to the [README for v0.3.1](https://github.com/elastic/mcp-server-elasticsearch/tree/v0.3.1).
### Deploy the Elasticsearch MCP Server
The Elasticsearch MCP Server is provided as a Docker container image available from AWS Marketplace. You can run it using either the stdio protocol (for direct client connections) or the streamable-HTTP protocol (for web-based integrations).
#### Choose a protocol
The server supports two protocols:
- [stdio](https://modelcontextprotocol.io/specification/latest/basic/transports#stdio): Direct communication between the MCP client and server. Use this when your client supports stdio and runs in the same environment.
- [streamable-HTTP](https://modelcontextprotocol.io/specification/latest/basic/transports#streamable-http): HTTP-based protocol recommended for web integrations, stateful sessions, and concurrent clients.
> **Note:** Server-Sent Events (SSE) is deprecated. Use streamable-HTTP instead.
### Configure the stdio protocol
Use the stdio protocol when your MCP client connects directly to the server process.
#### Set environment variables for stdio mode
Set the following environment variables:
- `ES_URL`: The URL of your Elasticsearch cluster (for example, `https://your-cluster.es.amazonaws.com:9200`)
- For authentication, use one of these options:
- API key: Set `ES_API_KEY` to your Elasticsearch API key
- Basic authentication: Set `ES_USERNAME` and `ES_PASSWORD` to your Elasticsearch credentials
- (Optional) `ES_SSL_SKIP_VERIFY`: Set to `true` to skip SSL/TLS certificate verification when connecting to Elasticsearch. Only use this for development or testing environments.
#### Run the container in stdio mode
Start the MCP server in stdio mode:
```bash
docker run -i --rm \
-e ES_URL \
-e ES_API_KEY \
docker.elastic.co/mcp/elasticsearch \
stdio
```
#### Configure Claude Desktop
Add this...