mcp-netalertx
# mcp-netalertx
<!-- mcp-name: io.github.je-bin/mcp-netalertx -->
## Publishing to the MCP Registry
This server is registered as `io.github.je-bin/mcp-netalertx` in the [MCP Registry](https://registry.modelcontextprotocol.io/).
`server.json` holds the registry metadata, and the `mcp-name` marker above is what the registry
checks to prove ownership of the published package.
To publish a new version:
1. Create the package on [PyPI](https://pypi.org) and configure *Trusted Publishing* for this
repository and the `publish-mcp.yml` workflow.
2. Bump the version in `pyproject.toml` (or `server.json`) and tag the release (`git tag vX.Y.Z`).
3. Push the tag: the workflow publishes to PyPI and then to the MCP Registry.
An [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server that gives an AI
assistant a **read-only view of the network inventory** kept by
[NetAlertX](https://github.com/netalertx/NetAlertX), my homelab asset-discovery and monitoring
tool.
The bridge speaks to the NetAlertX HTTP API and exposes 12 tools: the devices it knows, the
network topology, the open ports it recorded, the events and sessions it logged, system health —
plus two operational helpers, triggering a network scan and sending a Wake-on-LAN packet.
**Nothing that deletes data is exposed.**
> **NetAlertX is the upstream project**: <https://github.com/netalertx/NetAlertX>. This repository
> is only a bridge: it contains no NetAlertX code and talks to NetAlertX through its documented
> HTTP API. NetAlertX itself ships its own native MCP endpoint (SSE) — this bridge is a lighter,
> stdio-based, read-only alternative that you can point at any MCP client.
## Features
| Tool | What it does |
| --- | --- |
| `netalertx_check_auth` | Check that the configured API token is valid |
| `netalertx_list_devices` | List the known devices, optionally filtered by status |
| `netalertx_get_device` | Full detail of one device, by MAC address |
| `netalertx_get_open_ports` | Open ports recorded by the last NMAP scan, for an IP or MAC |
| `netalertx_get_network_topology` | Topology of the monitored network: nodes and links |
| `netalertx_get_device_totals` | Counters: total, connected, down, new, favorites, archived |
| `netalertx_list_recent_events` | Events of the last hours (connect, disconnect, new device…) |
| `netalertx_list_sessions` | Connection sessions, optionally for one device or one period |
| `netalertx_get_system_health` | Health of the NetAlertX host: database, memory, load, disk, CPU |
| `netalertx_get_network_interfaces` | Network interfaces of the NetAlertX host and their addresses |
| `netalertx_trigger_network_scan` | Trigger a network scan (ARPSCAN, NMAP, NMAPDEV, INTRNT, AVAHISCAN, NBTSCAN) |
| `netalertx_wake_on_lan` | Send a Wake-on-LAN magic packet to a device |
## Requirements
- Python 3.10+
- `mcp` 2.3.0 or later (provides `mcp.server.mcpserver.MCPServer`)
- A running NetAlertX instance whose HTTP API is reachable, and an API token
## Installation
```bash
git clone https://github.com/Je-Bin/mcp-netalertx.git
cd mcp-netalertx
python3 -m venv .venv
. .venv/bin/activate
pip install .
```
For a checkout without installing the package:
```bash
pip install -r requirements.txt # or: pip install "mcp>=2.3.0"
python -m mcp_netalertx.server
```
## Configuration
Everything is configured through environment variables:
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `NETALERTX_URL` | recommended | `http://localhost:20212` | Base URL of the NetAlertX API server. `20212` is the default API port of the official image (`GRAPHQL_PORT`); some deployments publish it behind nginx on `20211` under `/api/`. |
| `NETALERTX_TOKEN` | **yes** | *(empty)* | The NetAlertX API token, sent as `Authorization: Bearer <token>`. If it is missing, every tool returns an explicit configuration error instead of sending an unauthenticated request. |
| `NETALERTX_TIMEOUT` | no | `30` | Request timeout in seconds. |
The token is generated in the NetAlertX UI (**Settings → API**) or with the `apitoken` CLI
command. It is only ever read from the environment: it is never written to disk, never logged
and never passed on the command line.
### Example MCP client configuration
```json
{
"mcpServers": {
"netalertx": {
"command": "/path/to/mcp-netalertx/.venv/bin/mcp-netalertx",
"env": {
"NETALERTX_URL": "http://localhost:20212",
"NETALERTX_TOKEN": "<your api token>"
}
}
}
}
```
### Running it manually
```bash
NETALERTX_URL=http://localhost:20212 NETALERTX_TOKEN='<your api token>' mcp-netalertx
```
The server speaks MCP over stdio, so it stays silent until a client talks to it.
## Tools in action
A typical conversation looks like this:
```text
You: which devices are currently down?
Assistant: (calls netalertx_list_devices with status="down")
```
```json
{
"tool": "netalertx_list_devices",
"arguments": { "status": "down", "limit": 20 }
}
```
```json
{
"devices": [
{
"devMac": "aa:bb:cc:dd:ee:ff",
"devName": "printer",
"devIp": "192.0.2.42",
"devStatus": "offline",
"devType": "printer",
"devVendor": "Example"
}
]
}
```
Other examples:
```json
{ "tool": "netalertx_check_auth", "arguments": {} }
```
```json
{ "tool": "netalertx_get_device", "arguments": { "mac": "aa:bb:cc:dd:ee:ff" } }
```
```json
{ "tool": "netalertx_get_network_topology", "arguments": {} }
```
```json
{ "tool": "netalertx_get_open_ports", "arguments": { "target": "192.0.2.42" } }
```
```json
{ "tool": "netalertx_get_device_totals", "arguments": {} }
```
```json
{ "tool": "netalertx_list_recent_events", "arguments": { "hours": 24, "limit": 50 } }
```
```json
{ "tool": "netalertx_list_sessions", "arguments": { "mac": "aa:bb:cc:dd:ee:ff" } }
```
```json
{ "tool": "netalertx_get_system_health", "arguments": {} }
```
```json
{ "tool": "netalertx_trigger_network_scan", "arguments": { "scan_type": "ARPSCAN" } }
```
```json
{ "tool": "netalertx_wake_on_lan", "arguments": { "dev_mac": "aa:bb:cc:dd:ee:ff", "ip": "192.0.2.42" } }
```
## Security
- **Read-only by design.** The bridge only calls GET routes of the NetAlertX API, plus the two
operational routes `/nettools/trigger-scan` and `/nettools/wakeonlan`. The NetAlertX routes
that delete devices, events, sessions, notifications or database rows are never called and are
not exposed as tools.
- **The token is never embedded in the code.** It is read from the `NETALERTX_TOKEN` environment
variable, which has **no default value**. When the variable is missing or empty, the tools
return a clear, actionable configuration error and no request is sent to NetAlertX.
- **No secret in the logs.** Errors returned by NetAlertX are truncated to 400 characters and are
forwarded verbatim; the token is never part of an error message and is never echoed back.
- **Least privilege on the NetAlertX side.** NetAlertX API tokens are per-instance; keep the API
bound to the local network or behind a reverse proxy with TLS.
- **Local transport.** The server communicates over stdio with the MCP client: it opens no
listening socket on your network.
- **No arbitrary code execution.** The bridge only performs HTTP requests against the configured
NetAlertX URL; it never runs shell commands and never touches the file system.
## License
MIT — see [LICENSE](LICENSE).
NetAlertX is a separate project licensed under the GPL-3.0; it is not part of this repository.
TDQS
Scored across 12 tools
Each tool targets a distinct resource or action, and the read tools (devices, ports, sessions, events, topology, health, interfaces) are clearly separated. The only mild overlaps are netalertx_list_devices vs netalertx_get_device_totals (inventory vs counters) and netalertx_get_network_interfaces vs netalertx_get_network_topology, but descriptions make the distinction clear.
Every tool uses the netalertx_ prefix followed by a consistent verb_noun pattern (list_devices, get_device, trigger_network_scan, wake_on_lan). No camelCase or style mixing; names are predictable and readable.
Twelve tools is well within the ideal range and every tool covers a distinct facet of the NetAlertX domain (auth, inventory, ports, sessions, events, topology, health, interfaces, scans, WoL). Nothing feels redundant or padded.
Read coverage is strong and two operational actions (scan trigger, Wake-on-LAN) exist, but the write/lifecycle surface is notably thin: no way to favorite, archive, rename, or delete a device, and no event acknowledgement or alert/notification rule management. Agents can inspect and trigger scans but cannot mutate inventory or alert state.