Nornir MCP Server

Nornir MCP Server

A FastMCP server that provides network automation tools by exposing Nornir and NAPALM operations as MCP tools, allowing users to manage and interact with network devices through compatible MCP clients.

Category
访问服务器

README

🌐 Nornir MCP Server

License: MIT

A FastMCP server providing network automation tools powered by Nornir and NAPALM.

This server acts as a bridge, exposing Nornir/NAPALM network operations as MCP (Massively Concurrent Processing) tools, making them easily accessible from compatible MCP clients (like the FastMCP Web UI).

✨ Key Features

  • Leverages Nornir for inventory management and concurrent task execution against network devices.
  • Uses NAPALM for multi-vendor device interaction (information gathering, command execution).
  • Built with FastMCP for seamless integration with MCP clients using various transports (SSE in this configuration).
  • Containerized with Docker 🐳 for easy setup and deployment.
  • Uses uv for fast Python dependency management within the container ⚡.

🔧 Prerequisites

Before you begin, ensure you have the following installed:

⚙️ Configuration

Before running the server, you must configure your network inventory and device credentials:

  1. Navigate to the conf/ directory in the project.
  2. Edit hosts.yaml: Define your network devices. Specify their management IP/hostname, platform (e.g., ios, junos, eos), credentials (if not using defaults), and assign them to groups if desired.
  3. Edit groups.yaml: Define device groups with shared properties (like platform or connection options). Settings here can override defaults.
  4. Edit defaults.yaml: Set default credentials (username, password) and connection options (like NAPALM secret for enable passwords or default platform).
    • ⚠️ Important Security Note: The default configuration uses plaintext credentials in YAML files. This is suitable for testing/lab environments. For production, strongly consider using Nornir's built-in secrets management features (e.g., environment variables, HashiCorp Vault plugin) to avoid storing sensitive information directly in configuration files. Modify nornir_ops.py and your configuration if you implement a secrets provider.
  5. Review config.yaml: Ensure the inventory file paths (host_file, group_file, defaults_file) point correctly to the files within the conf/ directory (they should by default). Adjust runner options (num_workers) if needed.

▶️ Running the Server

Once configured, you can easily run the server using Docker Compose:

  1. Ensure you have configured the conf/ directory as described above.
  2. Open a terminal or command prompt in the project's root directory (the same directory as the Dockerfile and docker-compose.yml files).
  3. Run the following command:
    docker-compose up --build -d
    
    • The --build flag tells Docker Compose to build the image based on the Dockerfile the first time or if any project files (like .py files or pyproject.toml) have changed.
    • This command will start the Nornir MCP server in a Docker container.
  4. The server logs will be displayed in your terminal. By default, it should be accessible on port 8000 of your host machine (localhost).
  5. To stop the server, press Ctrl+C in the terminal where docker-compose is running. To remove the container afterwards, run docker-compose down.

🔌 Adding to MCP Client

To use the tools provided by this server in an MCP client (like the official FastMCP Web UI or other compatible clients):

  1. Make sure the Nornir MCP server is running (using docker-compose up).
  2. Open your MCP client application.
  3. Find the option to add or manage MCP Server connections.
  4. Add a new connection with the following details:
    • Server URL: Since this server uses the SSE (Server-Sent Events) transport and runs on port 8000 by default, the URL will be:
      • sse://localhost:8000
      • (If your Docker host has a different IP address accessible by the client, replace localhost with that IP, e.g., sse://192.168.1.100:8000)
    • Connection Name: Give it a descriptive name, for example, Nornir Lab Server.
  5. Save and connect to the newly added server.
  6. The MCP client should discover the Nornir_MCP service and list all the available tools (like get_facts, send_command, etc.). You can now use these tools via the client interface! 🎉

🛠️ Available Tools & Resources

Once connected via an MCP client, the following tools (under the "Nornir_MCP" service name) should typically be available:

  • Inventory:
    • list_all_hosts: Lists devices configured in your Nornir inventory (conf/hosts.yaml).
  • NAPALM Getters: (Retrieve information)
    • get_facts
    • get_interfaces
    • get_interfaces_ip
    • get_interfaces_counters
    • get_config (with retrieve option: running, startup, candidate)
    • get_arp_table
    • get_mac_address_table
    • get_users
    • get_vlans
    • get_snmp_information
    • get_bgp_neighbors
    • (Availability depends on device platform and NAPALM driver support)
  • Execution:
    • send_command: Send a single, read-only command to a device and get the output.
  • Streaming Resource:
    • sse://updates: Provides a simple heartbeat event stream. (Can be subscribed to by clients supporting SSE resources).

📄 License

This project is licensed under the MIT License.

🙌 Contributing

Contributions, issues, and feature requests are welcome! Please feel free to submit them via the project's repository.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选