Skip to main content

MCP server for journald

Project description

Journald MCP Server

mcp-name: io.github.james116blue/journald-mcp-server An MCP server for accessing systemd journal logs.

Features

  • List systemd units from journal logs
  • List syslog identifiers from journal logs
  • Get datetime of first journal entry
  • Filter journal entries by datetime range (since/until)
  • Filter by systemd unit or syslog identifier
  • Filter by message content (case-insensitive substring matching)
  • Natural language datetime parsing (e.g., "2 hours ago", "yesterday at 3pm")
  • List units and identifiers within specific time ranges

Installation

# Install dependencies
uv sync

Usage

Run as non-root: Give the user systemd-journal group access usermod -aG systemd-journal $USER

Run the server with:

uv run server.py [OPTIONS]

CLI 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: INFO

Examples

  1. Run with stdio transport (default, for MCP clients that communicate via stdin/stdout):

    python server.py
    
  2. Run with HTTP transport on custom port:

    python server.py --transport streamable-http --port 8080
    
  3. Run with SSE transport:

    python server.py --transport sse --port 3000
    
  4. Run with debug logging:

    python server.py --log-level DEBUG
    

MCP Integration

The server provides the following MCP resources and tools:

Resources

  • 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 journal
  • journal://units/{since}/{until}: List unique systemd units within a specified time range
  • journal://syslog-identifiers/{since}/{until}: List unique syslog identifiers within a specified time range

Tools

  • get_journal_entries: Get journal entries with datetime filtering

    • Parameters: since (optional), until (optional), unit (optional), identifier (optional), message_contains (optional), limit (default: 100)
    • Returns: List of entries with timestamp, unit, identifier, and message
    • Example: Get logs from last 2 hours containing "error": since="2 hours ago", message_contains="error"
  • get_recent_logs: Get recent journal logs from the last N minutes

    • Parameters: minutes (default: 60), unit (optional), limit (default: 50)
    • Returns: Formatted string of recent log messages

Datetime Input Format

The server uses natural language datetime parsing via the dateparser library. Supported formats include:

  • Relative times: "2 hours ago", "yesterday at 3pm", "last week", "now"
  • Absolute times: "2024-01-15 14:30", "2024-01-15T14:30:00"
  • Mixed: "today at 9am", "tomorrow 3pm"

All times are interpreted as UTC and returned in human-readable format: "YYYY-MM-DD HH:MM:SS UTC"

Development

This project uses:

  • Python 3.12+
  • MCP FastMCP
  • systemd-python for journal access
  • Click for CLI interface
  • dateparser for natural language datetime parsing

Project Structure

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.md

Running Tests

python -m pytest tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

journald_mcp_server-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

journald_mcp_server-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file journald_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: journald_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for journald_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a3310e1ca2fb78f2ede754f2a0595cfa36b302003a1f8c7a1fbda0dc374e3d94
MD5 c431aca3e7f017c77a2a8ae4f0452b5b
BLAKE2b-256 3cb8554e5f488ae1dbe96ac705133fecfa183eb90b7bc2028e9fb6b86955a1ca

See more details on using hashes here.

File details

Details for the file journald_mcp_server-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: journald_mcp_server-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for journald_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c5e87eaa75e72bfeda1e9053e6aaa83e8b34bd7acd8a1070f01b98ec409920e
MD5 72d256083ba346cb84470bb9a545824d
BLAKE2b-256 c89bf5bcde4909c2cdc7af807d3537be0027f7218f8fb0b61038577929ccf139

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page