MCP Log Analyzer
A Model Context Protocol server that analyzes various log types on Windows systems, allowing users to register, query, and analyze logs from different sources including Windows Event Logs, ETL files, and structured/unstructured text logs.
README
MCP Log Analyzer
A Model Context Protocol (MCP) server for analyzing different types of logs on Windows systems, built with the FastMCP framework.
Features
-
Multiple Log Format Support
- Windows Event Logs (EVT/EVTX)
- Windows Event Trace Logs (ETL)
- Structured Logs (JSON, XML)
- CSV Logs
- Unstructured Text Logs
-
MCP Tools
register_log_source: Register new log sourceslist_log_sources: View all registered sourcesget_log_source: Get details about a specific sourcedelete_log_source: Remove a log sourcequery_logs: Query logs with filters and paginationanalyze_logs: Perform analysis (summary, pattern, anomaly)
-
MCP Resources
logs://sources: View registered log sourceslogs://types: Learn about supported log typeslogs://analysis-types: Understand analysis optionssystem://windows-event-logs: Recent Windows System and Application event logssystem://linux-logs: Linux systemd journal and application logssystem://process-list: Current processes with PID, CPU, and memory usagesystem://netstat: Network connections and statistics for troubleshooting
-
MCP Prompts
- Log analysis quickstart guide
- Troubleshooting guide
- Windows Event Log specific guide
Installation
# Clone the repository
git clone https://github.com/your-username/mcp-log-analyzer.git
cd mcp-log-analyzer
# Install the package
pip install -e .
# For ETL file support (optional)
pip install -e ".[etl]"
# For development dependencies
pip install -e ".[dev]"
Windows Setup
On Windows, the package includes Windows Event Log support via pywin32. If you encounter import errors:
# Ensure Windows dependencies are installed
pip install pywin32>=300
# Test the setup
python test_windows_setup.py
# If successful, start the server
python main.py
Note: On first install of pywin32, you may need to run the post-install script:
python Scripts/pywin32_postinstall.py -install
Usage
Understanding MCP Servers
MCP (Model Context Protocol) servers don't have traditional web endpoints. They communicate via stdin/stdout with MCP clients (like Claude Code). When you run python main.py, the server starts silently and waits for MCP protocol messages.
Testing the Server
# Test that the server is working
python check_server.py
# See usage instructions
python check_server.py --usage
Starting the MCP Server
# Run directly
python main.py
# Or use Claude Code's MCP integration
claude mcp add mcp-log-analyzer python main.py
Using with Claude Code
-
Add the server to Claude Code:
claude mcp add mcp-log-analyzer python /path/to/main.py -
Use the tools in Claude Code:
- Register a log source: Use the
register_log_sourcetool - Query logs: Use the
query_logstool - Analyze logs: Use the
analyze_logstool
- Register a log source: Use the
-
Access resources:
- Reference resources using
@mcp-log-analyzer:logs://sources - Get help with prompts like
/mcp__mcp-log-analyzer__log_analysis_quickstart
- Reference resources using
System Monitoring Resources
These resources provide real-time system information without needing to register log sources:
-
Check System Processes:
- Access via
@mcp-log-analyzer:system://process-list - Shows top processes by CPU usage with memory information
- Access via
-
Windows Event Logs (Windows only):
- Default:
@mcp-log-analyzer:system://windows-event-logs(last 10 entries) - By count:
@mcp-log-analyzer:system://windows-event-logs/last/50(last 50 entries) - By time:
@mcp-log-analyzer:system://windows-event-logs/time/30m(last 30 minutes) - By range:
@mcp-log-analyzer:system://windows-event-logs/range/2025-01-07 13:00/2025-01-07 14:00 - Shows System and Application event log entries
- Default:
-
Linux System Logs (Linux only):
- Default:
@mcp-log-analyzer:system://linux-logs(last 50 lines) - By count:
@mcp-log-analyzer:system://linux-logs/last/100(last 100 lines) - By time:
@mcp-log-analyzer:system://linux-logs/time/1h(last hour) - By range:
@mcp-log-analyzer:system://linux-logs/range/2025-01-07 13:00/2025-01-07 14:00 - Shows systemd journal, syslog, and common application logs
- Default:
-
Network Monitoring (Cross-platform):
- Default:
@mcp-log-analyzer:system://netstat(listening ports) - Listening ports:
@mcp-log-analyzer:system://netstat/listening - Established connections:
@mcp-log-analyzer:system://netstat/established - All connections:
@mcp-log-analyzer:system://netstat/all - Network statistics:
@mcp-log-analyzer:system://netstat/stats - Routing table:
@mcp-log-analyzer:system://netstat/routing - Port-specific:
@mcp-log-analyzer:system://netstat/port/80 - Uses netstat on Windows, ss (preferred) or netstat on Linux
- Default:
Time Format Examples:
- Relative time:
30m(30 minutes),2h(2 hours),1d(1 day) - Absolute time:
2025-01-07 13:00,2025-01-07 13:30:15,07/01/2025 13:00
Example Workflow
-
Register a Windows System Log:
Use register_log_source tool with: - name: "system-logs" - source_type: "evt" - path: "System" -
Query Recent Errors:
Use query_logs tool with: - source_name: "system-logs" - filters: {"level": "Error"} - limit: 10 -
Analyze Patterns:
Use analyze_logs tool with: - source_name: "system-logs" - analysis_type: "pattern" -
Register an ETL File:
Use register_log_source tool with: - name: "network-trace" - source_type: "etl" - path: "C:\\Traces\\network.etl"
Development
# Run tests
pytest
# Code formatting
black .
isort .
# Type checking
mypy src
# Run all quality checks
black . && isort . && mypy src && flake8
Project Structure
src/mcp_log_analyzer/: Main packagemcp_server/: MCP server implementation using FastMCPcore/: Core functionality and modelsparsers/: Log parsers for different formats
main.py: Server entry point.mcp.json: MCP configurationtests/: Test files
Requirements
- Python 3.12+
- Windows OS (for Event Log support)
- See
pyproject.tomlfor full dependencies
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。