Token导航 LogoToken导航TokenDH.com
Systemd Monitoring MCP logo
运维云端未说明官方级别未说明来源级核验

Systemd Monitoring MCP

MCP Server

通过JSON-RPC协议监控Linux服务器的MCP服务,提供系统服务、定时器和日志的管理与查询功能。

工具数

3

提示词数

0

GitHub Stars

1

资源数

0
日志管理RustToken认证

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

paulstaab

提供方

paulstaab

最后核验

2026/5/17 20:23

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

systemd监控mcp

MCP服务器,用于通过JSON-RPC监控Linux服务器。

功能(MVP)

  • GET /health 公共卫生终点。
  • GET /.well-known/mcp 公共MCP发现端点。
  • POST /mcp MCP JSON-RPC端点(受承载令牌保护)。
  • initialize 接受现代协议版本(包括 2025-03-26)并优雅地进行谈判。
  • MCP工具: list_services, list_timers, list_logs.
  • MCP资源: resource://services/snapshot, resource://services/failed, resource://logs/recent.
  • 使用承载令牌进行身份验证 MCP_API_TOKEN.

MCP工具功能

  • list_services:列表 *.service 可选单元 scope, state, name_contains, limit,以及 summary.
  • list_timers:列表 *.timer 可选单元 scope, name_contains, state, limit, sort, order, overdue_only, include_persistent,以及 summary.
  • list_logs:列出带有必填项的日志 start_utc/end_utc 可选 scope, priority, unit, exclude_units, grep, order, limit, allow_large_window,以及 summary.

scope 支持 system|user|both 默认为 system 对于所有三个列表工具。

配置

注: 强烈建议在反向代理(例如Nginx、HAProxy、Envoy)后面运行此服务 它负责TLS终止并限制网络访问。

不要把这个暴露在互联网上!

变量必填默认描述
MCP_API_TOKEN-静态API令牌(最少16个字符)。
BIND_ADDR没有127.0.0.1绑定地址。
BIND_PORT没有8080绑定端口

export MCP_API_TOKEN="a-secure-token-at-least-16-chars"
# optional:
# export BIND_ADDR="127.0.0.1"
# export BIND_PORT="8080"

cargo run

API示例

健康

curl -s http://127.0.0.1:8080/health

MCP初始化

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","clientInfo":{"name":"example-client","version":"1.0.0"},"capabilities":{}}}' \
	http://127.0.0.1:8080/mcp

MCP工具/清单

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
	http://127.0.0.1:8080/mcp

MCP工具/呼叫列表_服务

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_services","arguments":{"state":"failed","name_contains":"sshd","limit":200}}}' \
	http://127.0.0.1:8080/mcp

MCP工具/调用列表计时器

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":8,"method":"tools/call","params":{"name":"list_timers","arguments":{"scope":"both","sort":"next","order":"asc","limit":200}}}' \
	http://127.0.0.1:8080/mcp

MCP工具/调用列表_logs

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"list_logs","arguments":{"scope":"both","priority":"err","unit":"sshd_service","exclude_units":["cron.service"],"grep":"/timeout|failed/","order":"desc","start_utc":"2026-02-27T00:00:00Z","end_utc":"2026-02-27T01:00:00Z","limit":200}}}' \
	http://127.0.0.1:8080/mcp

MCP工具/呼叫摘要模式

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"list_services","arguments":{"summary":true}}}' \
	http://127.0.0.1:8080/mcp

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"list_timers","arguments":{"scope":"both","summary":true}}}' \
	http://127.0.0.1:8080/mcp

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":9,"method":"tools/call","params":{"name":"list_logs","arguments":{"scope":"both","start_utc":"2026-02-27T00:00:00Z","end_utc":"2026-02-27T01:00:00Z","summary":true}}}' \
	http://127.0.0.1:8080/mcp

MCP工具/调用无效作用域(验证示例)

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":10,"method":"tools/call","params":{"name":"list_services","arguments":{"scope":"global"}}}' \
	http://127.0.0.1:8080/mcp

预期:JSON-RPC错误 -32602 具有稳定的数据代码 invalid_scope.

MCP资源/读取失败服务快照

curl -s \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $MCP_API_TOKEN" \
	-d '{"jsonrpc":"2.0","id":5,"method":"resources/read","params":{"uri":"resource://services/failed"}}' \
	http://127.0.0.1:8080/mcp

验证

在切换或释放之前使用此序列:

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test

备注

  • list_logs 需要UTC RFC3339时间戳 Z 后缀为 start_utcend_utc.
  • 时间窗口超过7天需要 allow_large_window=true.
  • 定时器和服务工具是只读的,不会改变systemd状态。

目录标签

目录标签

日志管理RustToken认证服务器监控本地部署JSON-RPCsystemd工具

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP