Repository avatar
Other Tools
v0.3.1
active

librenmsctrl

io.github.lidless-labs/librenmsctrl

LibreNMS CLI and MCP server for devices, ports, sensors, and alerts over stdio with gated writes.

Documentation

librenmsctrl banner

Lidless Labs

librenmsctrl

An operator control CLI for LibreNMS: inspect devices, ports, alerts, syslog, and authentication logs over API-token auth, with an MCP adapter for agent workflows.

Website → lidless.dev/librenms-mcp

npm version control CLI MCP compatible MIT license

librenmsctrl is a local operator control CLI for LibreNMS, the open-source network monitoring system. It gives shells, cron, and CI a typed command surface for reading your monitored network: devices, ports, port health, alerts, alert history, event log, device syslog, and LibreNMS authentication log over API-token auth.

The same package remains MCP-compatible for agent workflows. librenmsctrl mcp starts the stdio Model Context Protocol adapter, and the existing librenms-mcp binary continues to work for launchers and configs that already use it. The MCP adapter can acknowledge or mute alerts only when you pass an explicit confirm: true. It differs from pointing an agent at the raw LibreNMS REST API in one way that matters: every write is gated, every argument is schema-validated before it leaves the host, and your token is redacted from all output, so a hallucinated tool call cannot change your monitoring state by accident.

Status: work in progress. v1 ships read tools (tier 1) and confirm-gated safe writes (tier 2) only. Destructive operations (tier 3) such as device deletion, alert-rule removal, and bulk port resets are intentionally deferred until the write-gate pattern has more field time. The read path and the two write gates are tested.

What it does

librenmsctrl turns a LibreNMS instance into a scriptable control surface for network monitoring and observability work: list the devices LibreNMS is polling over SNMP, pull a single device or port, check port health and utilization, read alerts and logs, including device syslog and LibreNMS authentication events. It authenticates with a LibreNMS API token, talks to the LibreNMS /api/v0 REST API under the hood, and can emit human-readable tables or raw JSON for piping.

For MCP clients, the mcp subcommand exposes the same LibreNMS client core as structured tool output an agent can reason over. The package name is still @solomonneas/librenms-mcp, and the back-compat librenms-mcp bin is intentionally kept stable.

Writes are gated in three tiers:

  • Tier 1 (reads): open. No confirm flag. Status, device and port listings, single device or port, port health, alert listings, alert history, event log, syslog, and authentication log.
  • Tier 2 (safe writes): require an explicit confirm: true argument, documented on every write tool's JSON schema. Acknowledge an alert, unmute an alert, or put a device into a maintenance window. A tool call missing the flag throws WriteGateError before any HTTP traffic leaves the host.
  • Tier 3 (destructive): not implemented in v1. When added, ops like device deletion and alert-rule removal will also require destructive: true. The model cannot bypass either gate from a hallucinated call.

Every tool call is validated against its published TypeBox inputSchema before the tool runs. Ids, port ids, device ids, limits, and the type/state filters are bounds- and enum-checked, so a malformed or injection-style argument is rejected up front and never reaches a LibreNMS URL path or query string. Interpolated path and query values are URL-encoded as defense-in-depth. The API token is registered with the redactor on startup and masked from all log and error output.

Quickstart

Published to npm as @solomonneas/librenms-mcp. Install the package to get the librenmsctrl operator CLI and the back-compat librenms-mcp MCP launcher.

# start the MCP adapter on demand through the back-compat `librenms-mcp` bin
npx -y @solomonneas/librenms-mcp

# install the global `librenmsctrl` and `librenms-mcp` binaries
npm install -g @solomonneas/librenms-mcp

It needs Node 20+ and two env vars, LIBRENMS_URL and LIBRENMS_TOKEN.

export LIBRENMS_URL=https://librenms.example.local
export LIBRENMS_TOKEN=<your-api-token>

librenmsctrl status
librenmsctrl alerts list --state 1
librenmsctrl alerts list --severity critical --rule 49 --order "timestamp desc"
librenmsctrl --json ports health --metric errors_in --limit 10

The MCP adapter speaks stdio by default. A quick way to confirm it starts is to feed it an MCP tools/list request:

export LIBRENMS_URL=https://librenms.example.local
export LIBRENMS_TOKEN=<your-api-token>
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | npx -y @solomonneas/librenms-mcp

