NetworkManager MCP服务器

一个用于管理NetworkManager网络连接的模型上下文协议服务器,提供只读查询和安全的连接配置变更功能。

  • by jcronenberg
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 jcronenberg/nm-mcp-server

使用说明

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 state
  • get_devices - list network devices (interface, type, state, MAC address)
  • get_connections - list configured connection profiles with IPv4/IPv6 config
  • get_hostname - persistent system hostname
  • list_checkpoints - list active NetworkManager checkpoints, system-wide

Mutating

  • set_connection_state - activate or deactivate a connection profile by UUID
  • add_connection - create a new connection profile
  • modify_connection - update an existing connection profile by UUID
  • delete_connection - delete a connection profile by UUID
  • set_hostname - set the persistent system hostname
  • create_checkpoint - manually create a NetworkManager checkpoint
  • destroy_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.