# Elasticsearch MCP — Search & Analytics for AI Agents > MCP server connecting AI agents to Elasticsearch clusters. Run queries, manage indices, and analyze data through natural language via Claude Code or Cline. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use Add to your `.mcp.json`: ```json { "mcpServers": { "elasticsearch": { "command": "npx", "args": ["-y", "@elastic/mcp-server-elasticsearch"], "env": { "ES_URL": "http://localhost:9200", "ES_API_KEY": "your-api-key" } } } } ``` Restart Claude Code. Ask "list all indices" or "search for errors in logs". ## What is Elasticsearch MCP? Elasticsearch MCP is an official MCP server by Elastic that connects AI agents to Elasticsearch clusters. It enables natural language queries, index management, and data analysis — turning Claude Code or Cline into a powerful search and analytics interface for your Elasticsearch data. **Answer-Ready**: Elasticsearch MCP is an official MCP server by Elastic that connects AI agents like Claude Code to Elasticsearch clusters for natural language search, index management, and data analysis. **Best for**: Teams with Elasticsearch clusters who want AI-powered data exploration. **Works with**: Claude Code, Cline, any MCP-compatible tool. **Setup time**: Under 3 minutes. ## Core Features ### 1. Natural Language Search ``` You: "Find all error logs from the last 24 hours with status code 500" Claude Code (via MCP): → Constructs Elasticsearch query → Runs against logs-* index → Returns formatted results with timestamps and messages ``` ### 2. Index Management ``` You: "List all indices and their sizes" You: "Create an index for user events with timestamp and action fields" You: "Show the mapping for the orders index" ``` ### 3. Available Tools | Tool | Description | |------|-------------| | `list_indices` | Show all indices with health and size | | `get_mappings` | View index field mappings | | `search` | Execute search queries | | `get_shards` | View shard allocation | | `get_cluster_health` | Check cluster status | ### 4. Query Building The AI agent translates natural language to Elasticsearch DSL: ``` You: "Show me the top 10 customers by order value this month" Generated query: { "size": 0, "query": {"range": {"order_date": {"gte": "now-1M"}}}, "aggs": { "top_customers": { "terms": {"field": "customer_id", "size": 10}, "aggs": {"total_value": {"sum": {"field": "order_value"}}} } } } ``` ### 5. Multi-Cluster Support Configure multiple Elasticsearch endpoints: ```json { "mcpServers": { "es-prod": { "command": "npx", "args": ["-y", "@elastic/mcp-server-elasticsearch"], "env": {"ES_URL": "https://prod.es.cloud:9243", "ES_API_KEY": "prod-key"} }, "es-staging": { "command": "npx", "args": ["-y", "@elastic/mcp-server-elasticsearch"], "env": {"ES_URL": "https://staging.es.cloud:9243", "ES_API_KEY": "staging-key"} } } } ``` ## Use Cases | Use Case | Example | |----------|---------| | Log analysis | "Find recent errors and group by service" | | Data exploration | "What are the most common user actions?" | | Monitoring | "Is the cluster healthy? Any unassigned shards?" | | Debugging | "Show me requests with latency > 5s today" | ## FAQ **Q: Is this the official Elastic MCP server?** A: Yes, built and maintained by Elastic (the company behind Elasticsearch). **Q: Does it support Elasticsearch 8.x?** A: Yes, designed for Elasticsearch 8.x with API key authentication. **Q: Can it modify data?** A: Currently focused on read operations (search, mappings, health). Write operations are limited for safety. ## Source & Thanks > Created by [Elastic](https://github.com/elastic). Licensed under Apache 2.0. > > [elastic/mcp-server-elasticsearch](https://github.com/elastic/mcp-server-elasticsearch) ## 快速使用 在 `.mcp.json` 中配置 Elasticsearch 连接信息,重启 Claude Code 即可用自然语言查询数据。 ## 什么是 Elasticsearch MCP? Elastic 官方 MCP 服务器,将 AI 代理连接到 Elasticsearch 集群,支持自然语言搜索、索引管理和数据分析。 **一句话总结**:Elastic 官方 MCP 服务器,让 Claude Code 等 AI 工具用自然语言查询和分析 Elasticsearch 数据。 **适合人群**:有 Elasticsearch 集群需要 AI 数据探索的团队。**支持**:Claude Code、Cline。 ## 核心功能 ### 1. 自然语言搜索 用自然语言描述查询,自动生成 Elasticsearch DSL。 ### 2. 索引管理 列出索引、查看映射、检查集群健康。 ### 3. 多集群支持 配置多个 Elasticsearch 端点。 ### 4. 查询构建 AI 代理自动将自然语言转为复杂聚合查询。 ## 常见问题 **Q: 官方的吗?** A: 是,Elastic 官方构建和维护。 **Q: 支持写操作吗?** A: 目前以读操作为主(搜索、映射、健康检查)。 ## 来源与致谢 > [elastic/mcp-server-elasticsearch](https://github.com/elastic/mcp-server-elasticsearch) — Apache 2.0 --- Source: https://tokrepo.com/en/workflows/cba686ed-a6c0-41fe-ae2d-b50339abfa15 Author: MCP Hub