ContainerLab MCP服务器
用于管理容器化网络实验室的Python MCP服务器 集装箱实验室API.
工具
| 工具 | 说明 |
|---|---|
authenticate | 使用ContainerLab API服务器进行身份验证(可选-自动身份验证处理此问题) |
listLabs | 列出所有可用的实验室 |
deployLab | 部署一个具有拓扑定义的新实验室 |
inspectLab | 获取实验室详细信息、节点状态、管理IP |
execCommand | 在一个或所有实验室节点上执行命令 |
destroyLab | 摧毁实验室,清理资源 |
先决条件
跑步 ContainerLab API服务器 其中Linux用户被配置为进行身份验证。
# On the ContainerLab host:
sudo groupadd -f clab_admins && sudo groupadd -f clab_api
sudo useradd -m -s /bin/bash netclaw 2>/dev/null || true
sudo usermod -aG clab_admins netclaw && sudo passwd netclaw
# If the API server runs in Docker, restart it to pick up the new user:
docker restart clab-api-server安装
pip install -r requirements.txt环境变量
| 变量 | 默认值 | 描述 |
|---|---|---|
CLAB_API_SERVER_URL | http://localhost:8080 | containerlab API服务器URL |
CLAB_API_USERNAME | admin | API用户名 |
CLAB_API_PASSWORD | password | API密码 |
用法
独立(stdio MCP服务器)
python3 -u clab_mcp_server.py使用NetClaw的mcp-call.py
python3 mcp-call.py "python3 -u clab_mcp_server.py" listLabs '{}'
python3 mcp-call.py "python3 -u clab_mcp_server.py" deployLab '{"topologyContent":{"name":"demo","topology":{"nodes":{"srl1":{"kind":"nokia_srlinux","image":"ghcr.io/nokia/srlinux:latest"}},"links":[]}}}'
python3 mcp-call.py "python3 -u clab_mcp_server.py" inspectLab '{"labName":"demo","details":true}'
python3 mcp-call.py "python3 -u clab_mcp_server.py" execCommand '{"labName":"demo","nodeName":"srl1","command":"show version"}'
python3 mcp-call.py "python3 -u clab_mcp_server.py" destroyLab '{"labName":"demo","cleanup":true,"graceful":true}'支持的节点类型
ContainerLab支持多种网络操作系统。常见示例:
| 种类 | 平台 | 示例图片 |
|---|---|---|
cisco_iosxr | 思科IOS XR | ios-xr/xrd-control-plane:latest |
cisco_iosxe | 思科IOS XE(Cat8000v) | c8000v:latest |
cisco_nxos 思科 NX-OS(Nexus 9000v) n9kv:latest | ||
cisco_ftdv | 思科Firepower FTDv | ftdv:latest |
cisco_csr1000v | 思科CSR 1000v | csr1000v:latest |
nokia_srlinux | 诺基亚SR Linux | ghcr.io/nokia/srlinux:latest |
ceos Arista CEOS | ceos:latest | |
juniper_crpd | Juniper cRPD | crpd:latest |
juniper_vjunosswitch | Juniper vJunos交换机 | vrnetlab/vr-vjunosswitch:latest |
juniper_vjunosrouter | Juniper vJunos路由器 | vrnetlab/vr-vjunosrouter:latest |
frr | FR路由 | frrouting/frr:latest |
linux | 通用Linux | alpine:latest |
paloalto_panos 帕洛阿尔托 PAN-OS panos:latest | ||
fortinet_fortigate | Fortinet FortiGate | fortigate:latest |
有关完整列表,请参阅 ContainerLab文档.
许可证
麻省理工学院
