nornir-mcp-server
This server provides MCP tools for network automation, letting AI agents inventory, query, configure, and generate device configs via Nornir.
get_inventory: List hosts and metadata, optionally filtered by attributes like
{"site": "tokyo"}.run_netmiko_command: Execute show/CLI commands (SSH/Telnet) on filtered hosts in parallel, with optional TextFSM parsing.
run_http_request: Send REST API requests (GET/POST/PUT, etc.) to device API endpoints, with optional JSON payloads, in parallel.
run_serial_command: Run commands over direct serial connections, processed sequentially (one device at a time).
generate_config: Render Jinja2 templates per host to generate configuration (dry-run only; no deployment).
run_netmiko_config: Deploy configuration commands to filtered devices in parallel — a destructive write operation that requires user confirmation.
Filtering: Most tools accept
filter_criteriato target specific hosts; omitting it may run on all hosts.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nornir-mcp-server run show version on core routers in tokyo"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
English | 日本語
nornir-mcp-server
nornir-mcp-server is an MCP (Model Context Protocol) server that exposes Nornir, a network automation framework, to AI agents.
Rather than the traditional "iterate over every device in a list" approach, it lets an AI agent leverage Nornir's metadata-based filtering (nornir.filter) to autonomously select targets — e.g. "only the core routers in Tokyo" — and run tasks against them in parallel.
Capabilities
SimpleInventory(YAML) and NetBox (nornir_netbox) supportParallel execution of
showcommands (SSH/Telnet)REST API request execution (via
httpx)Direct serial connection support to hosts (
netmikoserial mode)Dynamic config generation with Jinja2
Deploying configuration to real devices (Config Deploy)
Related MCP server: mcp-netmiko-server
Key Features
Flexible inventory: Uses Nornir's plugin ecosystem as-is — the standard
SimpleInventory(hosts.yaml / groups.yaml) rather than a custom format. Dynamic inventory from NetBox is also supported.Autonomous filtering: The AI narrows down target devices at runtime by supplying metadata such as
{"role": "core", "site": "tokyo"}.Configuration management and deployment: Give (or have the AI write) a template, and it instantly generates per-host configuration and can push it straight to the real devices.
Multi-protocol support: SSH/Telnet, REST APIs, and physical serial console connections are all reachable from a single MCP server.
Fast parallel execution: Nornir's ThreadedRunner dispatches tasks to multiple devices safely and quickly (serial ports are the exception — see below).
Installation and Setup
This project is managed with the uv package manager.
1. Install dependencies
cd nornir-mcp-server
uv sync2. Configure the inventory
YAML files are used by default; edit config.yaml to switch to NetBox, etc.
By default the config file is loaded from config.yaml next to server.py, but you can point it anywhere with the NORNIR_MCP_CONFIG environment variable (independent of the process's working directory).
export NORNIR_MCP_CONFIG=/path/to/config.yamlOnly the config file path is resolved this way. The host_file / group_file paths inside that config are resolved by Nornir against the process's current working directory, so a config stored outside the repository must use absolute inventory paths.
hosts.yaml / groups.yaml / defaults.yaml contain device credentials and are gitignored. Copy them from the templates:
cp hosts.yaml.example hosts.yaml
cp groups.yaml.example groups.yamlEdit groups.yaml and replace every CHANGE_ME with real login credentials — both the top-level username / password (used by run_serial_command) and the ones under connection_options.netmiko.extras (used for SSH/Telnet). These files are never committed.
config.yaml (SimpleInventory example):
---
inventory:
plugin: SimpleInventory
options:
host_file: "hosts.yaml"
group_file: "groups.yaml"
logging:
enabled: Falseconfig.yaml (NetBox integration example):
⚠️ Unlike the inventory files, config.yaml is tracked in git — never write your NetBox API token into it. NetBoxInventory2 reads the token from the NB_TOKEN environment variable (and the URL from NB_URL).
export NB_TOKEN=your-netbox-api-token---
inventory:
plugin: NetBoxInventory2
options:
nb_url: "https://netbox.local"
logging:
enabled: False3. Start the MCP server
Run it locally with:
uv run mcp run server.pyRunning via Docker (GHCR)
GitHub Actions automatically builds and publishes a container image to the GitHub Container Registry (GHCR) on every commit to main.
If you have Docker, you can use the server right away without cloning the repository.
docker pull ghcr.io/nagayon-935/nornir-mcp-server:latestExample:
Mount your config files (config.yaml and the inventory files) into /app in the container. (MCP communicates over stdio, so you'll need -i or similar — follow your MCP client's setup instructions.)
docker run -i --rm \
-v $(pwd)/config.yaml:/app/config.yaml \
-v $(pwd)/hosts.yaml:/app/hosts.yaml \
-v $(pwd)/groups.yaml:/app/groups.yaml \
ghcr.io/nagayon-935/nornir-mcp-server:latestMCP Tools Provided
The following tools are currently exposed to AI agents.
get_inventory
Returns the hosts and their metadata from the current inventory, optionally filtered.
Args:
filter_criteria(e.g.{"site": "tokyo"})Returned
dataincludes values inherited from groups and defaults; host values take precedence.
run_netmiko_command
Runs a show-style command in parallel across the filtered target devices.
Args:
command(the CLI command to run),filter_criteria(target filter),use_textfsm(ifTrue, parses output into structured JSON using ntc-templates)
run_http_request
Sends an HTTP request to the REST API endpoint of each filtered target device.
Args:
method(GET/POST/etc.),path(API path),filter_criteria,json_dataConfigure the target host's inventory data (
host.data) withbase_url(e.g.https://192.168.1.1),http_headers,tls_verify(True/False), andhttp_timeout(seconds, defaults to 10) as needed.These settings can also be defined in group or default data. Host values override inherited values.
run_serial_command
Runs a command over a direct serial connection (console cable, etc.). Physical ports can only be held by one process at a time, so even with multiple target hosts, they are always processed one at a time (never in parallel).
Args:
command(the CLI command to run),filter_criteriaThe target host's inventory data must include
serial_settings(port, baudrate, etc.). Netmiko's serial drivers require adevice_typeending in_serial, so either setserial_settings.device_typeexplicitly, or leave it unset and it will be derived by appending_serialtohost.platform(e.g.cisco_ios).serial_settingscan also be inherited from group or default data.The derivation is not validated against Netmiko's driver table, and Netmiko only ships serial drivers for a subset of platforms. A platform with no matching
*_serialdriver (e.g.arista_eos→arista_eos_serial) fails withUnsupported device_type; setserial_settings.device_typeexplicitly in that case.Login uses the top-level
username/passwordfields fromhosts.yaml/groups.yaml/defaults.yaml. It does not readconnection_options.netmiko.extras(which is used for SSH connections), so if you also use serial connections, set credentials at the top level too —groups.yaml.exampleships both. All three files are gitignored.
generate_config
Renders a Jinja2 template (in a sandboxed environment) to generate configuration. Does not deploy it — useful for dry runs and auditing.
Args:
template_string(a Jinja2 template),filter_criteriaOnly
{{ host.name }},{{ host.hostname }},{{ host.platform }},{{ host.groups }}, and{{ host.data['key'] }}are available inside the template. Other host attributes (such as credentials) are intentionally not exposed.host.dataincludes values inherited from groups and defaults; host values take precedence. Data fields are exposed as provided, so avoid placing secrets in data used by inventory queries or templates.
run_netmiko_config
⚠️ This is a destructive operation that changes device configuration. Deploys the given configuration commands (or a generated config) to the target devices in parallel.
Args:
commands(list of configuration commands to deploy),filter_criteriaThis is the only write path in the server. The tool description instructs the agent to confirm with you before calling it — keep a human in the loop for this tool.
Testing
Unit tests live in tests/.
uv sync
uv run pytest tests/ -vLint and format with ruff:
uv run ruff check .
uv run ruff format .License
MIT License
Available Tools
6 toolsgenerate_configA
Generate configuration from a Jinja2 template string for each target host. Does NOT deploy the configuration; useful for dry-runs and auditing.
Args: template_string: Jinja2 template string. Available variables: {{ host.name }}, {{ host.hostname }}, {{ host.platform }}, {{ host.groups }}, {{ host.data['key'] }}. Other host attributes (e.g. credentials) are not exposed. filter_criteria: Dictionary to filter target hosts.
Inputs: template_string (required), filter_criteria. Returns: result
get_inventoryA
Get inventory hosts and their metadata, optionally filtered.
Args: filter_criteria: Dictionary of key-value pairs to filter hosts (e.g. {"name": "router1"} or {"role": "core", "site": "tokyo"}). Matches host attributes or data fields.
Inputs: filter_criteria. Returns: result
run_http_requestA
Run an HTTP API request (REST) concurrently on multiple hosts.
Args: method: HTTP method (e.g., 'GET', 'POST', 'PUT'). path: API path to request (e.g., '/api/v1/system'). filter_criteria: Dictionary to filter target hosts. json_data: Optional JSON payload for POST/PUT requests.
Inputs: path (required), method (required), json_data, filter_criteria. Returns: result
run_netmiko_commandA
Run a show command concurrently on multiple hosts via Netmiko.
Args: command: The CLI command to execute (e.g., 'show version'). filter_criteria: Dictionary of key-value pairs to filter target hosts. If empty, runs on ALL hosts! use_textfsm: If True, attempts to parse output into structured data using ntc-templates.
Inputs: command (required), use_textfsm, filter_criteria. Returns: result
run_netmiko_configA
WRITE OPERATION: modifies device configuration. Deploy configuration commands concurrently to multiple hosts via Netmiko. Confirm with the user before calling this tool.
Args: commands: List of configuration commands to execute. filter_criteria: Dictionary to filter target hosts.
Inputs: commands (required), filter_criteria. Returns: result
run_serial_commandA
Run a CLI command on devices via direct Serial connection (using Netmiko).
Note: Physical serial ports generally cannot be used concurrently by multiple threads, so hosts are processed sequentially (one at a time).
Args: command: The CLI command to execute (e.g., 'show version'). filter_criteria: Dictionary to filter target hosts.
Inputs: command (required), filter_criteria. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a distinct purpose: inventory retrieval, command execution via Netmiko/Serial/HTTP, config generation, and config deployment. No two tools overlap in function; the transport-specific tools are clearly differentiated.
All tools follow a consistent verb_noun pattern using snake_case (e.g., get_inventory, run_netmiko_command). The naming is predictable and self-explanatory.
With 6 tools, the server is well-scoped for network automation. It covers essential operations without being bloated or insufficient.
The tool set covers inventory, multi-protocol command execution, config generation, and config deployment. Missing a serial config deployment tool and perhaps backup/restore, but core workflows are supported.
Maintenance
Related MCP Connectors
AI network lab: build and validate real multi-vendor router and switch labs from a prompt.
Connect your AI to your own devices, 3D printers, factory tools and a shared agent task pool.
IP intelligence, network diagnostics, and AI service availability tools for AI agents.
Private networking for AI agents: networks, nodes, commands, files, services via hosted MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with direct access to multi-vendor network devices for tasks like configuration management, health checks, and topology discovery through 35 specialized tools. It enables natural language control over platforms including Cisco, Juniper, and Nokia using SSH, NETCONF, and SNMP protocols.12MIT
- FlicenseNot gradedqualityDmaintenanceEnables LLMs to interact with network devices via SSH (netmiko), allowing command execution and configuration changes on routers and switches.35-
- FlicenseAqualityDmaintenanceEnables natural language orchestration of multi-vendor network infrastructure by combining NAPALM for structured data retrieval and Netmiko for CLI execution via Nornir.5-
- AlicenseNot gradedqualityDmaintenanceEnables large language models to manage network devices (Cisco, Huawei, H3C, Ruijie) via Telnet/SSH, supporting command execution, configuration, and diagnostics.16MIT