Execute CLI commands on Cisco NX-OS devices via NX-API
Cisco NX-OS CLI MCP Server
A Model Context Protocol (MCP) server that lets you interact with Cisco NX-OS devices. You can send arbitrary CLI commands to one or more switches via their NX-API interface. This server exposes MCP tools for executing commands on one or more devices with comprehensive error handling. The output format can also be selected (text or JSON).
Features
- Single Device Commands: Execute CLI commands on individual NX-OS switches
- Multi-Device Commands: Execute the same commands across multiple switches concurrently
- Text-Based I/O: Commands are sent as text (cli_show_ascii), responses default to text format
- JSON Option: Optional JSON response format for structured parsing
- Simple Authentication: Credentials collected from .env file or on a per-request override
- Error Handling: Clear, actionable error messages
- Batch Operations: Execute up to 100 commands per request
- Concurrent Execution: Parallel command execution on multiple devices (up to 50)
Requirements
- Python 3.10 or higher
- Cisco NX-OS devices with NX-API enabled (
feature nxapi) - Network connectivity between the MCP host (Claude Desktop, etc.) to target devices via HTTPS
Installation
Prerequisites
- Python 3.10 or higher
- uv - Fast Python package installer (recommended)
- Cisco NX-OS devices with NX-API enabled (
feature nxapi) - Network connectivity to target devices via HTTPS
Setup
- Install uv (if not already installed):
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
- Install dependencies using uv:
# With uv and pyproject.toml (recommended)
uv sync
- Set up authentication credentials:
Create a .env file from the template:
cp .env.example .env
Edit .env and add your credentials:
NXOS_USERNAME=admin
NXOS_PASSWORD=your_secure_password
Important: Never commit your production .env file to version control. .gitignore is configured to prevent this but be cautious!
Registering with MCP Hosts
Claude Desktop
macOS:
Edit the Claude Desktop configuration file:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
Add the NX-OS CLI MCP server to the mcpServers section:
{
"mcpServers": {
"nxos-cli": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/nxos-cli-mcp",
"run",
"nxos_cli_mcp.py"
]
}
}
}
Windows:
Edit the Claude Desktop configuration file:
notepad %APPDATA%\Claude\claude_desktop_config.json
Add the NX-OS CLI MCP server to the mcpServers section:
{
"mcpServers": {
"nxos-cli": {
"command": "uv",
"args": [
"--directory",
"C:\\absolute\\path\\to\\nxos-cli-mcp",
"run",
"nxos_cli_mcp.py"
]
}
}
}
After saving, restart Claude Desktop for the changes to take effect.
Visual Studio Code
macOS:
Edit the VS Code MCP settings file:
code ~/Library/Application\ Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
Add the server configuration:
{
"mcpServers": {
"nxos-cli": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/nxos-cli-mcp",
"run",
"nxos_cli_mcp.py"
]
}
}
}
Windows:
Edit the VS Code MCP settings file:
notepad %APPDATA%\Code\User\globalStorage\rooveterinaryinc.roo-cline\settings\cline_mcp_settings.json
Add the server configuration:
{
"mcpServers": {
"nxos-cli": {
"command": "uv",
"args": [
"--directory",
"C:\\absolute\\path\\to\\nxos-cli-mcp",
"run",
"nxos_cli_mcp.py"
]
}
}
}
After saving, reload the VS Code window (Command/Ctrl + Shift + P → "Developer: Reload Window").
Important Notes:
- Replace
/absolute/path/to/nxos-cli-mcp(orC:\absolute\path\to\nxos-cli-mcp) with the actual full path to your project directory - Ensure the
.envfile with your credentials is in the project directory - The server will automatically load credentials from the
.envfile when started by the MCP client
Available Tools
1. nxos_execute_commands
Execute CLI commands on a single NX-OS device.
Parameters:
ip_address(required): IP address or hostname of the devicecommands(required): List of CLI commands to executeresponse_format(optional): "text" (default, human-readable) or "json" (structured data)username(optional): Username for authenticationpassword(optional): Password for authenticationtimeout(optional): Request timeout in seconds (default: 30)
2. nxos_execute_commands_multi
Execute the same CLI commands on multiple NX-OS devices concurrently.
Tools (2)
nxos_execute_commandsExecute CLI commands on a single NX-OS device.nxos_execute_commands_multiExecute the same CLI commands on multiple NX-OS devices concurrently.Environment Variables
NXOS_USERNAMErequiredUsername for Cisco NX-OS authenticationNXOS_PASSWORDrequiredPassword for Cisco NX-OS authenticationConfiguration
{"mcpServers": {"nxos-cli": {"command": "uv", "args": ["--directory", "/absolute/path/to/nxos-cli-mcp", "run", "nxos_cli_mcp.py"]}}}