为 Elasticsearch 7.x 提供 MCP 协议接口的服务器,支持与 Elasticsearch 7.x 版本兼容,可让用户通过 MCP 客户端轻松访问 Elasticsearch 功能。
本服务器为 Elasticsearch 7.x 提供 MCP 协议接口,支持基本的 Elasticsearch 操作,如心跳检测、信息查询等,还完全支持搜索功能,包括聚合查询、高亮显示、排序和其他高级特性。
通过 Smithery 自动为 Claude 桌面安装 Elasticsearch 7.x MCP Server:
npx -y @smithery/cli install @imlewc/elasticsearch7-mcp-server --client claude
pip install -e .
.env 文件并设置 ELASTIC_PASSWORD:ELASTIC_PASSWORD=your_secure_password
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 服务器:
from mcp import MCPClient
client = MCPClient("localhost:9999")
response = client.call("es-ping")
print(response) # {"success": true}
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 |
git clone https://github.com/your-repository.git
cd your-repository
pip install -r requirements.txt
python server.py
有关许可证信息,请参阅 LICENSE 文件。