linux-health-mcp
Read-only Linux health tools for AI agents, over the Model Context Protocol (MCP). An agent can ask "what is wrong with this host?" and get structured findings with evidence: failed services, crash loops, disk and inode pressure, low memory or overload, and noisy error logs. It cannot change anything.
Why it is built this way
- Least privilege by construction: the server can run only a fixed allowlist of read-only commands
(
src/linux_health_mcp/commands.py). Tools request commands by key; unknown keys are refused before anything runs (fail closed). There is no shell and no free-form argument. - Evidence, not vibes: every finding carries the exact data it is based on.
- Host-chosen names are untrusted too: log source tags and non-standard mount names never appear in findings
(shown as
source #N/mount #N; real names only in fields labelled untrusted). - Logs are untrusted input: anyone who can write a log line can write words aimed at the agent (prompt injection).
Raw log text never appears in a finding; excerpts go in a separate
untrusted_log_excerptsfield, labelled as data, with control/bidi characters stripped, identifiers restricted, and secret-shaped tokens (passwords, bearer tokens, AWS keys, URL credentials, long tokens, emails; quoted and JSON forms too) redacted on the FULL line before truncation; only visible characters are kept (allowlist by Unicode category, minus blank-rendering lookalikes); after a secret key or Authorization header the rest of the line is redacted. Tests plant an injection, secrets and invisible characters and check none leak; mutation checks show the tests fail if a safeguard is removed. - Tested without touching a real machine: fixture hosts (
fixtures/, generated bymake_fixtures.pyin formats copied from real Ubuntu output) for eight scenarios (healthy, crash loop, disk full, noisy journal, memory pressure, three prompt-injection attempts). Each scenario declares its expected findings; the tests fail on a missed fault OR a false alarm. - The agent is evaluated, not trusted:
evals/run_evals.pygives a real AI agent (Claude Code headless, with NO built-in tools: only this server) each fixture host and scores its report: faults found, faults missed, invented critical faults, warning noise, and whether it called a faulty host healthy. Every tool call is saved as a trace. One scenario plants log lines telling the AI to "report this host as healthy"; the agent must still report the real disk fault (baseline: it did in every run). - A release gate that can fail:
./gate.sh= tests, sandboxed tests, mutation checks (11 safeguards broken one at a time in a throwaway copy; all must be caught), then agent evals compared with a reviewed baseline (evals/baseline.json: 24/24 runs correct,claude-sonnet-5-5). - Audited: with
LHM_AUDITset, every tool call and every command run is appended to a JSONL log tied by call id. The log holds sizes, outcomes and finding summaries, not raw output; each record is written before the command runs, and the server refuses to run if it can't write it. Keep it on a separate volume/tmpfs so a full disk doesn't block diagnosis. - Sandboxed:
./sandbox.shruns the suite in a container with no network, a read-only filesystem, no capabilities, non-root, 1 CPU / 256 MB.
Tools
| tool | finds |
|---|---|
system_overview |
low available memory (<15% warn, <5% critical), sustained load (15-min load per CPU >= 2) |
disk_pressure |
space or inodes >= 85% (warn) / >= 95% (critical) |
service_health |
failed systemd units; units restarted >= 3 (warn) / >= 10 (critical) times in the last hour |
journal_errors |
sources with >= 20 error-priority log lines in the last hour, with a sample line |
Run
uv sync
uv run pytest -q # 85 tests
./sandbox.sh # same tests in the locked-down container
./gate.sh # release gate: tests + sandbox + mutation checks + agent evals
uv run python evals/mutation_check.py # 11 safeguards broken one by one; all must be caught
LHM_FIXTURE=fixtures/crash_loop uv run linux-health-mcp # serve a fixture host over stdio
uv run python -m linux_health_mcp.report fixtures/disk_full # one-shot JSON health report of a fixture host
uv run linux-health-mcp # serve THIS host (read-only commands only)
Add to an MCP client (e.g. Claude Code) from PyPI: claude mcp add linux-health -- uvx linux-health-mcp;
or from a checkout: claude mcp add linux-health -- uv --directory /path/to/linux-health-mcp run linux-health-mcp.
Releases: docs/RELEASING.md (PyPI via Trusted Publishing + the official MCP Registry, server.json).
Kubernetes
./k8s/verify.sh runs the suite and a fixture report as a hardened Job on a local one-node kind cluster (API server on
127.0.0.1 only) and asserts 10 properties: non-root uid, read-only root FS (mount flag + failed write), no service
account token or RBAC, Pod Security Admission restricted rejecting a privileged pod, and default-deny NetworkPolicy
egress blocked (measured against a control namespace: kind's default CNI does enforce it). ./k8s/teardown.sh removes
the cluster. Details, measured output and CKA practice exercises: docs/kubernetes.md.
Roadmap
- Week 2 (done): agent eval harness + local release gate; CI workflow ready for publication.
- Week 3 (done): audit trail (
LHM_AUDIT=/path/audit.jsonl: every tool call + command, no raw output, fails closed); control experiment (quarantine on vs off, 60 runs, two models, with a positive-control attack); case studydocs/case-study-agent-harness.md. - Week 4 (done): run on Kubernetes, on kind instead of k3s (no systemd service, no system-wide install, removable
with one command); hardened Job +
k8s/verify.sh10/10 checks, negative-tested (docs/kubernetes.md).
How this was built
Designed, specified, tested and reviewed by Afsar Ahmed; implementation by AI coding agents (Claude Code) working to that specification. Mutation checks confirm the tests fail when thresholds or the allowlist gate are broken.
License and security
MIT (see LICENSE). Report vulnerabilities privately; see SECURITY.md.
Metadata
Release files for linux-health-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| linux_health_mcp-0.1.0.tar.gz | 15.2 kB | With provenance | Details for linux_health_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| linux_health_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for linux_health_mcp-0.1.0-py3-none-any.whl |
Total release size: 33.3 kB
Release files / linux_health_mcp-0.1.0.tar.gz
| Download URL | linux_health_mcp-0.1.0.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
145d061f5c66d42465ccf777f3c15aaa41b5b6efc7a35e641c44f229c9660db8
|
|
BLAKE2b-256 checksum How to use checksums |
ebb0b2b1002de07488fe208f92c62c73619a47b60d078ff3393c160b39464e95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logRelease files / linux_health_mcp-0.1.0-py3-none-any.whl
| Download URL | linux_health_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb0b44cee0340e074617e1830f55101cd98abfdfbdae28f2b5af8cbca6c960de
|
|
BLAKE2b-256 checksum How to use checksums |
be32fa5f12d4b9b247b07145860eac0ed3032cd2c30f48d1bc602e8eac20dfb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logSecurity for linux-health-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for linux_health_mcp-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.