casper-network-mcp
# casper-network-mcp
One small MCP server for HPE Aruba Networking Central, Juniper Mist and HPE Aruba Networking ClearPass, built for
[Casper](https://github.com/Choaterboater/casper). Your AI sees four tools; behind them are about 3,900 tools for the
three products, each one labelled with the kind of change it makes.
You normally never install this yourself: Casper sets it up, pins the exact version and starts it for you.
## What it does
| Tool | What it is for |
| --- | --- |
| `find_tool` | Finds the right tool for what you asked ("bounce port 7 on the closet switch") and says what kind of change it makes: read, troubleshoot, config, disruptive, firmware, delete or admin. |
| `invoke_read_tool` | Runs a tool that only reads, or a non-disruptive troubleshooting check (ping, show). Anything else is refused. Show-only checks are labelled `read`; ping and traceroute are labelled `diagnostic`. |
| `invoke_tool` | Runs any tool, including ones that change your network. Casper asks you first. |
| `access_check` | Says, for each product, whether a login is set and where that login can change things. |
Behind them:
- hand-written tools for everyday work (sites, clients, alarms, switch ports, guests, sessions, SSIDs, VLANs and
more), each one checked against the vendor's own API description;
- one generated tool for every operation in the bundled API descriptions;
- overview tools for broad questions: `central_site_overview`, `mist_site_overview` and `clearpass_overview` give
health, device counts and the top alarms in one read;
- `clearpass_why_denied` summarizes recent sessions, endpoint status/profile, NAD and applied roles for exactly
one MAC or username. The bundled 6.12.7 API exposes active accounting sessions, not full Access Tracker
rejects; without the Access Tracker database login, missing auth results, reject reasons and enforcement
profiles remain unknown. With it, the latest Access Tracker records are added;
- `clearpass_access_tracker` reads Access Tracker itself for one MAC or username: accept or reject, the error code
and its text (206 Access denied by policy, 215 TLS session error), alerts, auth type, roles, enforcement
profiles and NAD, newest first, over the last `hours` (1-720, default 24) with up to `limit` records (1-100,
default 10). No ClearPass API has Access Tracker, so it reads ClearPass's own database as its read-only
`appexternal` user (see Logins); it only ever runs fixed `SELECT`s;
- AOS 8 (ArubaOS 8 Mobility Conductor or Mobility Controller), read only: `aos8_find_client` (MAC, IP or
username), `aos8_get_client_detail` (role and how it was derived, VLAN, auth method and RADIUS server),
`aos8_get_client_history`, `aos8_auth_trace` (the controller's 802.1X / RADIUS trace for one MAC: rejects,
timeouts), `aos8_list_aaa_profiles` and `aos8_list_aaa_servers` (which RADIUS servers, often ClearPass, a profile
uses), user roles, a short list of auth config objects, and `aos8_show_command`, which runs only allow-listed
`show` commands;
- ClearPass session and auth-failure reads accept MAC, username, NAD IP, accounting service type and ISO 8601
start/end times (with timezone). Time windows scan at most ten pages locally; `next_server_offset` continues
a scan, including an empty page. The service filter is not an Access Tracker policy service name;
- `lookup_api`, which answers exact questions about the vendors' APIs (endpoints, fields, allowed values) from the
bundled documents, with no network.
- `get_device_config_management` says in one read whether new Central manages a device's configuration (a device
group, config health tracking it) or not; inventory labels such as provisioned, device function and site are not
proof, and the answer shows which evidence it used;
- `busy_hours` profiles a site hour by hour over up to a month (client counts, or a switch uplink's traffic) in your
time zone and names the quietest window for planned downtime.
## Site-wide answers in one call
`invoke_read_tool` can shape a reply before it reaches the AI, so a question about every AP or every client is one
call, not a page loop:
| Option | What it does |
| --- | --- |
| `all_pages` | Follows the tool's own paging (`next` / `next_cursor`, `offset`, Mist `page`) up to 50 pages or 10,000 items, and joins the pages. `_pages` says how many were read and whether the list is complete. |
| `fields` | Keeps only these keys of each item; `radio.channel` reaches inside an object. |
| `group_by` | Returns a count per value of one field instead of the items. |
For example `{"name": "central_get_device_inventory_v1", "arguments": {}, "all_pages": true, "group_by": "status"}`
answers "how many devices are in each state" for a whole account. Shaping is for reads only,
so a repeated call never repeats a change.
## Running it
```
uvx --from casper-network-mcp==0.1.7 casper-network-mcp --read-only
```
| Option | Meaning |
| --- | --- |
| `--read-only` | Only read and run checks; never send a change. Read once at start: nothing turns writes on while it runs. Casper passes this until you allow changes. |
| `--transport stdio` | The default: talk over standard input and output. |
| `--transport http --port 8010` | Listen on this machine only (`127.0.0.1`). |
From a checkout, `.mcp.json.example` starts it read-only with `uv run`; logins come from your shell.
## Logins
The server reads only these variables from the environment Casper starts it with. It reads no settings files.
Leave out a product you do not use: the server still starts, `access_check` says that login is missing, and a call
to one of its tools answers `{"error": "login_missing", "product": "..."}`.
| Product | Variables |
| --- | --- |
| Juniper Mist | `MIST_API_TOKEN` (or `MIST_APITOKEN`, mistapi's name), and `MIST_HOST` if your cloud is not `api.mist.com` |
| HPE Aruba Networking Central | `CENTRAL_BASE_URL`, `CENTRAL_CLIENT_ID`, `CENTRAL_CLIENT_SECRET`; more accounts as `CENTRAL_<NAME>_BASE_URL`, `CENTRAL_<NAME>_CLIENT_ID`, `CENTRAL_<NAME>_CLIENT_SECRET` |
| HPE Aruba Networking ClearPass | `CLEARPASS_BASE_URL`, and `CLEARPASS_CLIENT_ID` with `CLEARPASS_CLIENT_SECRET` or a pasted `CLEARPASS_API_TOKEN` |
| ClearPass Access Tracker (optional) | `CLEARPASS_DB_PASSWORD`; and only if not the defaults: `CLEARPASS_DB_HOST` (the host in `CLEARPASS_BASE_URL`), `CLEARPASS_DB_USER` (`appexternal`), `CLEARPASS_DB_LOGS_PORT` (5433), `CLEARPASS_DB_CONFIG_PORT` (5432) |
| HPE Aruba Networking UXI | `UXI_CLIENT_ID`, `UXI_CLIENT_SECRET` (a GreenLake personal API client for the UXI service); `UXI_BASE_URL` only if not `https://api.capenetworks.com` |
| AOS 8 (Mobility Conductor or Controller) | `AOS8_BASE_URL` (`https://<conductor>:4343`), `AOS8_USERNAME`, `AOS8_PASSWORD` (a read-only management user is enough) |
| HPE OpsRamp | `OPSRAMP_BASE_URL` (`https://<tenant>.api.opsramp.com`), `OPSRAMP_TENANT_ID`, `OPSRAMP_CLIENT_ID`, `OPSRAMP_CLIENT_SECRET` (a custom integration's OAuth2 key and secret) |
For ClearPass, an API client is best: the server logs in with it and gets a new token before the old one runs out.
In ClearPass Guest, open Administration > API Services > API Clients, create a client with grant type Client
Credentials and an operator profile that allows what you want Casper to do, and set its client ID and secret. If
`CLEARPASS_API_TOKEN` is set it is used as is and the client ID and secret are ignored.
Access Tracker is not in any ClearPass API, so `clearpass_access_tracker` reads it from ClearPass's database as
`appexternal`, ClearPass's built-in read-only database user. Set its password in ClearPass under Administration >
Server Manager > Server Configuration > Change Password (user `appexternal`) and put the same value in
`CLEARPASS_DB_PASSWORD`. Records come from the logs database (`tipsLogDb`, port 5433) and error-code text from the
config database (`tipsdb`, port 5432); both ports must be reachable from where the server runs. If the error-code
text can't be read, records keep the numeric code. Each call opens its own connections and closes them, marks the
session read-only and stops any query after 15 seconds. TLS is tried first; only a server that refuses TLS is read
over a plain connection, and the reply's `transport` says which. ClearPass's database certificate is its own, so
it is not checked. Without the password the tool answers `login_missing` with what to set, and `access_check`
reports ClearPass's `access_tracker` as `missing`.
For AOS 8 the server logs in to the controller's REST API (`POST /v1/api/login`), keeps the session id
(`UIDARUBA`) and its cookie in memory, reuses that one session (controllers allow only a few), logs in again once
when the controller answers 401, and logs out (`GET /v1/api/logout`) when it stops. The session id, the cookie and
the password never appear in a reply or an error. Point `AOS8_BASE_URL` at the Mobility Conductor or straight at a
managed controller; a Conductor holds no clients itself, so client searches fall back to its global user table.
The controller's certificate is checked like every other product's: a self-signed or private-CA certificate needs
that CA trusted, for example with `SSL_CERT_FILE`. `access_check` reports AOS 8 as `unknown` (the API has no call
that says what a login may change) after one `show version`, with `reads: ok`, or `login: expired` when the login
is turned away.
A second Central account (a customer's temporary key, a lab) needs no second server. Set
`CENTRAL_TEMP_BASE_URL`, `CENTRAL_TEMP_CLIENT_ID` and `CENTRAL_TEMP_CLIENT_SECRET` and the login is called `temp`.
`access_check` lists it under Central's `named_logins`, and `invoke_read_tool` or `invoke_tool` with `"login":
"temp"` runs that one call as it; without `login` the main account answers. Names are letters and digits. The
`--read-only` pin covers every login. Remove the variables when the key is retired.
A Central login here is a GreenLake API client, so it reaches new Central only: Classic Central's API
(`apigw-*.central.arubanetworks.com`) does not accept GreenLake tokens, and `access_check` says so.
ClearPass API tokens expire (the API client's token lifetime in ClearPass sets when); a pasted token is not renewed.
When a product turns a login away (HTTP 401), `access_check` reports that product with `"login": "expired"` and a
call to one of its tools returns `{"error": "login_expired", "product": ...}`, so the client can ask you for a new one.
## Changes to your network
There are no write switches. What a login may do is set by its role in the product, and Casper asks you before
every change, showing the tool and what it changes. On top of that:
- `--read-only` refuses every change before anything is sent;
- a path piece that could reach somewhere else (`/`, `?`, `#`, `..`) is refused before anything is sent;
- when the server knows a Mist login can only read a site, a change to that site is refused before anything is
sent;
- tools that disrupt the network (cable tests, reboots, port and PoE bounces, disconnects) require `invoke_tool`
and are labelled disruptive, so Casper
asks every time;
- show-only checks (LLDP neighbours, ARP and MAC tables, port counters, spanning tree, `cx_show` and the other
show tools, which refuse anything but one-line `show` commands) are reads: kind `troubleshoot`, label `read`,
no box in Casper. Ping, traceroute and other checks that send traffic from the device keep the `diagnostic`
label, so Casper still asks;
- tokens, passwords and pre-shared keys are hidden in replies and errors (AOS 8 session ids and cookies too);
- AOS 8 is read only: every tool sends `GET`; `aos8_show_command` refuses anything that is not one allow-listed
`show` command (no `;`, `|` or new lines, nothing that shows the running config or a secret);
- the ClearPass Access Tracker database is only read: fixed `SELECT`s with every value passed as a parameter, as
the read-only `appexternal` user, in a read-only session.
The server never asks you to type anything and never treats an argument the AI sets as your approval. Approval is
Casper's box only.
## Compact Mist discovery diagnostics
For AirPrint, Bonjour or mDNS problems, find `mist_wlan_discovery_summary` with
`find_tool("AirPrint discovery", product="mist", include_schema=True)`, then call it with
`{"ssid": "Example"}`. Add `site_id` or `org_id` when known to skip scope lookups.
It returns exact SSID matches, VLAN, isolation, mDNS/SSDP filtering and Bonjour service evidence,
including template-derived WLANs, without dumping clients or full site settings. The same evidence helps
investigate Sonos and AirPlay discovery, but does not verify playback or cross-VLAN reachability.
Automatic scope discovery is limited to 10 sites (at most four concurrent WLAN reads).
Multiple orgs, larger scopes and duplicate SSIDs require explicit target selection;
incomplete reads are reported, never treated as a healthy network or an absent SSID.
This tool only reads: findings do not confirm printer reachability or trigger a change.
`mist_list_wlans` also includes discovery settings so a separate full WLAN read is often unnecessary.
See [implementation and validation notes](docs/mist-discovery-diagnostics.md) for usage, limitations,
the two-MCP-call offline regression scenario and Sonos/AirPlay follow-up evidence.
## Failures and recovery
API failures keep their existing `error`, `status`, `detail`, `request_id` and `url` fields, and add
`code` and `guidance`: `permission_denied` for 403, `rate_limited` for 429, `upstream_error` for 5xx,
and `api_error` otherwise. A valid `Retry-After` header also supplies `retry_after_seconds`.
The existing `login_missing` and `login_expired` replies are unchanged.
Transport failures report `timeout` or `connection_error`. After a write timeout, the outcome is unknown:
check the target's current state before retrying. Writes are never resent automatically, including after
401; renewable logins refresh and resend only plain reads.
## How well find_tool finds tools
`find_tool` was measured on a fixed set of 60 plain questions (20 each for Central, Mist and ClearPass, in
`tests/bench/find_tool_questions.yaml`), then tuned one change at a time. A change stayed only if it found more
right tools in the top 3, or answered faster without finding fewer. Run `uv run python scripts/bench_find_tool.py`
to measure it yourself.
| | Right tool first | Right tool in top 3 | Top 3, no product given | Time per question (p50 / p95) | First question in a new process |
| --- | --- | --- | --- | --- | --- |
| Before | 67% | 77% | 68% | 0.6 / 1.6 ms | 3.4 s |
| After | 85% | 100% | 90% | 0.6 / 2.0 ms | 0.4 s |
What changed, in order:
1. Synonyms (`router/synonyms.yaml`) and plural folding: "access point" finds `ap`, "kick" finds disconnect, "who is
on" finds clients. Top 3: 77% to 97%.
2. Ranking by what the question asks: "what" and "show" prefer tools that read, "create", "delete" and "change"
prefer those changes; the product name in a tool's name no longer counts against it. Top 3: 97% to 98%, first
pick 75% to 87%. (Weighting name words over description words was tried and dropped: top 3 fell to 90-95%.)
3. A prebuilt word index shipped in the package (`router/index.json`): the first question no longer loads every
tool. First question: 3.4 s to 0.4 s.
4. Overview tools for broad questions (`central_site_overview`, `mist_site_overview`, `clearpass_overview`: health,
device counts and top alarms in one read) and `mist_list_site_clients` for "who is on the wifi". A synonym that
spreads into several words ("wifi" to wlan, ssid, wireless) now counts once. Top 3: 98% to 100%.
Times are on a laptop with the router already loaded, except the last column.
### First-pick follow-up
A later offline comparison uses merged PR #12 (`72e41ce`) as its baseline. The original
75-question held-out dataset was unavailable; these are **36 new synthetic evaluation questions**
(12 per product), frozen before router edits. Only aggregate evaluation baseline scores were inspected
before tuning; evaluation misses were not used. This small sample is not evidence of equivalent gains
on real requests or on the original 75 questions.
The additional 30-question development set exposed a general parsing error: a leading product name
or alias hid the following action verb. `find_tool` now skips those prefixes when reading intent.
Scoring weights, candidate retrieval, tool summaries, the shipped index and dependencies are unchanged.
| Product | First, filtered | Top 3, filtered | First, unfiltered | Top 3, unfiltered | MRR, filtered |
| --- | --- | --- | --- | --- | --- |
| Central | 10/12 → 12/12 | 11/12 → 12/12 | 10/12 → 12/12 | 11/12 → 12/12 | 0.8869 → 1.0000 |
| Mist | 10/12 → 11/12 | 12/12 → 12/12 | 9/12 → 10/12 | 12/12 → 12/12 | 0.9167 → 0.9583 |
| ClearPass | 10/12 → 11/12 | 12/12 → 12/12 | 10/12 → 11/12 | 12/12 → 12/12 | 0.9028 → 0.9583 |
Top-ten accuracy remains 12/12 for every product in both modes. Warm filtered top-three p50/p95
was 0.72/5.37 ms before and 0.80/5.95 ms after in this local measurement, below the unchanged 50 ms
p95 limit. The original 60-question benchmark's per-product accuracy is unchanged in both modes;
its p50/p95 was 0.51/2.27 ms before and 0.53/2.29 ms after. Timings are descriptive, not portable
speed guarantees.
Two filtered evaluation first-pick failures remain: `"show WLAN security for one WLAN"` and
`"show every authentication service"`; each acceptable answer is second. Unfiltered evaluation also
prefers Central's overview for `"show the site health overview"`. No further tuning used these misses.
The new development set also exposes a limitation: without a product filter, `"mist restart an access point"`
drops out of the top three (Mist unfiltered development top-three: 11/11 → 10/11). These measurements
predate the product-routing fix: an unambiguous product name or alias now restricts plain-language results
to that product when no explicit filter is supplied. Explicit filters and exact API matches take precedence;
requests naming several products remain unfiltered.
The benchmark now reports every wrong-first result with its expected rank, separately from top-three
misses, plus per-product filtered/unfiltered top-one, top-three, top-ten and MRR:
```
uv run python scripts/bench_find_tool.py --questions tests/bench/find_tool_evaluation.yaml
uv run python scripts/bench_find_tool.py --questions tests/bench/find_tool_evaluation.yaml --json
```
Dataset provenance, development failure categories and frozen baseline hashes are in
[`tests/bench/README.md`](tests/bench/README.md). This evaluation set is now regression data; another
tuning cycle needs a fresh evaluation set. Tests guard each product's first/top-three scores independently,
so improvements elsewhere cannot conceal regressions.
## What is in the package
The package includes HPE's proprietary API documents (not MIT; see specs/NOTICE.md) and Juniper Mist's MIT
OpenAPI file. They are stored exactly as the vendors serve them; `scripts/refresh_specs.py --check` fetches them
again and confirms every hash. See `NOTICE.md` and `THIRD_PARTY_NOTICES.md`.
The package has no install step, downloads nothing when it starts and never updates itself.
## Agent skill
`skills/device-troubleshoot/SKILL.md` is an agent skill for asking about one device or user ("why can't this MAC
connect?"). It checks Mist, Central or AOS 8 first, then ClearPass, using only this server's read tools, and answers with
a timeline and root cause. Copy the folder into your agent's skills directory (for example `~/.agents/skills/`).
It is not part of the Python package.
## Working on it
```
uv sync
uv run pytest -q
uv run ruff check .
uv run python scripts/bench_find_tool.py # find_tool accuracy and speed
uv run python scripts/build_manifests.py # after the bundled specs change
uv run python scripts/build_index.py # after any tool changes
```
A release is built from a `v*` tag: the wheel, then `casper-network-mcp.lock.txt` (every dependency pinned by hash,
plus this package pinned to the wheel's own hash, made by `scripts/make_lock.py`). The release checks that lock
installs with Casper's exact command before publishing:
```
uv pip install --require-hashes --no-deps --only-binary :all: -r casper-network-mcp.lock.txt
```
## Security
Report problems privately; see `SECURITY.md`.
## Licence
MIT for this project's code (`LICENSE`). The bundled vendor documents keep their own terms (`NOTICE.md`).
TDQS
Scored across 4 tools
The workflow is clearly staged: find_tool discovers, access_check reports permissions, and the two invoke tools execute. The only fuzzy boundary is invoke_read_tool vs invoke_tool, since invoke_tool claims to run 'any tool from find_tool', including reads, but the read variant's extra pagination/field/group_by options make the intended split understandable.
All names are snake_case and readable, with two clear verb_verb_noun pairs (invoke_read_tool, invoke_tool) and find_tool. access_check breaks the verb_noun pattern by being noun-first, a minor deviation rather than a real inconsistency.
Four tools is a sensible fixed facade for a gateway that multiplexes six products via dynamic discovery. There is slight redundancy in having invoke_tool capable of doing everything invoke_read_tool does, but the extra read-only conveniences justify keeping both.
Discovery, permission inspection, schema retrieval (include_schema), pagination, and both safe and destructive execution are all covered, which is solid for a meta-server. Gaps are minor: there is no way to enumerate all available tools or list by product without a free-text query, and no login/credential management beyond naming a login.