Cisco MCP Server

Cisco MCP Server

Enables executing Cisco CLI commands on network devices over SSH through two MCP tools for exec and config commands, with security and automation features.

Category
访问服务器

README

Cisco MCP Server

Production-grade Model Context Protocol (MCP) server for executing Cisco CLI commands on network devices over SSH.

Architecture

MCP Client (LLM)
       ↓
   Tool Selection
   ┌─────────────────────┐
   │ execute_exec_command │  ← show, ping, clear, traceroute, dir
   │ execute_config_command│  ← interface, hostname, router, acl
   └─────────────────────┘
       ↓
Validation Layer (validator)
       ↓
Connector Layer (cisco.py)
       ↓
SSH Transport (Scrapli + Paramiko)
       ↓
Cisco Device

Features

  • Two MCP Tools: LLM decides whether to call the exec or config tool
    • execute_exec_command — operational/exec mode commands (show, ping, clear, traceroute, etc.)
    • execute_config_command — configuration mode commands (interface, hostname, router, etc.)
  • Configuration Mode Management: Automatically handles enable → configure terminal → commands → end
  • Pagination Handling: Automatically disables pagination (terminal length 0) for exec commands
  • Dangerous Command Blocking: Rejects reload, write erase, debug, etc.
  • Managed Command Rejection: Rejects conf t, enable, end, exit (server manages these)
  • Structured Audit Logging: JSON-line audit trail for every execution
  • Legacy SSH Support: Paramiko transport for devices with older SSH (e.g., diffie-hellman-group1-sha1)
  • Vendor Extensible: Abstract base connector supports future vendors (Juniper, Arista, etc.)

Project Structure

mcp_server/
├── server.py                  # MCP server entry point (two tools registered)
├── config.py                  # Configuration management (env vars)
├── models.py                  # Pydantic request/response models
├── tools/
│   └── execute_commands.py    # ExecCommandTool + ConfigCommandTool
├── connectors/
│   ├── base.py                # Abstract base connector
│   └── cisco.py               # Cisco IOS/IOS-XE connector (Scrapli + Paramiko)
├── validation/
│   ├── classifier.py          # Command classifier (kept for reference/utility)
│   └── validator.py           # Input validator (dangerous cmds, device check)
├── inventory/
│   └── devices.yaml           # Device inventory
├── audit/
│   └── audit_logger.py        # Structured audit logger
├── utils/
│   ├── logger.py              # Logging configuration
│   └── exceptions.py          # Custom exceptions
└── tests/
    ├── test_classifier.py
    ├── test_validator.py
    ├── test_models.py
    └── test_execute_commands.py

Setup

Prerequisites

  • Python 3.11+
  • Access to Cisco devices via SSH

Installation

# Clone and enter project directory
cd Cicsco_MCP_New

# Create virtual environment
python -m venv .venv
.venv\Scripts\activate  # Windows
# source .venv/bin/activate  # Linux/Mac

# Install dependencies
pip install -r requirements.txt

Configuration

  1. Copy the environment template:
copy .env.example .env
  1. Edit .env with your credentials:
CISCO_USERNAME=admin
CISCO_PASSWORD=your_password
CISCO_ENABLE_PASSWORD=your_enable_password
SSH_TIMEOUT=30
SSH_PORT=22
LOG_LEVEL=INFO
  1. Edit mcp_server/inventory/devices.yaml to add your devices:
devices:
  "10.10.10.1":
    hostname: "R1"
    platform: "cisco_iosxe"
    description: "Core Router"

Note: If devices.yaml is empty or missing, the server allows connections to any device.

Running the Server

Standalone (stdio transport)

python -m mcp_server.server

Testing with MCP Inspector

npx @modelcontextprotocol/inspector python -m mcp_server.server

Opens a browser UI where you can select either tool and test with real devices.

VS Code / Claude Desktop Integration

Add to your MCP client configuration:

{
  "mcpServers": {
    "cisco": {
      "command": "python",
      "args": ["-m", "mcp_server.server"],
      "cwd": "C:/path/to/Cicsco_MCP_New"
    }
  }
}

Usage

Tool 1: execute_exec_command

For operational/exec mode commands — the LLM calls this for show, ping, clear, traceroute, etc.

Request:

{
  "device": "10.10.10.1",
  "commands": [
    "show version",
    "show ip interface brief"
  ]
}

Response:

{
  "success": true,
  "mode": "exec",
  "device": "10.10.10.1",
  "execution_time": 2.31,
  "results": [
    {
      "command": "show version",
      "output": "Cisco IOS XE Software, Version 17.03.04a..."
    },
    {
      "command": "show ip interface brief",
      "output": "Interface              IP-Address      OK? Method Status..."
    }
  ]
}

Tool 2: execute_config_command

For configuration mode commands — the LLM calls this for interface, routing, ACL changes, etc. The server automatically handles enable → configure terminal → commands → end.

Request:

{
  "device": "10.10.10.1",
  "commands": [
    "interface Loopback100",
    "ip address 10.100.0.1 255.255.255.0",
    "no shutdown"
  ]
}

Response:

{
  "success": true,
  "mode": "config",
  "device": "10.10.10.1",
  "execution_time": 1.92,
  "results": [
    {
      "command": "interface Loopback100",
      "status": "success"
    },
    {
      "command": "ip address 10.100.0.1 255.255.255.0",
      "status": "success"
    },
    {
      "command": "no shutdown",
      "status": "success"
    }
  ]
}

Error Responses

Authentication failure:

{
  "success": false,
  "device": "10.10.10.1",
  "error": "Authentication failed for device 10.10.10.1."
}

Blocked dangerous command:

{
  "success": false,
  "device": "10.10.10.1",
  "error": "Blocked dangerous command: 'reload'"
}

Managed command rejected:

{
  "success": false,
  "device": "10.10.10.1",
  "error": "Command 'configure terminal' is managed automatically by the server. Do not include it in the command list."
}

Running Tests

pytest mcp_server/tests/ -v

Security

  • All inputs are validated before any device connection
  • Dangerous commands are blocked at the validation layer
  • No shell commands are executed on the MCP server host
  • Credentials are loaded from environment variables (never hardcoded)
  • SSH connections use secure authentication
  • Audit logs record every execution for compliance

Extending for Other Vendors

To add support for a new vendor (e.g., Juniper):

  1. Create mcp_server/connectors/juniper.py
  2. Implement the BaseConnector interface
  3. Update device inventory with platform type

The tool, validation, and audit layers remain unchanged.

License

Internal use only.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选