数据中心网络管理协议服务器

一个用于与Juniper Apstra Fabric Manager API交互的模型上下文协议服务器,支持通过自然语言命令管理数据中心网络基础设施。

  • by vignitin
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 vignitin/apstra-mcp-server

使用说明

Apstra MCP服务器

一种模型上下文协议(MCP)服务器,提供与Juniper Apstra结构管理器API交互的工具。使Claude和其他MCP客户端能够通过自然语言命令管理数据中心网络基础设施。

特性

  • 蓝图管理:创建、检索和删除蓝图配置
  • 基础结构查询:获取机架、路由区域和系统信息
  • 网络提供:使用高级配置选项和远程网关创建虚拟网络
  • 连接模板:管理连接模板和应用程序端点分配
  • 策略管理:从应用程序终结点应用和删除连接模板策略
  • 配置管理:检查部署状态和部署配置
  • 协议监控:监视BGP和其他协议会话
  • 异常检测:检索和分析蓝图异常
  • 原生流媒体支持:服务器发送事件的实时更新

快速开始

本地使用(stdio)

# Create config file
cp apstra_config_sample.json apstra_config.json
# Edit with your Apstra server details

# Run with stdio transport
python3 apstra_mcp.py -t stdio -f apstra_config.json

网络部署(流式HTTP)

Docker(推荐)

# Clone and configure
git clone <this-repo>
cd apstra-mcp-server
cp apstra_config_sample.json apstra_config.json
# Edit config with your Apstra details

# Start HTTP streaming server
docker-compose up -d

直接Python

# Install dependencies
pip install -r requirements.txt

# Start streamable HTTP server
python3 apstra_mcp.py -t streamable-http -H 0.0.0.0 -p 8080 -f apstra_config.json

安装

先决条件

  • Python 3.7+
  • 访问Juniper Apstra服务器
  • 有效的Apstra证书

依赖项

pip install -r requirements.txt

可用工具(共21个)

健康和状态工具(2个工具)

  • health() -服务器健康检查和Apstra连接状态
  • formatting_guidelines() -获取网络数据演示的格式指南

查询工具(12个工具)

  • get_bp() -获取蓝图信息
  • get_racks(blueprint_id) -获取机架信息
  • get_rz(blueprint_id) -获取路由区域
  • get_vn(blueprint_id) -获取虚拟网络
  • get_ct(blueprint_id) -获取连接模板
  • get_app_ep(blueprint_id) -获取连接模板的应用程序端点
  • get_system_info(blueprint_id) -获取系统/设备信息
  • get_protocol_sessions(blueprint_id) -获取协议会话
  • get_anomalies(blueprint_id) -获取蓝图异常
  • get_remote_gw(blueprint_id) -获取远程网关
  • get_diff_status(blueprint_id) -获取部署差异状态
  • get_templates() -获取可用模板

管理工具(3个工具)

  • deploy(blueprint_id, description, staging_version) -部署配置
  • delete_blueprint(blueprint_id) -删除蓝图
  • apply_ct_policies(blueprint_id, application_points) -将连接模板策略应用于/删除到应用程序终结点

创建工具(4个工具)

  • create_vn(blueprint_id, security_zone_id, vn_name, virtual_gateway_ipv4, ipv4_subnet, ...) -使用高级配置选项创建虚拟网络
  • create_remote_gw(blueprint_id, gw_ip, gw_asn, gw_name, local_gw_nodes, ...) -创建远程网关
  • create_datacenter_blueprint(blueprint_name, template_id) -创建数据中心蓝图
  • create_freeform_blueprint(blueprint_name) -创建自由形式的蓝图

安全模型

stdio传输(默认)

  • 默认情况下是安全的,没有网络暴露
  • 使用配置文件凭据
  • 非常适合与Claude Desktop集成

可流式传输http

  • 可通过本地FastMCP流媒体功能访问网络
  • 自动SSE升级以实现实时更新
  • 单容器部署

Claude桌面配置

增添 claude_desktop_config.json:

{
  "mcpServers": {
    "apstra": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp,httpx",
        "python3",
        "/path/to/apstra_mcp.py",
        "-f",
        "/path/to/apstra_config.json"
      ]
    }
  }
}

更新路径以匹配您的安装目录。

使用示例

使用克劳德桌面

  • “给我看看系统中的所有蓝图”
  • “使用网关192.168.1.1和子网192.168.1.0/24创建名为“web层”的虚拟网络”
  • “获取蓝图X中的所有连接模板”
  • “将连接模板策略Y应用于接口Z”
  • “显示连接模板的应用程序终结点”
  • “部署临时配置”
  • “检查蓝图X中是否有任何异常”

流式HTTP客户端

服务器在上公开了本机FastMCP端点 /mcp/* 具有流式响应的自动SSE升级功能。

建筑

  • FastMCP框架:具有自动SSE流的本地传输系统
  • 基于配置的身份验证:使用直接的Apstra API身份验证进行简单的无状态操作
  • 单个集装箱:端口8080上的HTTP服务器,具有可流式传输的HTTP

文档

故障排除

  • 身份验证失败:检查凭据和服务器连接
  • 工具未出现:在Claude Desktop日志中验证服务器启动
  • 传输错误:确保FastMCP版本兼容性
  • Docker问题:检查 docker-compose logs

许可证

本项目按原样提供,用于教育和示范目的。


博客文章: 数据中心网络MCP