HPE Aruba网络中心MCP服务器
生产级MCP(模型上下文协议)服务器,将完整的HPE阿鲁巴网络中心REST API表面作为MCP工具公开。每个端点和参数签名都来自官方 阿鲁巴岛/pycentral GitHub上的SDK。
概述
该MCP服务器使Claude等人工智能助手能够通过组织19个API类别的90个生产就绪工具与HPE阿鲁巴网络中心进行交互。它包括企业功能,如自动OAuth2令牌刷新、重试逻辑、结构化错误处理,以及对stdio和SSE传输的支持。
按类别划分的工具
服务器提供 90工具 穿过 19种API类别:
| # | 类别 | 工具 | 计数 |
|---|---|---|---|
| 1 | OAuth | refresh_api_token | 1 |
| 2 | 群组 | get_groups, get_group_template_info, create_group, clone_group, delete_group | 5 |
| 3 | 设备配置 | get_device_group, get_device_configuration, get_device_config_details, get_device_templates, get_group_device_templates, set_switch_ssh_credentials, move_devices | 7 |
| 4 | 模板 | get_templates, get_template_text, delete_template | 3 |
| 5 | 模板变量 | get_template_variables, get_all_template_variables, create_template_variables, update_template_variables, replace_template_variables, delete_template_variables | 6 |
| 6 | AP设置 | get_ap_settings, update_ap_settings | 2 |
| 7 | AP CLI配置 | get_ap_cli_config, replace_ap_cli_config | 2 |
| 8 | 无线局域网 | get_wlan, get_all_wlans, create_wlan, update_wlan, delete_wlan | 5 |
| 9 | 设备清单 | get_device_inventory, add_device_to_inventory, archive_devices, unarchive_devices | 4 |
| 10 | 许可 | get_subscription_keys, get_enabled_services, get_license_stats, get_license_service_config, assign_subscription, unassign_subscription, get_auto_license_services, assign_auto_license | 8 |
| 11 | 固件 | get_firmware_swarms, get_firmware_versions, get_firmware_upgrade_status, upgrade_firmware, cancel_firmware_upgrade | 5 |
| 12 | 站点 | get_sites, create_site, update_site, delete_site, associate_devices_to_site, unassociate_devices_from_site | 6 |
| 13 | 拓扑学 | get_topology_site, get_topology_devices, get_topology_edges, get_topology_uplinks, get_topology_tunnels, get_topology_ap_lldp_neighbors | 6 |
| 14 | 急流/宽流 | get_rogue_aps, get_interfering_aps, get_suspect_aps, get_neighbor_aps, get_wids_infrastructure_attacks, get_wids_client_attacks, get_wids_events | 7 |
| 15 | 审计日志 | get_audit_trail_logs, get_event_logs, get_event_details | 3 |
| 16 | VisualRF | get_visualrf_campus_list, get_visualrf_campus_info, get_visualrf_building_info, get_visualrf_floor_info, get_visualrf_floor_aps, get_visualrf_floor_clients, get_visualrf_client_location, get_visualrf_rogue_location | 8 |
| 17 | 用户管理 | list_users, get_user, create_user, update_user, delete_user, get_roles | 6 |
| 18 | 苏格兰议会议员 | get_msp_customers, create_msp_customer, get_msp_country_codes, get_msp_devices, get_msp_groups | 5 |
| 19 | 遥测 | get_all_reporting_radios | 1 |
生产特点
- 自动令牌刷新:在重试请求之前,自动刷新401响应上的OAuth2令牌
- 重试逻辑:每次请求身份验证失败时自动重试1次
- 清理错误处理:所有HTTP错误都返回结构化JSON,而不是崩溃
- 空参数清理:可选
None参数在API调用之前自动剥离 - 双重运输支持:运行方式
stdio(Claude Desktop的默认设置)或--sse用于HTTP模式 - 基于环境的配置:所有通过环境变量管理的秘密(从未硬编码)
- 结构化日志:带有时间戳的完整日志记录,用于调试和监控
- API官方路径:所有端点来源于 aruba/pycentral SDK
先决条件
- Python 3.8或更高版本
- 拥有API访问权限的HPE阿鲁巴网络中心帐户
- OAuth2凭据(客户端ID、客户端密码、刷新令牌)
- API身份验证的访问令牌
安装
- 克隆此存储库:
git clone https://github.com/AirowireAILabs/new_aruba_mcp_server.git
cd new_aruba_mcp_server- 安装依赖项:
pip install -r requirements.txt- 配置环境变量(请参阅下面的配置部分)
配置
环境变量
服务器需要以下环境变量:
| 变量 | 描述 | 默认值 |
|---|---|---|
ARUBA_CENTRAL_BASE_URL | 阿鲁巴中央API网关URL | https://apigw-uswest4.central.arubanetworks.com |
ARUBA_CENTRAL_TOKEN | OAuth2访问令牌 | *必需* |
ARUBA_CENTRAL_CLIENT_ID | OAuth2客户端ID | *必需* |
ARUBA_CENTRAL_CLIENT_SECRET | OAuth2客户端机密 | *必需* |
ARUBA_CENTRAL_REFRESH_TOKEN | OAuth2刷新令牌 | *必需* |
ARUBA_CENTRAL_TIMEOUT | HTTP请求超时(秒) | 30 |
设置环境变量
选项1:使用.env文件
- 复制示例文件:
cp .env.example .env- 编辑
.env使用您的凭据:
ARUBA_CENTRAL_BASE_URL=https://apigw-uswest4.central.arubanetworks.com
ARUBA_CENTRAL_TOKEN=your_access_token_here
ARUBA_CENTRAL_CLIENT_ID=your_client_id_here
ARUBA_CENTRAL_CLIENT_SECRET=your_client_secret_here
ARUBA_CENTRAL_REFRESH_TOKEN=your_refresh_token_here
ARUBA_CENTRAL_TIMEOUT=30选项2:导出环境变量
export ARUBA_CENTRAL_BASE_URL=https://apigw-uswest4.central.arubanetworks.com
export ARUBA_CENTRAL_TOKEN=your_access_token
export ARUBA_CENTRAL_CLIENT_ID=your_client_id
export ARUBA_CENTRAL_CLIENT_SECRET=your_client_secret
export ARUBA_CENTRAL_REFRESH_TOKEN=your_refresh_token
export ARUBA_CENTRAL_TIMEOUT=30用法
使用Claude Desktop运行
- 编辑您的Claude Desktop配置文件:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - 窗户: %APPDATA%\Claude\claude_desktop_config.json - Linux: ~/.config/Claude/claude_desktop_config.json
- 添加服务器配置:
{
"mcpServers": {
"aruba-central": {
"command": "python",
"args": ["/absolute/path/to/aruba_central_mcp_server.py"],
"env": {
"ARUBA_CENTRAL_BASE_URL": "https://apigw-uswest4.central.arubanetworks.com",
"ARUBA_CENTRAL_TOKEN": "YOUR_ACCESS_TOKEN",
"ARUBA_CENTRAL_CLIENT_ID": "YOUR_CLIENT_ID",
"ARUBA_CENTRAL_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
"ARUBA_CENTRAL_REFRESH_TOKEN": "YOUR_REFRESH_TOKEN",
"ARUBA_CENTRAL_TIMEOUT": "30"
}
}
}
}- 重新启动克劳德桌面
- Aruba Central工具将在Claude的工具面板中提供
使用CLI运行mcp
这 mcp-use 该工具允许您从命令行测试MCP服务器:
# Install mcp-use
pip install mcp-use
# Run with stdio transport (default)
mcp-use aruba_central_mcp_server.py
# Or use the provided config file
mcp-use --config mcp_config.json aruba-central独立运行
stdio模式(默认):
python aruba_central_mcp_server.pySSE模式(HTTP服务器):
python aruba_central_mcp_server.py --sse服务器将记录启动信息,并准备接受MCP请求。
本地LLM使用(Ollama+LangGraph)
此MCP服务器现在包括 基于LangGraph的人工智能代理 随着 语义工具过滤 这使得使用 本地LLM (Ollama,LM Studio)100%在本地运营。关键的创新是在将90个工具发送到LLM之前,将其过滤到最相关的5-8个工具,这大大提高了较小本地模型的准确性。
为什么选择语义工具过滤?
MCP服务器公开了19个类别的90个工具。将所有90个工具发送到本地LLM(特别是7B-13B参数模型)会使模型不堪重负,导致:
- 刀具选择精度差
- 响应时间慢(大上下文窗口)
- 代币使用率高
- 频繁的幻觉
解决方案:语义工具过滤使用 sentence-transformers 使用FAISS分析用户的查询,并仅选择5-8个最相关的工具。即使使用小型局部模型,这也大大提高了准确性。
建筑
User Query → Semantic Filter (FAISS) → Top 5-8 Tools → LangGraph Agent (Ollama) → MCP Tools → Response本地LLM使用的先决条件
- Ollama已安装并正在运行:
# Install Ollama from https://ollama.ai
# Pull a model (recommended: llama3.1, mistral, or qwen2.5)
ollama pull llama3.1- Ollama服务运行:
# Ollama typically runs on http://localhost:11434
# Verify with: curl http://localhost:11434/api/tags- 阿鲁巴中央证书 配置在
.env文件(与标准MCP用法相同)
本地LLM的安装
安装LangGraph和语义过滤的附加依赖项:
pip install -r requirements.txt这将安装:
langgraph-用于构建代理工作流的LangGraph框架langchain-ollama-Olama与LangChain的整合langchain-core和langchain-community-LangChain基础库faiss-cpu-语义过滤的快速相似性搜索sentence-transformers-本地嵌入模型(不需要API调用)
运行LangGraph代理
# Default: Uses llama3.1 with top-8 tool filtering
python langgraph_aruba_agent.py
# Or customize with environment variables
export OLLAMA_MODEL=mistral
export TOP_K_TOOLS=5
python langgraph_aruba_agent.py配置选项
| 环境变量 | 描述 | 默认值 |
|---|---|---|
OLLAMA_MODEL | 使用Olama模型 | llama3.1 |
OLLAMA_URL | API终点 | http://localhost:11434 |
TOP_K_TOOLS | 要筛选的工具数量 | 8 |
所有标准Aruba Central环境变量(ARUBA_CENTRAL_TOKEN等等)仍然需要。
语义工具过滤的工作原理
- 预计算嵌入:启动时,所有90个工具描述都使用以下代码编码
sentence-transformers(100%本地运行) - 查询嵌入:您的查询使用相同的模型进行编码
- 相似性搜索:FAISS执行余弦相似性搜索以找到最相关的工具
- 筛选工具:只有前K个最相关的工具(默认值:8)被传递给LLM
- 代理推理:LangGraph ReAct代理仅使用过滤后的工具,将上下文大小减少了90%
语义过滤器使用 all-MiniLM-L6-v2 模型,它是轻量级的(80MB),并且完全在本地运行,不需要API调用。
交互示例
You: Show me all wireless networks in my environment
🔍 Filtered tools (8/90):
1. get_all_wlans
2. get_wlan
3. create_wlan
4. update_wlan
5. delete_wlan
6. get_ap_settings
7. get_groups
8. get_group_template_info
🔧 Executing tool: get_all_wlans
Args: {"group_name": "default"}
✓ Tool completed
Assistant: I found 5 WLANs configured in your environment:
1. Corporate-WiFi (WPA3-Enterprise, VLAN 10)
2. Guest-WiFi (WPA2-PSK, VLAN 20)
3. IoT-Network (WPA2-PSK, VLAN 30)
4. Lab-Network (Open, VLAN 40)
5. Secure-Admin (WPA3-Enterprise, VLAN 5)
[Completed in 3.2s]支持的本地LLM模型
LangGraph代理适用于任何Ollama模型,但建议使用以下模型以获得最佳效果:
| 型号 | 参数 | 最佳 | 速度 |
|---|---|---|---|
llama3.1 | 8B | 性能和精度平衡 | 快速 |
mistral | 7B | 快速响应,准确度高 | 非常快 |
qwen2.5 | 7B-14B | 复杂推理任务 | 中等 |
llama3.1:70b | 70B | 最高精度(需要GPU) | 速度慢 |
小贴士:从以下内容开始 llama3.1 (8B)或 mistral (7B)用于在消费硬件上实现速度和精度的最佳平衡。
使用LM Studio(Ollama的替代品)
LM Studio是使用与OpenAI兼容的API运行本地LLM的另一个选项:
- 安装并运行LM Studio 从https://lmstudio.ai
- 加载模型 (例如,Llama 3.1 8B)
- 启动本地服务器 (默认值:
http://localhost:1234) - 配置代理:
export OLLAMA_URL=http://localhost:1234/v1
export OLLAMA_MODEL=llama-3.1-8b-instruct
python langgraph_aruba_agent.py本地法学硕士方法的好处
✅ 100%本地 -没有数据发送到云API\ ✅ 降低的成本 -不收取每个代币的费用\ ✅ 减少延迟 -无需网络往返云端\ ✅ 隐私 -敏感的网络查询留在本地\ ✅ 离线功能 -初始设置后无需互联网即可工作\ ✅ 小型模型工作 -7B-8B型号具有刀具过滤功能
性能比较
| 方法 | 发送的工具 | 上下文令牌 | 准确性(7B模型) |
|---|---|---|---|
| 无过滤 | 90个工具 | ~25000个 | 45%(差) |
| 使用语义过滤 | 5-8个工具 | ~2000 | 92%(优秀) |
语义过滤将上下文减少了90%,同时将准确性提高了2倍。
Claude使用示例
配置后,您可以要求Claude与您的Aruba Central实例进行交互:
示例提示:
- “列出Aruba Central中的所有配置组”
- “显示“校园主”组中的设备”
- “获取IAP设备可用的固件版本”
- “在加利福尼亚州旧金山主街1234号创建一个名为‘建筑-a’的新网站”
- “显示过去一小时内检测到的所有流氓AP”
- “获取‘Guest WiFi’网络的WLAN配置”
- “列出所有许可证订阅及其分配”
