Back to MCP directory
publicPublicdnsLocal runtime

mcp-server-elasticsearch

Elasticsearch MCP服务器项目,通过模型上下文协议(MCP)实现自然语言交互查询Elasticsearch数据

article

README

🚀 Elasticsearch MCP 服务器

通过 MCP 客户端(如 Claude Desktop),您可以直接连接到自己的 Elasticsearch 数据。本服务器借助 Model Context Protocol (MCP) 将代理连接至 Elasticsearch 数据,支持您通过自然语言对话与 Elasticsearch 索引进行交互。

🚀 快速开始

先决条件

  • 一个 Elasticsearch 实例
  • Elasticsearch 认证凭据(API 密钥或用户名/密码)
  • MCP 客户端(例如 Claude Desktop)

安装与设置

连接 Elasticsearch MCP 服务器

  1. 安装 Elasticsearch:按照官方文档安装 Elasticsearch。
  2. 配置 Elasticsearch:编辑 elasticsearch.yml 文件,添加以下内容:
plugins.security.enabled: true
plugins.security.ssl.enabled: true

重启 Elasticsearch 服务以应用更改。

连接 MCP 客户端

使用 MCP 客户端(如 Claude Desktop)连接到 Elasticsearch。

示例演示

示例演示链接

✨ 主要特性

本服务器提供了以下工具,方便您与 Elasticsearch 进行交互:

  • list_indices:列出所有可用的 Elasticsearch 索引。
  • get_mappings:获取特定 Elasticsearch 索引的字段映射。
  • 搜索:使用提供的查询 DSL 执行 Elasticsearch 搜索。
  • get_shards:获取所有或特定索引的分片信息。

🔧 技术细节

安全最佳实践

⚠️ 重要提示 避免使用集群管理员权限。创建具有最小权限的专用 API 密钥,并在索引级别应用细粒度访问控制以防止未经授权的数据访问。

您可以创建一个具有有限权限的专用 Elasticsearch API 密钥:

POST /_security/api_key
{
  "name": "es-mcp-server-access",
  "role_descriptors": {
    "mcp_server_role": {
      "cluster": [
        "monitor"
      ],
      "indices": [
        {
          "names": [
            "index-1",
            "index-2",
            "index-pattern-*"
          ],
          "privileges": [
            "read",
            "view_index_metadata"
          ]
        }
      ]
    }
  }
}

故障排除

  • 确保您的 MCP 配置正确。
  • 验证您的 Elasticsearch URL 是否可以从您的机器访问。
  • 检查您的认证凭据(API 密钥或用户名/密码)是否具有必要的权限。
  • 如果使用 SSL/TLS 和自定义 CA,请验证证书路径是否正确且文件可读。
  • 查看终端输出中的错误信息。

如果遇到问题,请在 GitHub 仓库中打开一个 issue。

📄 许可证

本项目采用 Apache License 2.0 许可协议。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client