Back to MCP directory
publicPublicdnsLocal runtime

cr7258_elasticsearch-mcp-server

Elasticsearch MCP服务器实现,提供索引操作、文档搜索和集群管理功能,支持通过自然语言与Elasticsearch交互。

article

README

🚀 Elasticsearch MCP 服务器

这是一个能与 Elasticsearch 实现交互的模型上下文协议(MCP)服务器。该服务器借助一系列工具,可实现搜索文档、分析索引以及管理集群等功能。

点击查看相关资源

✨ 主要特性

索引操作

  • list_indices:可列出 Elasticsearch 集群中的所有索引。
  • get_mapping:能获取特定索引的映射配置。
  • get_settings:用于获取特定索引的设置配置。

文档操作

  • search_documents:可使用 Elasticsearch 查询 DSL 在索引中搜索文档。

集群操作

  • get_cluster_health:获取集群的健康状态。
  • get_cluster_stats:获取集群的统计信息。

📦 安装指南

启动 Elasticsearch 集群

使用 Docker Compose 启动 Elasticsearch 集群:

docker-compose up -d

这将启动一个 3 节点的 Elasticsearch 集群和 Kibana。默认 Elasticsearch 用户名是 elastic,密码为 test123。 你可以从 https://localhost:5601 访问 Kibana。

💻 使用示例

配置 Claude Desktop

  1. 将以下配置添加到 Claude Desktop 的配置文件 claude_desktop_config.json 中:
{
  "mcpServers": {
    "elasticsearch": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/elasticsearch_mcp_server/src",
        "run",
        "server.py"
      ],
      "env": {
        "ELASTIC_HOST": "<your_elastic_url>",
        "ELASTIC_USERNAME": "<your_elastic_username>",
        "ELASTIC_PASSWORD": "<your_elastic_password>>"
      }
    }
  }
}
  • 在 macOS 上:配置文件路径为 ~/Library/Application Support/Claude/claude_desktop_config.json
  • 在 Windows 上:配置文件路径为 %APPDATA%/Claude/claude_desktop_config.json%
  1. 重新启动 Claude Desktop 以加载新的 MCP 服务器。

与 Elasticsearch 集群交互

现在你可以通过 Claude 使用自然语言命令与你的 Elasticsearch 集群交互,例如:

  • "列出集群中的所有索引"
  • "鲍勃有多大年纪?"
  • "显示集群的健康状态"
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