huawei-mcp-server

ishag74/huawei-mcp-server

3.2

If you are the rightful owner of huawei-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The HuaweiMCP V3 script provides a FastMCP server for managing Huawei routers using the Netmiko library.

Tools
6
Resources
0
Prompts
0

HuaweiMCP V3

This script provides a FastMCP server for interacting with Huawei routers using the Netmiko library. It allows you to execute commands, retrieve configurations, and manage router interfaces.

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
    
  2. Install the required Python libraries:

    pip install -r requirements.txt
    

Configuration

The server requires a JSON file (by default, devices.json) to define the Huawei routers it can connect to. This file should be in the same directory as the script.

devices.json example:

{
  "router1": {
    "ip": "192.168.1.1",
    "port": 22,
    "username": "admin",
    "password": "your_password",
    "type": "Huawei VRP",
    "mac": "00:1A:2B:3C:4D:5E",
    "software": "VRP (R) software, Version 8.191",
    "subnet": "192.168.1.0/24"
  },
  "router2": {
    "ip": "10.0.0.1",
    "port": 22,
    "username": "user",
    "auth": {
      "password": "another_password"
    },
    "type": "Huawei VRP",
    "mac": "00:1A:2B:3C:4D:5F",
    "software": "VRP (R) software, Version 8.191",
    "subnet": "10.0.0.0/24"
  }
}

Authentication Methods

The devices.json file supports two authentication methods:

  • Password: Provide the password directly in the password field or within an auth dictionary.
  • SSH Key: If you are using SSH key-based authentication, you can specify the path to your key file in the ssh_key field.

Usage

To start the HuaweiMCP server, run the HuaweiMCP_V3.py script with the following arguments:

python HuaweiMCP_V3.py [-f <device-mapping>] [-H <host>] [-p <port>] [-t <transport>]

Arguments

  • -f, --device-mapping: The name of the JSON file containing the device mapping. Default is devices.json.
  • -H, --host: The host for the Huawei MCP Server. Default is 0.0.0.0.
  • -p, --port: The port for the Huawei MCP Server. Default is 30030.
  • -t, --transport: The transport for the Huawei MCP Server. Default is streamable-http.

Example:

python HuaweiMCP_V3.py -f my_devices.json -H 127.0.0.1 -p 8080

Available Tools

The following tools are available through the FastMCP server:

  • execute_huawei_command(router_name: str, command: str, timeout: int = 360): Executes a command on the specified router.
  • get_huawei_config(router_name: str): Retrieves the current configuration from the specified router.
  • get_router_list(): Returns a comma-separated list of configured routers.
  • get_router_ip(): Returns a comma-separated list of configured routers and their IP addresses.
  • get_router_info(): Returns detailed information for each configured router, including type, MAC address, software version, and location (subnet).
  • configure_huawei_interface(router_name: str, interface_name: str, commands: list, timeout: int = 360): Configures a specified interface on a router with a list of commands.