Network Incident MCP
Network Incident MCP Demo
一个小型演示/原型,展示 LLM 智能体(Google Gemini)如何使用 Model Context Protocol (MCP) 对模拟网络事件进行分诊:获取设备遥测数据、检查系统日志、判断是否需要采取行动,并执行修复步骤——所有这些都通过本地 MCP 服务器暴露的工具完成。
这是一个用于学习/演示目的的原型。所有网络数据都是假的,硬编码在 mcp_server/mock_network_db.py 中。没有真实的网络后端。
工作原理
mcp_server/—— 一个 MCP 服务器,暴露:get_device_telemetry(device_id)—— 设备状态、光功率、BGP 翻动get_latest_syslog()—— 最近的 syslog 行apply_traffic_reroute(source_pop, target_pop, circuit_id)—— 一个模拟修复操作(拒绝任何不是已知健康 PoP 的目标)incident_triage_prompt(device_id)—— 一个提示词模板,描述分诊步骤和 -20.0 dBm 重路由阈值
agent/gemini_mcp_client.py—— 一个客户端,它启动 MCP 服务器,将其工具作为函数调用工具交给 Gemini,并运行一个循环:Gemini 决定下一步调用哪个工具,客户端通过 MCP 执行该工具并将结果反馈回去,直到 Gemini 给出最终答案。
Related MCP server: Pulse
设置
git clone <your-repo-url>
cd network-incident-mcp
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt运行测试
python3 -m pytest tests/独立运行 MCP 服务器
python3 mcp_server/server.py运行实际智能体
需要从 Google AI Studio 获取 Gemini API 密钥:
export GEMINI_API_KEY=your-key-here
python3 agent/gemini_mcp_client.py示例输出
智能体被指向模拟设备 router-van-01,该设备被模拟为 DEGRADED 状态,光功率为 -28.5 dBm——低于 -20.0 dBm 的重路由阈值。一次实际运行如下所示:
(venv) ac@ubuntuserver2026:~/network-incident-mcp$ python3 agent/gemini_mcp_client.py
Processing request of type ListToolsRequest
[+] Connected to MCP. Registered 3 tools with Gemini 3.6 Flash.
Processing request of type GetPromptRequest
[--> Model Tool Call Request]: get_device_telemetry({'device_id': 'router-van-01'})
Processing request of type CallToolRequest
[<-- MCP Execution Output]: {
"device_id": "router-van-01",
"data": {
"status": "DEGRADED",
"location": "Vancouver PoP",
"bgp_flaps": 14,
"optical_power_dbm": -28.5,
"circuits": [
"fiber-van-richmond-10G"
]
}
}
[--> Model Tool Call Request]: get_latest_syslog({})
Processing request of type CallToolRequest
[<-- MCP Execution Output]:
[2026-08-24T10:12:01Z] WARN router-van-01 BGP neighbor 192.168.10.1 DOWN (Retries: 3)
[2026-08-24T10:12:15Z] CRIT router-van-01 Optical signal loss detected on fiber-van-richmond-10G (-28.5 dBm)
[2026-08-24T10:14:02Z] WARN router-van-01 Packet loss spike: 18.4% on interface ge-0/0/1
[--> Model Tool Call Request]: apply_traffic_reroute({'target_pop': 'Richmond PoP', 'circuit_id': 'fiber-van-richmond-10G', 'source_pop': 'Vancouver PoP'})
Processing request of type CallToolRequest
[<-- MCP Execution Output]: {
"status": "ERROR",
"error": "Target PoP 'Richmond PoP' is not a known healthy PoP. Healthy PoPs: ['Toronto PoP']"
}
[--> Model Tool Call Request]: apply_traffic_reroute({'circuit_id': 'fiber-van-richmond-10G', 'target_pop': 'Toronto PoP', 'source_pop': 'Vancouver PoP'})
Processing request of type CallToolRequest
[<-- MCP Execution Output]: {
"status": "SUCCESS",
"action": "Traffic shifted from Vancouver PoP to Toronto PoP",
"isolated_circuit": "fiber-van-richmond-10G",
"new_route_metric": 10
}
[Model Final Response]: ### Incident Analysis Summary for `router-van-01`
1. **Device Telemetry Analysis**
- **Device ID:** `router-van-01`
- **Location:** Vancouver PoP
- **Device Status:** DEGRADED
- **Optical Power Level:** **-28.5 dBm**
- **BGP Flaps:** 14
- **Active Circuit:** `fiber-van-richmond-10G`
2. **Syslog Inspection**
- Critical optical signal loss log detected:
`[2026-08-24T10:12:15Z] CRIT router-van-01 Optical signal loss detected on fiber-van-richmond-10G (-28.5 dBm)`
- Additional warnings observed regarding BGP neighbor timeouts and interface packet loss spikes (`ge-0/0/1`).
3. **Remediation Action**
- **Condition Met:** Optical power level (-28.5 dBm) is below the threshold of -20.0 dBm.
- **Action Taken:** Executed `apply_traffic_reroute`.
- **Circuit:** `fiber-van-richmond-10G`
- **Source PoP:** Vancouver PoP
- **Target PoP:** Toronto PoP
- **Status:** **SUCCESS** — Traffic successfully rerouted from Vancouver PoP to Toronto PoP, isolating circuit `fiber-van-richmond-10G`.请注意,模型的第一次重路由尝试目标是 Richmond PoP,而它在模拟数据中并不是一个真实、健康的位置——服务器以 ERROR 拒绝该请求,而不是静默成功;模型随后改用正确的健康目标(Toronto PoP)重试,最终成功。
公共 HTTP 演示(无需 API 密钥)
web/app.py 是一个围绕相同模拟遥测/重路由逻辑的小型 FastAPI 封装,以普通 REST 端点形式暴露——不需要 MCP 客户端,也不需要 Gemini API 密钥。/triage/{device_id} 用 Python 以确定性方式重新实现了“获取 → 检查 → 重路由”流程(不通过 LLM),因此可以免费且安全地公开暴露。
本地运行:
uvicorn web.app:app --host 127.0.0.1 --port 8001然后,在另一个终端中:
curl http://127.0.0.1:8001/devices
curl http://127.0.0.1:8001/telemetry/router-van-01
curl http://127.0.0.1:8001/syslog
curl http://127.0.0.1:8001/triage/router-van-01 # degraded device -> auto-reroutes
curl http://127.0.0.1:8001/triage/router-yyz-02 # healthy device -> no reroute备注
需要
mcp<2(已在requirements.txt中固定版本)——服务器使用 v1FastMCPAPI。Gemini 模型的可用性会随时间变化;如果遇到
404模型未找到错误,请列出你的 API 密钥可用的模型,并更新agent/gemini_mcp_client.py中的模型名称。每次运行的工具调用轮数设有上限(
GeminiMCPOrchestrator.MAX_TURNS,默认 5),以避免 API 使用量失控。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with direct access to multi-vendor network devices for tasks like configuration management, health checks, and topology discovery through 35 specialized tools. It enables natural language control over platforms including Cisco, Juniper, and Nokia using SSH, NETCONF, and SNMP protocols.11MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to investigate and manipulate live network simulations via MCP, including protocol debugging and fault injection.
- AlicenseAqualityDmaintenanceAn MCP server that exposes live network monitoring data as Resources and diagnostic capabilities as Tools, letting AI assistants query network health conversationally.6MIT
- AlicenseNot gradedqualityBmaintenanceExposes network-monitoring tools (query metrics, analyze windows, compare, logs, status, runbooks, speed tests) as an MCP server for agentic workflows. Designed with evaluation suites, cost-aware model routing, and semantic tool retrieval.MIT
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Phone, SMS & email for AI agents — one remote MCP endpoint, OAuth login, zero install.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/asif-c/network-incident-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server