Elasticsearch 7.x MCP 服务器

Elasticsearch 7.x MCP 服务器

为 Elasticsearch 7.x 提供 MCP 协议接口的兼容服务器。

快速入门

安装

通过 Smithery 自动安装:

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

或手动安装:

pip install -e .

配置环境变量

设置以下环境变量:

  • ELASTIC_HOST: Elasticsearch 地址(如 http://localhost:9200)
  • ELASTIC_USERNAME: 用户名
  • ELASTIC_PASSWORD: 密码
  • MCP_PORT: (可选)默认 9999

使用 Docker Compose

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

示例代码

使用 MCP 客户端连接服务器:

from mcp import MCPClient
client = MCPClient("localhost:9999")
response = client.call("es-ping")
print(response)

支持的方法包括:es-pinges-infoes-search