|
| 1 | +MCP Server |
| 2 | +========== |
| 3 | + |
| 4 | +The NetBird Python Client includes a built-in `Model Context Protocol <https://modelcontextprotocol.io>`_ (MCP) server that exposes 25 NetBird management tools to AI assistants like `Claude Desktop <https://claude.ai>`_. |
| 5 | + |
| 6 | +This lets you manage your NetBird network through natural language — no scripting required. |
| 7 | + |
| 8 | +Installation |
| 9 | +------------ |
| 10 | + |
| 11 | +The MCP server requires the optional ``mcp`` dependency: |
| 12 | + |
| 13 | +.. code-block:: bash |
| 14 | +
|
| 15 | + pip install "netbird[mcp]" |
| 16 | +
|
| 17 | +Configuration |
| 18 | +------------- |
| 19 | + |
| 20 | +The server reads credentials from environment variables: |
| 21 | + |
| 22 | +.. list-table:: |
| 23 | + :header-rows: 1 |
| 24 | + :widths: 30 70 |
| 25 | + |
| 26 | + * - Variable |
| 27 | + - Description |
| 28 | + * - ``NETBIRD_HOST`` |
| 29 | + - NetBird API host (e.g. ``api.netbird.io`` or ``netbird.yourcompany.com``) |
| 30 | + * - ``NETBIRD_API_TOKEN`` |
| 31 | + - Personal Access Token from the NetBird dashboard |
| 32 | + |
| 33 | +Claude Desktop Setup |
| 34 | +-------------------- |
| 35 | + |
| 36 | +Add the following to your Claude Desktop configuration file: |
| 37 | + |
| 38 | +- **macOS**: ``~/Library/Application Support/Claude/claude_desktop_config.json`` |
| 39 | +- **Windows**: ``%APPDATA%\Claude\claude_desktop_config.json`` |
| 40 | + |
| 41 | +.. code-block:: json |
| 42 | +
|
| 43 | + { |
| 44 | + "mcpServers": { |
| 45 | + "netbird": { |
| 46 | + "command": "netbird-mcp", |
| 47 | + "env": { |
| 48 | + "NETBIRD_HOST": "api.netbird.io", |
| 49 | + "NETBIRD_API_TOKEN": "your-api-token" |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | +
|
| 55 | +Restart Claude Desktop after saving. You should see NetBird tools available in the conversation. |
| 56 | + |
| 57 | +Self-Hosted NetBird |
| 58 | +~~~~~~~~~~~~~~~~~~~ |
| 59 | + |
| 60 | +.. code-block:: json |
| 61 | +
|
| 62 | + { |
| 63 | + "mcpServers": { |
| 64 | + "netbird": { |
| 65 | + "command": "netbird-mcp", |
| 66 | + "env": { |
| 67 | + "NETBIRD_HOST": "netbird.yourcompany.com", |
| 68 | + "NETBIRD_API_TOKEN": "your-api-token" |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | +
|
| 74 | +Running the Server Manually |
| 75 | +--------------------------- |
| 76 | + |
| 77 | +.. code-block:: bash |
| 78 | +
|
| 79 | + NETBIRD_HOST=api.netbird.io NETBIRD_API_TOKEN=your-token netbird-mcp |
| 80 | +
|
| 81 | +Or using ``python -m``: |
| 82 | + |
| 83 | +.. code-block:: bash |
| 84 | +
|
| 85 | + python -m netbird.mcp.server |
| 86 | +
|
| 87 | +Available Tools |
| 88 | +--------------- |
| 89 | + |
| 90 | +The server exposes 25 tools organized by resource: |
| 91 | + |
| 92 | +Account |
| 93 | +~~~~~~~ |
| 94 | + |
| 95 | +.. list-table:: |
| 96 | + :header-rows: 1 |
| 97 | + :widths: 30 70 |
| 98 | + |
| 99 | + * - Tool |
| 100 | + - Description |
| 101 | + * - ``get_account`` |
| 102 | + - Get the current NetBird account settings and configuration |
| 103 | + |
| 104 | +Users |
| 105 | +~~~~~ |
| 106 | + |
| 107 | +.. list-table:: |
| 108 | + :header-rows: 1 |
| 109 | + :widths: 30 70 |
| 110 | + |
| 111 | + * - Tool |
| 112 | + - Description |
| 113 | + * - ``get_current_user`` |
| 114 | + - Get the currently authenticated user's profile and permissions |
| 115 | + * - ``list_users`` |
| 116 | + - List all users in the NetBird account |
| 117 | + |
| 118 | +Peers |
| 119 | +~~~~~ |
| 120 | + |
| 121 | +.. list-table:: |
| 122 | + :header-rows: 1 |
| 123 | + :widths: 30 70 |
| 124 | + |
| 125 | + * - Tool |
| 126 | + - Description |
| 127 | + * - ``list_peers`` |
| 128 | + - List all peers with connection status and IP addresses |
| 129 | + * - ``get_peer`` |
| 130 | + - Get details of a specific peer by ID |
| 131 | + * - ``update_peer`` |
| 132 | + - Update a peer's name, SSH access, or login expiration |
| 133 | + * - ``delete_peer`` |
| 134 | + - Remove a peer from the network |
| 135 | + * - ``get_peer_accessible_peers`` |
| 136 | + - List all peers a given peer can access based on current policies |
| 137 | + |
| 138 | +Groups |
| 139 | +~~~~~~ |
| 140 | + |
| 141 | +.. list-table:: |
| 142 | + :header-rows: 1 |
| 143 | + :widths: 30 70 |
| 144 | + |
| 145 | + * - Tool |
| 146 | + - Description |
| 147 | + * - ``list_groups`` |
| 148 | + - List all peer groups with member counts |
| 149 | + * - ``get_group`` |
| 150 | + - Get details of a specific group including its members |
| 151 | + * - ``create_group`` |
| 152 | + - Create a new peer group with optional initial members |
| 153 | + * - ``update_group`` |
| 154 | + - Update a group's name or member list |
| 155 | + * - ``delete_group`` |
| 156 | + - Delete a peer group |
| 157 | + |
| 158 | +Policies |
| 159 | +~~~~~~~~ |
| 160 | + |
| 161 | +.. list-table:: |
| 162 | + :header-rows: 1 |
| 163 | + :widths: 30 70 |
| 164 | + |
| 165 | + * - Tool |
| 166 | + - Description |
| 167 | + * - ``list_policies`` |
| 168 | + - List all access control policies with their rules |
| 169 | + * - ``create_policy`` |
| 170 | + - Create a new policy with protocol, port, and direction control |
| 171 | + * - ``delete_policy`` |
| 172 | + - Delete an access control policy |
| 173 | + |
| 174 | +Networks |
| 175 | +~~~~~~~~ |
| 176 | + |
| 177 | +.. list-table:: |
| 178 | + :header-rows: 1 |
| 179 | + :widths: 30 70 |
| 180 | + |
| 181 | + * - Tool |
| 182 | + - Description |
| 183 | + * - ``list_networks`` |
| 184 | + - List all networks with their resources and routers |
| 185 | + * - ``get_network`` |
| 186 | + - Get a network with its resources and routers included |
| 187 | + |
| 188 | +Setup Keys |
| 189 | +~~~~~~~~~~ |
| 190 | + |
| 191 | +.. list-table:: |
| 192 | + :header-rows: 1 |
| 193 | + :widths: 30 70 |
| 194 | + |
| 195 | + * - Tool |
| 196 | + - Description |
| 197 | + * - ``list_setup_keys`` |
| 198 | + - List all setup keys with validity and usage stats |
| 199 | + * - ``create_setup_key`` |
| 200 | + - Create a setup key for enrolling new peers |
| 201 | + |
| 202 | +DNS |
| 203 | +~~~ |
| 204 | + |
| 205 | +.. list-table:: |
| 206 | + :header-rows: 1 |
| 207 | + :widths: 30 70 |
| 208 | + |
| 209 | + * - Tool |
| 210 | + - Description |
| 211 | + * - ``list_nameservers`` |
| 212 | + - List all DNS nameserver groups |
| 213 | + * - ``get_dns_settings`` |
| 214 | + - Get the global DNS settings for the account |
| 215 | + |
| 216 | +Posture Checks & Audit |
| 217 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 218 | + |
| 219 | +.. list-table:: |
| 220 | + :header-rows: 1 |
| 221 | + :widths: 30 70 |
| 222 | + |
| 223 | + * - Tool |
| 224 | + - Description |
| 225 | + * - ``list_posture_checks`` |
| 226 | + - List all device posture checks (compliance policies) |
| 227 | + * - ``get_audit_events`` |
| 228 | + - Get recent audit log events showing account activity |
| 229 | + |
| 230 | +Diagrams |
| 231 | +~~~~~~~~ |
| 232 | + |
| 233 | +.. list-table:: |
| 234 | + :header-rows: 1 |
| 235 | + :widths: 30 70 |
| 236 | + |
| 237 | + * - Tool |
| 238 | + - Description |
| 239 | + * - ``generate_network_diagram`` |
| 240 | + - Generate a network topology diagram (Mermaid, Graphviz, or Diagrams) |
| 241 | + |
| 242 | +Example Conversations |
| 243 | +--------------------- |
| 244 | + |
| 245 | +Once connected to Claude Desktop, you can ask questions like: |
| 246 | + |
| 247 | +.. code-block:: text |
| 248 | +
|
| 249 | + "List all peers and show which ones are currently connected" |
| 250 | +
|
| 251 | + "Create a policy called 'SSH Access' allowing the DevOps group |
| 252 | + to reach port 22 on the Servers group" |
| 253 | +
|
| 254 | + "Generate a Mermaid diagram of the current network topology" |
| 255 | +
|
| 256 | + "Create a reusable setup key called 'Office-Onboarding' that expires |
| 257 | + in 7 days and auto-assigns peers to the Office group" |
| 258 | +
|
| 259 | + "Show me all audit events from the last 24 hours" |
| 260 | +
|
| 261 | + "Which peers can the peer named 'laptop-01' access?" |
| 262 | +
|
| 263 | +API Reference |
| 264 | +------------- |
| 265 | + |
| 266 | +.. automodule:: netbird.mcp.server |
| 267 | + :members: |
| 268 | + :undoc-members: |
| 269 | + :show-inheritance: |
0 commit comments