ravipendurty/netmiko-mcp-server
If you are the rightful owner of netmiko-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 NetMiko MCP Server is a Model Context Protocol server designed for managing network devices using NetMiko, allowing clients to connect and manage devices via SSH.
NetMiko MCP Server
A Model Context Protocol (MCP) server that provides network device management capabilities using NetMiko. This server allows MCP clients to connect to and manage network devices via SSH.
Features
- Device Connection Management: Connect/disconnect to network devices
- Command Execution: Send show commands and configuration commands
- Multiple Device Support: Manage multiple devices simultaneously
- TextFSM Integration: Parse command outputs into structured data
- Security: Secure SSH connections with authentication
- Device Types: Support for Cisco, Arista, Juniper, HP, Dell, and more
Installation
- Clone or download this repository
- Install dependencies:
pip install -r requirements.txt
Usage
Starting the Server
# Start with default configuration
python mcp_server.py
# Start with custom configuration
python cli.py start --config config.yaml
CLI Tools
The server includes a CLI interface for testing and management:
# Test connection to a device
python cli.py test-connection -h 192.168.1.1 -t cisco_ios -u admin -p password
# List supported device types
python cli.py list-device-types
# Generate sample configuration
python cli.py generate-config -o my_config.yaml
MCP Tools
The server provides the following MCP tools:
connect_device
Connect to a network device.
Parameters:
device_id(string): Unique identifier for the devicehost(string): IP address or hostnamedevice_type(string): Device type (cisco_ios, cisco_nxos, etc.)username(string): SSH usernamepassword(string): SSH passwordport(integer, optional): SSH port (default: 22)secret(string, optional): Enable secrettimeout(integer, optional): Connection timeout (default: 30)
disconnect_device
Disconnect from a network device.
Parameters:
device_id(string): Device identifier to disconnect
send_command
Send a show command to a connected device.
Parameters:
device_id(string): Device identifiercommand(string): Command to executeuse_textfsm(boolean, optional): Parse output with TextFSMstrip_prompt(boolean, optional): Strip device prompt from outputstrip_command(boolean, optional): Strip command from output
send_config_commands
Send configuration commands to a device.
Parameters:
device_id(string): Device identifiercommands(array): List of configuration commandsexit_config_mode(boolean, optional): Exit config mode after commands
get_device_info
Get information about a connected device.
Parameters:
device_id(string): Device identifier
list_connected_devices
List all currently connected devices.
Configuration
Create a config.yaml file to pre-configure devices:
server:
name: "netmiko-mcp-server"
version: "1.0.0"
log_level: "INFO"
devices:
router1:
host: "192.168.1.1"
device_type: "cisco_ios"
username: "admin"
password: "password"
port: 22
timeout: 30
secret: "enable_secret"
Supported Device Types
- cisco_ios
- cisco_nxos
- cisco_xr
- cisco_asa
- arista_eos
- juniper_junos
- hp_procurve
- dell_force10
- paloalto_panos
- fortinet
- checkpoint_gaia
- linux
Example Usage
- Connect to a device:
{
"tool": "connect_device",
"arguments": {
"device_id": "router1",
"host": "192.168.1.1",
"device_type": "cisco_ios",
"username": "admin",
"password": "password"
}
}
- Send a show command:
{
"tool": "send_command",
"arguments": {
"device_id": "router1",
"command": "show ip interface brief",
"use_textfsm": true
}
}
- Configure the device:
{
"tool": "send_config_commands",
"arguments": {
"device_id": "router1",
"commands": [
"interface GigabitEthernet0/1",
"description Connected to Switch1",
"no shutdown"
]
}
}
Security Considerations
- Store credentials securely (consider using environment variables)
- Use SSH keys when possible
- Implement proper access controls
- Monitor and log all device interactions
- Use secure network connections
Error Handling
The server handles common network device errors:
- Authentication failures
- Connection timeouts
- Command execution errors
- Device disconnections
Development
To extend the server:
- Add new tools in the
_setup_handlers()method - Implement corresponding handler methods
- Update the tool list in
handle_list_tools() - Test with various device types
License
This project is open source. Please check the license file for details.
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
Support
For issues and questions:
- Check the NetMiko documentation
- Review MCP protocol specifications
- Create an issue in the repository