Journald MCP Server

io.github.james116blue由 GitHub 账号 james116blue 发布v0.1.0更新于 Oct 24, 2026

Incident forensic with log files analyzing

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

只读的 MCP 服务器,让助手查询本机 systemd journal 日志,可按时间范围、unit、syslog 标识和消息内容筛选。

可以做什么
  • 列出 journal 中的 systemd unit 与 syslog 标识,可限定时间范围
  • 获取 journal 第一条记录的时间
  • 按 since/until、unit、标识及不区分大小写的消息子串筛选日志条目,并可限制条数
  • 获取某 unit 最近 N 分钟的日志
  • 支持“2 hours ago”“yesterday at 3pm”等自然语言时间,按 UTC 解释
适用场景
适合在 Linux 机器上做故障排查与事件取证:让助手拉取近期服务日志、按时间窗口或 unit 缩小范围、搜索错误信息,而无需手写 journalctl 命令。
运行要求
以本地 Python 3.12+ 进程运行(PyPI 包 journald-mcp-server,或 uv sync 后运行 server.py),依赖 systemd-python 访问 journal。建议将用户加入 systemd-journal 组以便非 root 读取日志。默认 stdio 传输,可选 sse 与 streamable-http。
安装前请注意
journal 日志可能包含敏感的系统与应用数据(如密钥、个人信息),这些内容会传给助手及其模型提供方。访问为只读,但仍应以最小权限运行(使用 systemd-journal 组而非 root)。启用 HTTP 传输会在监听端口上暴露日志数据。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Journald MCP Server,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

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

bash
# Install dependenciesuv sync

Usage

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

Run the server with:

bash
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):

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

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

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

    bash
    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

bash
python -m pytest tests/

来源:README.md,提交 d9843ed

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.1.0最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。