Nornir MCP Server
Enables natural language orchestration of multi-vendor network infrastructure by combining NAPALM for structured data retrieval and Netmiko for CLI execution via Nornir.
README
Nornir MCP Server
An enterprise-ready Model Context Protocol (MCP) server that brings the power of Nornir to LLMs like Claude. It seamlessly integrates NAPALM for structured data retrieval and Netmiko for flexible CLI execution, enabling natural language orchestration of complex network infrastructure.
🚀 Overview
The Nornir MCP Server provides a specialized set of tools for network engineers and AI agents to interact with multi-vendor environments safely and efficiently.
- Multi-Vendor Support: Standardized interaction for Cisco (IOS, NX-OS, XR), Arista (EOS), Juniper (Junos), and 100+ others.
- Dual-Engine Architecture: Combines NAPALM's normalized getters with Netmiko's robust SSH command execution.
- Intelligent Filtering: Schema-agnostic device selection by hostname, group, or platform.
- Security First: Built-in command blacklisting, input validation (Pydantic), and backup path restrictions.
- Per-Call Inventory Reloading: Every MCP tool invocation reloads
config.yamland inventory data from disk. - Production Ready: Comprehensive logging and asynchronous execution.
📋 Table of Contents
- Installation
- Quick Start
- Available Tools
- Configuration
- Claude Integration
- Security
- Development
- Testing
🛠 Installation
Using uv (Recommended)
# Install as a global tool
uv tool install git+https://github.com/sydasif/nornir-mcp-server.git
# Upgrade to latest
uv tool upgrade nornir-mcp-server
Using pip
pip install git+https://github.com/sydasif/nornir-mcp-server.git
⚡ Quick Start
-
Initialize Configuration:
Create a
config.yamland basic inventory files in your working directory. See Minimal Inventory Example below. -
Launch the Server:
nornir-mcp -
Verify Inventory:
The server will look for
config.yamlin the current directory to load your Nornir inventory.
📦 Minimal Inventory Example
To get started quickly, create these three files in your project root:
hosts.yaml
R1:
hostname: 192.168.1.1
platform: ios
groups:
- cisco_ios
groups.yaml
cisco_ios:
platform: ios
username: admin
password: password
defaults.yaml
# Global defaults
data:
site: NYC
config.yaml
inventory:
plugin: SimpleInventory
options:
host_file: "hosts.yaml"
group_file: "groups.yaml"
defaults_file: "defaults.yaml"
🧰 Available Tools
The server exposes 5 tools categorized by operational intent. All tools support individual filter parameters for device selection.
Filter Parameters:
filter_name: Filter by device name in inventoryfilter_hostname: Filter by specific hostname or IP addressfilter_group: Filter by group membership (e.g., "cisco", "arista")filter_platform: Filter by platform (e.g., "eos", "ios", "junos")
All filter parameters are optional. When multiple filters are provided, they are combined with AND logic.
| Category | Tool | Description |
|---|---|---|
| Inventory | list_network_devices |
List hosts, groups, and metadata. |
| Monitoring | run_napalm_getter |
Generic access to any NAPALM getter (ARP, VLAN, etc.). |
| Management | run_show_commands |
Execute arbitrary show commands safely. |
send_config_commands |
Deploy configuration changes with validation. | |
backup_device_configs |
Securely save configurations to local disk. |
⚙️ Configuration
Every MCP tool call reloads config.yaml from the current working directory. The server does not cache a long-lived Nornir instance between requests.
Nornir Setup (config.yaml)
inventory:
plugin: SimpleInventory
options:
host_file: "hosts.yaml"
group_file: "groups.yaml"
defaults_file: "defaults.yaml"
runner:
plugin: threaded
options:
num_workers: 100
logging:
enabled: true
level: INFO
Command Security
The server includes a built-in security engine that validates all CLI commands against a multi-stage validation system before execution. This prevents accidental or malicious use of destructive commands while minimizing false positives for read-only operations.
Security Features:
- Read-Only Enforcement: Tools like
run_show_commandsenforce an allowlist prefix (e.g.,show,display,get,ping,traceroute). - Smart Denylist: Destructive keywords (
erase,format,delete,reload) are blocked only when they appear as the first token of a command. This allows legitimate commands likeshow reload historywhile blocking a barereload. - Chaining & Redirection Protection: Prevents the use of
;,&&,>, and<to ensure single-command integrity. - Path Sandboxing: Configuration backups are protected against directory traversal attacks (
..).
🤖 CLI Integration
Add the following to your claude config:
{
"mcpServers": {
"nornir": {
"command": "nornir-mcp"
}
}
}
Add the following to your opencode config:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"nornir": {
"type": "local",
"command": ["nornir-mcp"]
}
}
}
Try these prompts:
- "Show me all core routers in the US-West region."
- "Are there any BGP neighbors down on R1?"
- "Backup the running configuration of all Arista switches."
- "Check if there are any errors on the interfaces of the edge-group."
🔒 Security
- Command Validation: All CLI inputs pass through a multi-stage built-in denylist filter (Keywords and Patterns).
- Credential Management: Supports environment variables and Nornir's native secure handling.
- Path Sandboxing: Configuration backups are restricted to the defined root directory to prevent traversal.
👨💻 Development
# Clone and setup
git clone https://github.com/sydasif/nornir-mcp-server.git
cd nornir-mcp-server
uv sync
# Run tests
uv run pytest
# Lint and Format
uv run ruff check . --fix
uv run ruff format .
If uv run is unstable in the local environment, use .venv/bin/pytest and .venv/bin/ruff directly.
Relevant internal paths:
src/nornir_mcp/services/runner.py: shared task execution.src/nornir_mcp/services/inventory.py: shared inventory loading and filtering helper. This helper still reloads inventory from disk on every call.src/nornir_mcp/services/napalm.py: shared NAPALM getter execution helper used by monitoring and backup tools.src/nornir_mcp/tools/monitoring.py: monitoring tools for generic getters.
✅ Testing
The repository includes a pytest suite under tests/ covering filters, inventory loading, inventory tools, monitoring tools, NAPALM helper behavior, security validation, runner error handling, and backup behavior.
# Run the full test suite
uv run pytest
# Fallback if uv run is unstable
.venv/bin/pytest
📄 License
This project is licensed under the MIT License. See LICENSE for details.
<p align="center">Built with ❤️ for Network Automation</p>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。