You should get back a JSON listing of the 17 tools above. In normal use you point an MCP client at the same command instead.

For Executor and other remote MCP clients, opt into Streamable HTTP with LIBRENMS_MCP_TRANSPORT=http. It binds to loopback on port 3000 by default and uses the shared kit's 1 MiB request body cap. Set LIBRENMS_MCP_HTTP_TOKEN to require a bearer token; a token is mandatory when binding to a non-loopback address. A non-loopback bind also requires explicit opt-in via LIBRENMS_MCP_HTTP_HOST. See Streamable HTTP setup for the full environment and client configuration.

Tools

The MCP adapter exposes 17 tools: 14 reads, 3 confirm-gated safe writes. This list is generated from the server's tool registration in mcp-server.ts.

Reads (14, open):

ToolWhat it does
librenms_statusLibreNMS instance status check.
librenms_list_devicesList monitored devices.
librenms_get_deviceFetch a single device by id.
librenms_list_portsList ports across devices.
librenms_get_portFetch a single port detail.
librenms_port_healthRank ports by current error rates or utilization percent.
librenms_list_alertsList current alerts.
librenms_get_alertFetch a single alert by id.
librenms_alert_historyHistorical alert records.
librenms_event_logRead the device event log.
librenms_syslogRead device syslog, optionally scoped to a hostname or device id.
librenms_authlogRead LibreNMS authentication log entries.
librenms_list_alert_rulesList alert rules, including their expressions and status.
librenms_get_alert_ruleFetch one alert rule by id.

Safe writes (3, require confirm: true):

ToolWhat it does
librenms_ack_alertAcknowledge an active alert by id.
librenms_unmute_alertUnmute a previously muted alert.
librenms_set_maintenancePut a device into a maintenance window.

Configuration

Set the following env vars. Both credential vars are required.

VariableRequiredDefaultNotes
LIBRENMS_URLyes-Base URL of your LibreNMS instance. Trailing slashes are stripped.
LIBRENMS_TOKENyes-LibreNMS API token. Registered with the redactor on startup and masked from all output.
LIBRENMS_TLS_INSECUREnofalseSkip TLS cert validation for homelab self-signed certs. Accepts true/1/yes, case-insensitive.
LIBRENMS_REQUEST_TIMEOUT_MSno30000Per-request HTTP timeout in milliseconds. Minimum 1000. Raise for slow installations.

CLI

librenmsctrl is the read-only operator control CLI for shells, cron, and CI. It shares the LibreNMS client core with the MCP adapter and talks to the same /api/v0 API over token auth. It exposes only the read tools (tier 1). The confirm-gated writes (ack, set_maintenance, unmute) are intentionally not surfaced in the CLI.

# installed globally as `librenmsctrl`, or via `npx -p @solomonneas/librenms-mcp librenmsctrl ...`
librenmsctrl status                       # instance health (exit 1 if no system data)
librenmsctrl devices list --type down
librenmsctrl devices get core-sw1
librenmsctrl ports list core-sw1
librenmsctrl ports get 42
librenmsctrl ports health --metric errors_in --limit 10
librenmsctrl alerts list --state 1        # 0=ok, 1=active, 2=ack
librenmsctrl alerts list --severity critical --rule 49 --order "timestamp desc"
librenmsctrl alerts get 7
librenmsctrl alerts history --device-id 3 --limit 25 --from '2026-05-17 02:00:00' --to '2026-05-17 03:00:00' --start 200 --order DESC
librenmsctrl rules list --json
librenmsctrl rules get 42 --json
librenmsctrl events list --limit 50 --start 100
librenmsctrl syslog list --hostname switch1 --limit 50
librenmsctrl authlog list --limit 50
librenmsctrl --json status                # raw JSON for piping

For event and alert logs, --start skips that many rows. Date values for --from and --to use the LibreNMS server timezone.

Run librenmsctrl help for the full flag list. It reads the same LIBRENMS_URL, LIBRENMS_TOKEN, LIBRENMS_TLS_INSECURE, and LIBRENMS_REQUEST_TIMEOUT_MS env vars as the server. Exit codes: 0 success, 1 runtime error (LibreNMS unreachable, call failed, or status with no system data), 2 usage error (unknown command/flag or bad value).

