使用说明
NetworkManager MCP Server
A Model Context Protocol (MCP) server for NetworkManager.
Usage
go build -o mcp-server-nm .
./mcp-server-nm
Tools
Read-only
get_connectivity- global network connectivity stateget_devices- list network devices (interface, type, state, MAC address)get_connections- list configured connection profiles with IPv4/IPv6 configget_hostname- persistent system hostnamelist_checkpoints- list active NetworkManager checkpoints, system-wide
Mutating
set_connection_state- activate or deactivate a connection profile by UUIDadd_connection- create a new connection profilemodify_connection- update an existing connection profile by UUIDdelete_connection- delete a connection profile by UUIDset_hostname- set the persistent system hostnamecreate_checkpoint- manually create a NetworkManager checkpointdestroy_checkpoint- destroy a checkpoint by its object path
Safety features
Mutating operations that can affect connectivity (set_connection_state, modify_connection, delete_connection) run through a transaction wrapper that:
- Creates a NetworkManager checkpoint before applying any change, scoped to the device(s) the change actually affects (falling back to every device if that can't be determined), so it can be rolled back.
- Verifies the MCP session is still responsive after the change; if not, the change is rolled back automatically.
- Compares connectivity before and after the change. If connectivity has degraded and the client supports elicitation, the user is prompted to confirm or roll back the change. If the client doesn't support elicitation, the change is kept but a warning is included in the response.
- Rolls back the checkpoint if an unexpected error occurs while applying the change.
Since NetworkManager won't let a device belong to two checkpoints at once, a mutating tool can fail with a "device already included in checkpoint" error if a stale checkpoint from a crashed process (or another tool entirely) still holds one of the relevant devices. Use list_checkpoints to inspect what's currently active and destroy_checkpoint to clear one out if it's stale, then retry.