Elasticsearch MCP Server
Read this in other languages: English, 中文
Overview
An Elasticsearch MCP (Model Context Protocol) server built on , providing seamless integration with Elasticsearch 7, 8, and 9 versions.
接入你的智能体
從發布者安裝。不是 PlugMCP 端點。
遠端 URL 還是本機指令? 兩種安裝方式的差異
es_cluster_info: Get cluster information and version detailses_cluster_health: Get cluster health status and metricses_index_create: Create new indices with settings and mappingses_index_delete: Delete existing indiceses_index_exists: Check if an index existses_index_list: List all indices with metadataes_document_index: Index documents with optional IDes_document_get: Retrieve documents by IDes_document_update: Update existing documentses_document_delete: Delete documents by IDes_search: Execute search queries with filters, sorting, and field selection
index, query, size, from, sort, _sourcees_bulk: Execute multiple operations in a single requestChoose one of the following methods to run the Elasticsearch MCP server:
# Basic usage with local Elasticsearch
docker run --rm \
-e ES_ADDRESSES=http://localhost:9200 \
ghcr.io/aeazer/mcp-elasticsearch:latest
# HTTP mode for remote access
docker run -d -p 8080:8080 \
-e MCP_PROTOCOL=http \
-e ES_ADDRESSES=http://your-elasticsearch:9200 \
ghcr.io/aeazer/mcp-elasticsearch:latest
# With authentication
docker run -d -p 8080:8080 \
-e MCP_PROTOCOL=http \
-e ES_ADDRESSES=https://your-elasticsearch:9200 \
-e ES_USERNAME=elastic \
-e ES_PASSWORD=your-password \
-e ES_SSL=true \
ghcr.io/aeazer/mcp-elasticsearch:latest
# Clone the repository
git clone https://github.com/AeaZer/mcp-elasticsearch.git
cd mcp-elasticsearch
# Build Docker image
docker build -t mcp-elasticsearch .
# Run the container
docker run -e ES_ADDRESSES=http://localhost:9200 -e ES_VERSION=8 mcp-elasticsearch
# Clone the repository
git clone https://github.com/AeaZer/mcp-elasticsearch.git
cd mcp-elasticsearch
# Download dependencies and build
go mod download
go build -o mcp-elasticsearch main.go
# Run with environment variables
export ES_ADDRESSES=http://localhost:9200
export ES_VERSION=8
export MCP_PROTOCOL=stdio
./mcp-elasticsearch
For integration with desktop applications that support MCP, you can configure the server through a configuration file:
First, ensure you have the mcp-elasticsearch executable available:
# Option A: Install directly from GitHub (Recommended)
go install github.com/AeaZer/mcp-elasticsearch@latest
# Option B: Build from source
git clone https://github.com/AeaZer/mcp-elasticsearch.git
cd mcp-elasticsearch
go mod download
go build -o mcp-elasticsearch main.go
# Option C: Download pre-built binary (Windows only)
# Download mcp-elasticsearch.exe from GitHub Releases
# macOS and Linux users should use Option A or B
Note: Docker is not suitable for desktop application integration as it doesn't support stdio mode properly in this context. Use native executables instead.
If you used go install (Option A), the executable is automatically placed in $GOPATH/bin or $GOBIN, which is typically already in your PATH environment variable.
If you built from source (Option B) or downloaded the pre-built binary (Option C), ensure the mcp-elasticsearch executable is in your system PATH environment variable, or use the full path in your configuration.
Create or modify the MCP configuration file for your desktop application:
Cursor: Create or edit ~/.cursor/mcp.json (Linux/Mac) or %APPDATA%\Cursor\User\mcp.json (Windows)
Claude Desktop: Create or edit configuration in the appropriate location for your platform.
Basic Configuration:
{
"mcpServers": {
"elasticsearch": {
"command": "mcp-elasticsearch",
"env": {
"ES_ADDRESSES": "http://localhost:9200",
"ES_VERSION": "8"
}
}
}
}
With Authentication:
{
"mcpServers": {
"elasticsearch": {
"command": "mcp-elasticsearch",
"env": {
"ES_ADDRESSES": "https://your-elasticsearch.com:9200",
"ES_USERNAME": "elastic",
"ES_PASSWORD": "your-password",
"ES_VERSION": "8",
"ES_SSL": "true"
}
}
}
}
With API Key:
{
"mcpServers": {
"elasticsearch": {
"command": "mcp-elasticsearch",
"env": {
"ES_ADDRESSES": "https://your-elasticsearch.com:9200",
"ES_API_KEY": "your-api-key",
"ES_VERSION": "8"
}
}
}
}
Elastic Cloud Configuration:
{
"mcpServers": {
"elasticsearch": {
"command": "mcp-elasticsearch",
"env": {
"ES_CLOUD_ID": "your-cloud-id",
"ES_USERNAME": "elastic",
"ES_PASSWORD": "your-password",
"ES_VERSION": "8"
}
}
}
}
Using Full Path (if not in PATH):
{
"mcpServers": {
"elasticsearch": {
"command": "/full/path/to/mcp-elasticsearch",
"env": {
"ES_ADDRESSES": "http://localhost:9200",
"ES_VERSION": "8"
}
}
}
}
After creating or modifying the configuration file, restart your desktop application to load the new MCP server configuration.
Once configured, you should see Elasticsearch tools and resources available in your desktop application. The available tools include cluster operations, index management, document operations, search capabilities, and bulk operations as listed in the "Supported Tools" section above.
docker run -d -p 8080:8080 \
--name mcp-elasticsearch \
-e MCP_PROTOCOL=http \
-e ES_ADDRESSES=http://host.docker.internal:9200 \
ghcr.io/aeazer/mcp-elasticsearch:latest
# Test the server endpoints
curl http://localhost:8080/health # Health check
curl http://localhost:8080/mcp # MCP endpoint (requires proper MCP client)
docker run -d -p 8080:8080 \
-e MCP_PROTOCOL=http \
-e ES_CLOUD_ID="your-cloud-id" \
-e ES_USERNAME=elastic \
-e ES_PASSWORD="your-password" \
-e ES_VERSION=8 \
ghcr.io/aeazer/mcp-elasticsearch:latest
⚠️ WARNING: SSE protocol is deprecated and not recommended for production use. Use HTTP mode instead.
docker run -d -p 8080:8080 \
--name mcp-elasticsearch-sse \
-e MCP_PROTOCOL=sse \
-e ES_ADDRESSES=http://host.docker.internal:9200 \
-e ES_VERSION=8 \
ghcr.io/aeazer/mcp-elasticsearch:latest
# SSE endpoint (deprecated)
curl http://localhost:8080/sse
Create a docker-compose.yml file:
version: '3.8'
services:
mcp-elasticsearch:
image: ghcr.io/aeazer/mcp-elasticsearch:latest
ports:
- "8080:8080"
environment:
- MCP_PROTOCOL=http
- ES_ADDRESSES=http://elasticsearch:9200
- ES_VERSION=8
depends_on:
- elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
environment:
- discovery.type=single-node
- xpack.security.enabled=false
ports:
- "9200:9200"
Run with: docker-compose up -d
All configuration is done via environment variables:
Different protocols use different access methods:
http://host:port/mcphttp://host:port/healthhttp://localhost:8080/mcphttp://host:port/ssehttp://localhost:8080/sseexport ES_ADDRESSES=http://localhost:9200
export MCP_PROTOCOL=stdio
./mcp-elasticsearch
export ES_ADDRESSES=http://localhost:9200
export MCP_PROTOCOL=http
export MCP_PORT=8080
./mcp-elasticsearch
⚠️ WARNING: SSE protocol is deprecated and not recommended for production use. Use Streamable HTTP instead.
export ES_ADDRESSES=http://localhost:9200
export MCP_PROTOCOL=sse
export MCP_PORT=8080
./mcp-elasticsearch
export ES_CLOUD_ID=your_cloud_id
export ES_USERNAME=elastic
export ES_PASSWORD=your_password
export ES_VERSION=8
./mcp-elasticsearch
go mod download
go build -o mcp-elasticsearch main.go
go test ./...
docker build -t mcp-elasticsearch .
{
"tool": "es_cluster_info",
"arguments": {}
}
{
"tool": "es_index_create",
"arguments": {
"index": "my-index",
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"title": {"type": "text"},
"timestamp": {"type": "date"}
}
}
}
}
{
"tool": "es_document_index",
"arguments": {
"index": "my-index",
"id": "doc1",
"body": {
"title": "Hello World",
"content": "This is a test document",
"timestamp": "2024-01-01T00:00:00Z"
}
}
}
{
"tool": "es_search",
"arguments": {
"index": "my-index",
"query": {
"bool": {
"must": [
{"match": {"title": "Hello"}}
],
"filter": [
{"range": {"timestamp": {"gte": "2024-01-01"}}}
]
}
},
"sort": [
{"timestamp": {"order": "desc"}},
{"_score": {"order": "desc"}}
],
"_source": ["title", "content", "timestamp"],
"size": 20,
"from": 0
}
}
When running in HTTP mode, the server provides multiple endpoints:
# Check server health (publicly accessible)
curl http://localhost:8080/health
# Response
{"status":"healthy","server":"elasticsearch-mcp"}
# MCP communication endpoint (requires MCP client)
# URL: http://localhost:8080/mcp
# This endpoint handles MCP protocol messages and tool calls
# Not directly accessible via simple HTTP GET requests
/health): Simple HTTP GET for monitoring/mcp): For MCP protocol communication only/sse): Deprecated, avoid usingAll errors are reported within the MCP tool results with isError: true, allowing LLMs to see and handle errors appropriately. Protocol-level errors are reserved for exceptional conditions like missing tools or server failures.
host.docker.internal:9200 instead of localhost:9200 in DockerES_INSECURE_SKIP_VERIFY=true for testing with self-signed certificatesgit checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
An Elasticsearch MCP (Model Context Protocol) server
工具
尚無工具清單。遠端伺服器會在首次健康檢查後取得工具清單。
常見問題
在本頁複製適用於 Cursor、Claude Desktop、Claude Code 或 VS Code 的 stdio 設定。它使用發布者的安裝方式,而不是 PlugMCP 代理伺服器。
這筆記錄未列出必要的環境變數。
MCP Elasticsearch 透過 stdio 在本機執行。
上次檢查時間:2026-10-27。 An Elasticsearch MCP (Model Context Protocol) server