Port health keeps the default errors_in metric and ranks ifInErrors_rate or ifOutErrors_rate in errors per second. The utilization metric uses combined inbound and outbound traffic: (ifInOctets_rate + ifOutOctets_rate) * 8 / ifSpeed * 100. Octet rates are bytes per second and ifSpeed is bits per second, so 62.5 MB/s on a 1 Gbps port is 50%. Combined full-duplex utilization can exceed 100%. These fields are available from the LibreNMS Ports API.

Tool and CLI JSON results retain the raw rate fields and add utilization_percent. Missing, invalid, negative, or non-finite inputs make the affected metric unavailable and sort it after valid zero. Zero or missing speed makes utilization unavailable (null in JSON, - in human output); it does not affect error-rate ranking. Sorting and limiting happen client-side.

Starting the MCP server

librenmsctrl mcp (or the back-compat librenms-mcp bin) starts the stdio MCP server unless LIBRENMS_MCP_TRANSPORT=http is set. If a launcher referenced the file path dist/mcp-server.js directly, point it at dist/mcp-bin.js (or dist/cli.js mcp). Launchers that use the librenms-mcp bin name need no change.

MCP client config

Copy-paste this into your MCP client. It is the canonical mcpServers shape used by Claude Desktop and Claude Code. Both LIBRENMS_URL and LIBRENMS_TOKEN are required.

{
  "mcpServers": {
    "librenms": {
      "command": "npx",
      "args": ["-y", "@solomonneas/librenms-mcp"],
      "env": {
        "LIBRENMS_URL": "https://librenms.example.local",
        "LIBRENMS_TOKEN": "<your-api-token>",
        "LIBRENMS_TLS_INSECURE": "false"
      }
    }
  }
}

Claude Code

claude mcp add librenms -s user -- npx -y @solomonneas/librenms-mcp

Then export LIBRENMS_URL and LIBRENMS_TOKEN in your shell (~/.bashrc, ~/.zshrc) or pass --env flags on the claude mcp add line.

Claude Desktop

Add the mcpServers block above to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows).

Codex CLI

~/.codex/config.toml:

[mcp_servers.librenms]
command = "npx"
args = ["-y", "@solomonneas/librenms-mcp"]

[mcp_servers.librenms.env]
LIBRENMS_URL = "https://librenms.example.local"
LIBRENMS_TOKEN = "<your-api-token>"
LIBRENMS_TLS_INSECURE = "false"

OpenClaw

The plugin loads automatically once installed. Config goes in your ~/.openclaw/openclaw.json under plugins.entries.librenms (or use the bundled openclaw.plugin.json):

{
  "plugins": {
    "entries": {
      "librenms": {
        "package": "@solomonneas/librenms-mcp",
        "activation": { "onStartup": true }
      }
    }
  }
}

Env vars from ~/.openclaw/workspace/.env are inherited by the plugin.

Safety

This MCP uses a three-tier write-gating pattern:

  • Tier 1 (reads): open. No confirm flag needed.
  • Tier 2 (safe writes): require an explicit confirm: true arg. The JSON schema documents this on every write tool. A tool call without the confirm flag throws WriteGateError before any HTTP traffic.
  • Tier 3 (destructive): not implemented in v1. When added, ops like device deletion, alert-rule removal, and bulk port resets will also require destructive: true.

Input validation: every tool call is validated against its published TypeBox inputSchema before the tool runs. Ids, port ids, device ids, limits, and the type/state filters are bounds- and enum-checked, so a malformed or injection-style argument (a non-integer id, an off-enum filter, an unexpected extra field) is rejected up front and never reaches a LibreNMS URL path or query string. Interpolated path and query values are URL-encoded as defense-in-depth.

API token scope: start with a "Read Only" token role in LibreNMS (Settings > API > New API Token > Read Only) and verify the read tools work end-to-end. Grade up to "Normal User" or "Global Read/Write" only after you have confirmed the redactor is masking your token in your transcripts and that the model is honoring the confirm gate. Tokens can be revoked instantly from the same Settings > API screen.

TLS: the LIBRENMS_TLS_INSECURE=true toggle exists for homelab self-signed certs. Leave it false in any environment with a real CA-signed cert.

HTTP responses: authenticated redirects are rejected. Configure the final LibreNMS API URL directly. The request deadline covers response headers and the entire body. Success and error bodies share a 10 MiB decoded byte cap. GET requests retain one retry for transport, malformed JSON, and server errors. Mutations are sent once because a failed response cannot prove the server did not apply the write. Check server state before manually repeating a failed write.

