这是一个与Elasticsearch 7.x版本兼容的MCP服务器。
<a href="https://glama.ai/mcp/servers/zxwxozvlme"> <img width="380" height="200" src="https://gips1.baidu.com/it/u=983903062,720203676&fm=3081&app=3081&f=PNG?w=760&h=400" alt="Elasticsearch 7.x 服务器 MCP 服务器" /> </a>要通过Smithery自动安装Elasticsearch 7.x MCP服务器到Claude Desktop:
npx -y @smithery/cli install @imlewc/elasticsearch7-mcp-server --client claude
pip install -e .
服务器需要以下环境变量:
ELASTIC_HOST:Elasticsearch主机地址(例如,http://localhost:9200)ELASTIC_USERNAME:Elasticsearch用户名ELASTIC_PASSWORD:Elasticsearch密码MCP_PORT:(可选)MCP服务器监听端口,默认9999.env文件并设置ELASTIC_PASSWORD:ELASTIC_PASSWORD=your_secure_password
docker-compose up -d
这将启动一个三节点的Elasticsearch 7.17.10集群、Kibana和MCP服务器。
您可以使用任何MCP客户端连接到MCP服务器:
from mcp import MCPClient
client = MCPClient("localhost:9999")
response = client.call("es-ping")
print(response) # {"success": true}
当前支持的MCP方法:
es-ping:检查Elasticsearch连接es-info:获取Elasticsearch集群信息es-search:在Elasticsearch索引中搜索文档# 基本搜索
search_response = client.call("es-search", {
"index": "my_index",
"query": {
"match": {
"title": "搜索关键词"
}
},
"size": 1
0,
"from": 0
})
# 聚合查询
agg_response = client.call("es-search", {
"index": "my_index",
"size": 0, # 只需聚合结果,无需文档
"aggs": {
"categories": {
"terms": {
"field": "category.keyword",
"size": 10
}
},
"avg_price": {
"avg": {
"field": "price"
}
}
}
})
# 高级搜索,带有高亮显示、排序和过滤
advanced_response = client.call("es-search", {
"index": "my_index",
"query": {
"bool": {
"must": [
{"match": {"content": "搜索词"}}
],
"filter": [
{"range": {"price": {"gte": 100, "lte": 200}}}
]
}
},
"sort": [
{"date": {"order": "desc"}},
"_score"
],
"highlight": {
"fields": {
"content": {}
}
},
"_source": ["title", "date", "price"]
})
elasticsearch7-mcp-server[许可证在LICENSE文件中]