elasticsearch-logs
Read-only MCP server for Elasticsearch log querying. Enables natural language search, filtering, context retrieval, and aggregation of logs.
README
Elasticsearch 日志查询 MCP
这是一个只读的 Elasticsearch MCP 服务,适合让 Codex、Claude Desktop 等 MCP 客户端辅助排查日志。
功能
check_connection:检查 ES 连接和版本list_indices:发现日志索引get_index_fields:查看字段及类型search_logs:按关键词、时间范围和精确字段过滤日志get_log_context:查看某条异常时间点前后的日志aggregate_logs:按日志级别、服务、主机等字段统计,并可生成时间趋势
所有工具均为只读操作。单次最多返回 200 条日志。
安装与启动
python -m pip install -r requirements.txt
python es_mcp_server.py
默认连接信息与原 testes.py 一致。生产使用建议通过环境变量覆盖:
$env:ES_URL = "http://127.0.0.1:9200"
$env:ES_USERNAME = "elastic"
$env:ES_PASSWORD = "your-password"
python es_mcp_server.py
MCP 客户端配置
将下面配置加入客户端的 MCP servers 配置中,并把路径改成当前机器上的实际绝对路径:
{
"mcpServers": {
"elasticsearch-logs": {
"command": "python",
"args": ["D:\\pyProject\\esmcp\\es_mcp_server.py"],
"env": {
"ES_URL": "http://192.168.25.230:9200",
"ES_USERNAME": "elastic",
"ES_PASSWORD": "your-password"
}
}
}
}
使用示例
- “列出最近的日志索引”
- “在
app-logs-*中查询最近一小时包含 NullPointerException 的日志” - “筛选
service.name.keyword=order-service且log.level.keyword=ERROR的日志” - “查看 2026-07-31T10:30:00+08:00 前后两分钟的日志”
- “统计最近 24 小时各日志级别数量,并按 1 小时展示趋势”
字段名称以实际 mapping 为准;首次使用建议先调用 get_index_fields。
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.