Returned data: device names, descriptions, alert text, syslog and event messages, object keys, and upstream errors are untrusted LibreNMS content. Embedded instructions do not authorize tool calls or writes. JSON output escapes marker characters in keys and values while preserving decoded fields and the existing result envelope. Truncation is reported by the output byte cap.

See SECURITY.md for the vulnerability-reporting policy.

How does the MCP adapter constrain API access?

You can hand an agent a generic HTTP tool and the LibreNMS API token, and for read-only exploration that works. The difference shows up the moment a write is possible:

  • No write gate. A generic HTTP tool will happily PUT or DELETE whatever the model decides to send. librenms-mcp refuses every write unless the call carries confirm: true, and refuses destructive shapes entirely in v1.
  • No input validation. A raw API tool passes whatever the model produced straight into a URL. librenms-mcp bounds- and enum-checks every argument against a published schema and URL-encodes interpolated values before any request is built.
  • Token leakage. A generic tool echoes request and response detail, including your token, into the transcript. librenms-mcp registers the token with a redactor on startup and masks it from all log and error output.
  • Shaped tools beat one giant endpoint. Seventeen named, described tools give the model a far better surface to reason over than one call this REST API tool with a free-form path argument.

What librenms-mcp is not

  • It is not a LibreNMS replacement or a poller. It reads an existing LibreNMS instance over the API. It does not collect SNMP itself.
  • It is not a dashboard. It returns structured tool data for an agent. For a NOC dashboard view, see watchtower.
  • It does not delete devices, remove alert rules, or do bulk port resets. Tier-3 destructive operations are deliberately absent in v1.
  • It is not a hosted service. It runs locally over stdio, talks only to the LibreNMS URL you configure, and starts no daemon.

Why not other LibreNMS MCP servers or direct API scripts?

ToolRuntimeCLI + MCP in one packageWrite safety for AI agents
librenmsctrlNode.js / TypeScript (npx)Yes (librenmsctrl + librenms-mcp)Writes gated behind explicit flags so an agent cannot mute alerts silently
mhajder/librenms-mcpPythonMCP onlyRead/query focused
clearminds/clr-librenms-mcpPythonMCP onlyRead-only
Custom curl scriptsShellScripts onlyManual auth and parsing

Pick a Python-only wrapper if your shop standardizes strictly on Python. Pick librenmsctrl if you want one TypeScript package that serves both cron/shell scripts (librenmsctrl) and stdio MCP clients (librenms-mcp) with explicit write gates.

FAQ

Can an AI agent acknowledge or mute a LibreNMS alert without approval? No. Alert acknowledgements, maintenance windows, and other write verbs require explicit write enablement and confirmation flags.

Does librenmsctrl work with Claude Code, Claude Desktop, Cursor, and Codex? Yes. Run npx -y @solomonneas/librenms-mcp over stdio with LIBRENMS_URL and LIBRENMS_API_TOKEN.

Does librenmsctrl pair with a visual NOC dashboard? Yes. Pair it with watchtower for a live LibreNMS + Proxmox topology dashboard and cutsheet for switch/firewall config diff risk analysis.

Part of Lidless Labs

librenmsctrl is maintained by Lidless Labs (GitHub). Related network and homelab tools:

  • watchtower - self-hosted NOC dashboard for LibreNMS and Proxmox VE
  • cutsheet - self-hosted network config diff and risk analysis (Oxidized alternative)
  • proxmox-mcp - Proxmox VE MCP server and CLI with gated writes
  • adguardctrl - AdGuard Home DNS CLI and MCP server with confirm-gated writes
  • n8nctrl - n8n workflow inspection, validation, and ops over CLI and MCP

Contributing

Patches welcome. See CONTRIBUTING.md for what lands easily, CODE_OF_CONDUCT.md, and the issue and PR templates under .github/. All public output should be scrubbed of personal hostnames, tokens, and real IPs.

License

MIT.


Part of Lidless Labs · the eye does not close

Network: n8nctrl · watchtower · portgrid · cutsheet · eero-cli

All tools · Lidless Labs on GitHub

CLI API results and errors are labeled as untrusted LibreNMS data, escape display controls and delimiters, and fit within 64 KiB. JSON results include _external_data_notice. Oversized JSON results return truncated: true in place of the payload. Consumers should check that flag before using a result. API credentials are registered for redaction when a client is constructed.