Back to MCP directory
publicPublicdnsLocal runtime

elasticsearch7-mcp-server

这是一个为Elasticsearch 7.x提供MCP协议接口的服务,支持基本的Elasticsearch操作和完整的搜索功能,包括聚合查询、高亮显示等高级特性。

article

README

🚀 Elasticsearch 7.x MCP 服务器

为 Elasticsearch 7.x 提供 MCP 协议接口的服务器,支持与 Elasticsearch 7.x 版本兼容,可让用户通过 MCP 客户端轻松访问 Elasticsearch 功能。

smithery badge

🚀 快速开始

本服务器为 Elasticsearch 7.x 提供 MCP 协议接口,支持基本的 Elasticsearch 操作,如心跳检测、信息查询等,还完全支持搜索功能,包括聚合查询、高亮显示、排序和其他高级特性。

✨ 主要特性

  • 提供 Elasticsearch 7.x 的 MCP 协议接口
  • 支持基本的 Elasticsearch 操作(如心跳检测、信息查询等)
  • 完全支持搜索功能,包括聚合查询、高亮显示、排序和其他高级特性
  • 通过任何 MCP 客户端轻松访问 Elasticsearch 功能

📦 安装指南

配置要求

  • Python 3.10+ 或更高版本
  • Elasticsearch 7.x(推荐使用 7.17.x 版本)

使用 Smithery 自动安装

通过 Smithery 自动为 Claude 桌面安装 Elasticsearch 7.x MCP Server:

npx -y @smithery/cli install @imlewc/elasticsearch7-mcp-server --client claude

手动安装

pip install -e .

使用 Docker Compose

  1. 创建 .env 文件并设置 ELASTIC_PASSWORD
ELASTIC_PASSWORD=your_secure_password
  1. 启动服务:
docker-compose up -d

这将启动一个三节点的 Elasticsearch 7.17.10 集群、Kibana 和 MCP 服务器。

💻 使用示例

环境变量配置

服务器需要以下环境变量:

  • ELASTIC_HOST:Elasticsearch 服务地址(例如 http://localhost:9200)
  • ELASTIC_USERNAME:Elasticsearch 用户名
  • ELASTIC_PASSWORD:Elasticsearch 密码
  • MCP_PORT:(可选)MCP 服务器监听端口,默认为 9999

使用 MCP 客户端

你可以使用任何 MCP 客户端连接到 MCP 服务器:

from mcp import MCPClient

client = MCPClient("localhost:9999")
response = client.call("es-ping")
print(response)  # {"success": true}

搜索 API 示例

基本搜索

response = client.call("es-search", body={
    "query": {
        "match_all": {}
    }
})
print(response)

带过滤的搜索

response = client.call("es-search", body={
    "query": {
        "term": {
            "field": "value"
        }
    }
}, index="your_index_name")
print(response)

📚 详细文档

环境变量说明

| 属性 | 详情 | |------|------| | ELASTIC_HOST | 指定 Elasticsearch 服务的地址,默认为 localhost | | ELASTIC_PORT | 指定 Elasticsearch 服务的端口,默认为 9200 | | MCP_LISTEN | 指定 MCP 服务器监听的地址,默认为 0.0.0.0 | | MCP_PORT | 指定 MCP 服务器的监听端口,默认为 9999 |

开发指南

  1. 克隆仓库:
git clone https://github.com/your-repository.git
cd your-repository
  1. 安装依赖项:
pip install -r requirements.txt
  1. 启动服务器:
python server.py

📄 许可证

有关许可证信息,请参阅 LICENSE 文件。

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