Zing 论坛

正文

Nornir MCP Server:将大语言模型引入网络自动化的企业级桥梁

Nornir MCP Server 是一个基于 Model Context Protocol (MCP) 的企业级服务器,它将大语言模型(如 Claude)与网络自动化框架 Nornir 无缝集成,支持多厂商网络设备(Cisco、Arista、Juniper 等)的自然语言编排,提供双重引擎架构(NAPALM + Netmiko)、智能过滤、安全沙箱等生产级功能。

MCPModel Context ProtocolNornir网络自动化Network AutomationLLM大语言模型ClaudeNAPALMNetmiko
发布时间 2026/05/06 20:39最近活动 2026/05/06 20:51预计阅读 8 分钟
Nornir MCP Server:将大语言模型引入网络自动化的企业级桥梁
1

章节 01

Nornir MCP Server: Enterprise Bridge Connecting LLM and Network Automation

Nornir MCP Server is an enterprise-level server based on Model Context Protocol (MCP) that seamlessly integrates large language models (like Claude) with the Nornir network automation framework. It supports natural language orchestration for multi-vendor network devices (Cisco, Arista, Juniper, etc.) and provides production-grade features such as a dual-engine architecture (NAPALM + Netmiko), intelligent filtering, and a security sandbox.

2

章节 02

Background: Challenges in Integrating Network Automation and LLM

Network automation has long faced issues like tool fragmentation, complex configurations, and steep learning curves. Traditional network engineers need to master multiple CLIs, APIs, and automation frameworks (e.g., Ansible, Nornir) to manage multi-vendor devices efficiently. Meanwhile, LLMs excel in code generation, natural language understanding, and reasoning, but integrating these capabilities safely and efficiently into network operations has been an industry exploration direction.

Model Context Protocol (MCP), an open protocol by Anthropic, provides a solution for standardized interaction between LLMs and external tools/data sources. Through MCP, LLMs can use external tools like function calls to implement true 'agentic' workflows. Nornir MCP Server is the concrete implementation of this concept in network automation.

3

章节 03

Core Architecture & Key Tools

Dual Engine Design

Nornir MCP Server uses a unique dual-engine architecture:

  • NAPALM Engine: Standardized network data acquisition (supports Cisco IOS/NX-OS/XR, Arista EOS, Juniper Junos, etc., for unified queries of ARP tables, MAC address tables, VLAN info, etc.).
  • Netmiko Engine: Flexible CLI command execution (supports show commands and config delivery for scenarios not covered by NAPALM).

Six Core Tools

It exposes six core tools to LLMs:

  1. Inventory Management: Query devices by hostname, group, platform.
  2. Device Monitoring: get_device_facts (basic device info) and run_napalm_getter (general data acquisition).
  3. Configuration Management: run_show_commands (execute show commands) and send_config_commands (deliver configs with validation/rollback).
  4. Configuration Backup: Batch backup device configs to a local directory.
4

章节 04

Security Design & Real-time Reload

Security Measures

  • Command Blacklist: Blocks high-risk commands (e.g., reload, write erase), sensitive keywords (erase, format), and command chains/redirections (;, &&, >, <).
  • Input Validation & Sandbox: Strict type validation via Pydantic to prevent injection attacks; config backup paths are restricted to specified directories.
  • Credential Safety: Supports environment variables and Nornir's native secure credential management.

Real-time Reload

Each tool call reloads config.yaml and inventory files from disk, enabling dynamic device addition, config hot updates, and state isolation without service restart.

5

章节 05

Practical Usage Scenarios

  1. Fast Troubleshooting: Ask Claude: 'Are there any BGP neighbor status anomalies in core routers in the US-West region?' Claude will filter devices, get BGP status, and summarize results.
  2. Batch Config Backup: Instruction: 'Backup running configs of all Arista switches.' The system identifies Arista devices and performs batch backup.
  3. Interface Health Check: Instruction: 'Check interface error counts for devices in edge-group.' The system executes targeted show commands and collects stats.
6

章节 06

Technical Implementation & Installation Guide

Technical Implementation

  • Language: Python 3.10+ with async execution.
  • Core Modules: services/runner.py (task execution/timeout), services/inventory.py (inventory loading/filtering), tools/monitoring.py (monitoring tools).
  • Dependencies: Uses uv as package manager; pytest test suite covers core functions.

Installation

  • uv: uv tool install git+https://github.com/sydasif/nornir-mcp-server.git
  • pip: pip install git+https://github.com/sydasif/nornir-mcp-server.git

Integration with AI Assistants

  • Claude: Add to config: {"mcpServers": {"nornir": {"command": "nornir-mcp"}}}
  • OpenCode: Add to config: {"$schema": "https://opencode.ai/config.json", "mcp": {"nornir": {"type": "local", "command": ["nornir-mcp"]}}}
7

章节 07

Project Significance & Future Outlook

Nornir MCP Server represents an important direction for integrating network automation and AI. It lowers the threshold for network operations (allowing natural language interaction instead of complex CLI commands) and provides a safe, controllable example for LLM agents in IT infrastructure management.

As the MCP ecosystem grows, similar bridge projects are expected to emerge in more professional fields,推动 'AI-native operations' (AIOps) from concept to practice. Mastering such tools will become an important part of future competitiveness for network engineers.