Elasticsearch MCP Server
使用模型上下文协议将代理连接到 Elasticsearch 数据,从而允许通过 MCP 客户端(如 Claude Desktop 和 Cursor)与 Elasticsearch 索引进行自然语言交互。
Tools
list_indices
List all available Elasticsearch indices, support regex
get_mappings
Get field mappings for a specific Elasticsearch index
search
Perform an Elasticsearch search with the provided query DSL. Highlights are always enabled.
elasticsearch_health
Get the health status of the Elasticsearch cluster, optionally include index-level details
create_index
Create an Elasticsearch index, optionally configure settings and mappings
create_mapping
Create or update the mapping structure of an Elasticsearch index
bulk
Bulk data into an Elasticsearch index
reindex
Reindex data from a source index to a target index
create_index_template
Create or update an Elasticsearch index template
get_index_template
Get information about Elasticsearch index templates
delete_index_template
Delete an Elasticsearch index template
README
Elasticsearch MCP 服务器
MCP 服务器用于直接从任何 MCP 客户端(如 Claude Desktop、Cursor)连接到您的 Elasticsearch 集群。
此服务器使用模型上下文协议将代理连接到您的 Elasticsearch 数据。它允许您通过自然语言对话与您的 Elasticsearch 索引进行交互。
演示
功能概述
可用功能
list_indices: 列出可用的 Elasticsearch 索引,支持正则表达式get_mappings: 获取特定 Elasticsearch 索引的字段映射search: 使用提供的查询 DSL 执行 Elasticsearch 搜索elasticsearch_health: 获取 Elasticsearch 集群健康状态,可以选择包括索引级别的详细信息create_index: 创建 Elasticsearch 索引,可以选择设置和映射create_mapping: 为 Elasticsearch 索引创建或更新映射结构bulk: 将批量数据导入到 Elasticsearch 索引中reindex: 使用可选的查询和脚本将数据从源索引重新索引到目标索引create_index_template: 创建或更新索引模板get_index_template: 获取有关索引模板的信息delete_index_template: 删除索引模板
工作原理
- MCP 客户端分析您的请求并确定需要哪些 Elasticsearch 操作
- MCP 服务器执行这些操作(列出索引、获取映射、执行搜索)
- MCP 客户端处理结果并以用户友好的格式呈现
快速入门
前提条件
- 一个 Elasticsearch 实例
- Elasticsearch 身份验证凭据(API 密钥或用户名/密码)
- MCP 客户端(例如 Claude Desktop、Cursor)
安装与设置
使用已发布的 NPM 包(即将推出)
[!TIP] 使用 Elasticsearch MCP 服务器的最简单方法是通过已发布的 npm 包。
-
配置 MCP 客户端
- 打开您的 MCP 客户端。 请参阅 MCP 客户端列表,这里我们配置的是 Claude Desktop。
- 转到 Settings > Developer > MCP Servers
- 单击
Edit Config并添加一个新的 MCP 服务器,配置如下:
{ "mcpServers": { "elasticsearch-mcp": { "command": "npx", "args": [ "-y", "@awesome-ai/elasticsearch-mcp" ], "env": { "HOST": "your-elasticsearch-host", "API_KEY": "your-api-key" } } } } -
开始对话
- 在您的 MCP 客户端中打开一个新的对话
- MCP 服务器应自动连接
- 现在您可以提出有关您的 Elasticsearch 数据的问题
配置选项
Elasticsearch MCP 服务器支持配置选项以连接到您的 Elasticsearch:
[!NOTE] 您必须提供 API 密钥或用户名和密码才能进行身份验证。
| 环境变量 | 描述 | 必需 |
|---|---|---|
HOST |
您的 Elasticsearch 实例 URL | 是 |
API_KEY |
用于身份验证的 Elasticsearch API 密钥 | 否 |
USERNAME |
用于基本身份验证的 Elasticsearch 用户名 | 否 |
PASSWORD |
用于基本身份验证的 Elasticsearch 密码 | 否 |
CA_CERT |
Elasticsearch SSL/TLS 的自定义 CA 证书的路径 | 否 |
本地开发
[!NOTE] 如果您想修改或扩展 MCP 服务器,请按照以下本地开发步骤操作。
-
使用正确的 Node.js 版本
nvm use -
安装依赖项
npm install -
构建项目
npm run build -
在 Claude Desktop App 中本地运行(也支持 Cusor)
- 打开 Claude Desktop App
- 转到 Settings > Developer > MCP Servers
- 单击
Edit Config并添加一个新的 MCP 服务器,配置如下:
{ "mcpServers": { "elasticsearch-mcp": { "command": "node", "args": [ "/path/to/your/project/dist/index.js" ], "env": { "HOST": "your-elasticsearch-host", "API_KEY": "your-api-key" } } } } -
使用 MCP Inspector 进行调试
HOST=your-elasticsearch-url API_KEY=your-api-key npm run inspector这将启动 MCP Inspector,允许您调试和分析请求。 您应该看到:
Starting MCP inspector... Proxy server listening on port 3000 🔍 MCP Inspector is up and running at http://localhost:5173 🚀
示例查询
[!TIP] 以下是一些您可以使用 MCP 客户端尝试的自然语言查询。
- "我的 Elasticsearch 集群中有哪些索引?"
- "显示 'products' 索引的字段映射。"
- "查找上个月所有超过 500 美元的订单。"
- "哪些产品收到了最多的 5 星评价?"
- "我的 Elasticsearch 集群的健康状况如何?"
- "创建一个名为 'users' 的新索引,包含 3 个分片和 1 个副本。"
- "向 'products' 索引添加一个名为 'tags' 的 keyword 类型字段。"
- "将这些客户记录批量导入到 'customers' 索引中。"
- "将数据从 'old_index' 重新索引到 'new_index'。"
- "为模式为 'logs-*' 的日志创建索引模板。"
- "显示我的所有索引模板。"
- "删除 'outdated_template' 索引模板。"
如果您遇到问题,请随时在 GitHub 存储库上提出 issue。
灵感来源
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
