Incident forensic with log files analyzing
An MCP server for accessing systemd journal logs.
# Install dependencies
uv syncRun as non-root: Give the user systemd-journal group access usermod -aG systemd-journal $USER
Run the server with:
uv run server.py [OPTIONS]--transport: Transport protocol to use (stdio, sse, or streamable-http). Default: stdio--port: Port to listen on for HTTP transport (ignored for stdio transport). Default: 3002--log-level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL). Default: INFORun with stdio transport (default, for MCP clients that communicate via stdin/stdout):
python server.pyRun with HTTP transport on custom port:
python server.py --transport streamable-http --port 8080Run with SSE transport:
python server.py --transport sse --port 3000Run with debug logging:
python server.py --log-level DEBUGThe server provides the following MCP resources and tools:
journal://units: List unique systemd units from journal logs (all accessible time)journal://syslog-identifiers: List unique syslog identifiers from journal logs (all accessible time)journal://first-entry-datetime: Get the datetime of the first entry in the journaljournal://units/{since}/{until}: List unique systemd units within a specified time rangejournal://syslog-identifiers/{since}/{until}: List unique syslog identifiers within a specified time rangeget_journal_entries: Get journal entries with datetime filtering
since (optional), until (optional), unit (optional), identifier (optional), message_contains (optional), limit (default: 100)since="2 hours ago", message_contains="error"get_recent_logs: Get recent journal logs from the last N minutes
minutes (default: 60), unit (optional), limit (default: 50)The server uses natural language datetime parsing via the dateparser library. Supported formats include:
All times are interpreted as UTC and returned in human-readable format: "YYYY-MM-DD HH:MM:SS UTC"
This project uses:
journald-mcp-server/
├── journald_mcp_server/ # Main package
│ ├── __init__.py
│ ├── server.py # MCP server implementation
│ └── datetime_utils.py # Datetime parsing and formatting utilities
├── tests/ # Test suite
│ ├── __init__.py
│ └── test_server.py
├── server.py # Entry point wrapper
├── pyproject.toml
└── README.mdpython -m pytest tests/