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
- 创建
.env
文件,设置ELASTIC_PASSWORD
。 - 启动服务:
docker-compose up -d
示例代码
使用 MCP 客户端连接服务器:
from mcp import MCPClient
client = MCPClient("localhost:9999")
response = client.call("es-ping")
print(response)
支持的方法包括:es-ping
、es-info
和 es-search
。