网络设备管理服务器

一个基于gNOI的模型上下文协议(MCP)服务器,提供网络设备管理功能,包括获取设备时间、支持不安全的gRPC连接等。

  • by hdwhdw
  • Go
  • 本地部署
  • 更新于
在 GitHub 查看 hdwhdw/gnxi-mcp

使用说明

GNXI MCP服务器

一种模型上下文协议(MCP)服务器,使用gNOI(gRPC网络操作接口)提供网络设备管理功能。

特性

  • 通过gNOI系统获取设备时间。时间服务
  • 支持不安全的gRPC连接
  • 可配置的设备地址和端口

用法

建筑

构建所有组件:

go build -o gnxi-mcp-server ./cmd
go build -o test-client ./cmd/test-client
go build -o demo-client ./cmd/demo-client

运行服务器

服务器通过stdin/stdout(MCP stdio传输)运行:

./gnxi-mcp-server

测试

测试服务器是否正常工作:

./test-client

使用特定设备IP进行演示:

./demo-client 192.168.1.100

MCP工具:get_device_time

使用gNOI从网络设备检索当前系统时间。

参数:

  • host (必填):设备主机名或IP地址
  • port (必需):gRPC端口号(默认值:9339)
  • insecure (可选):使用不安全的连接(默认值:true)

例子:

{
  "host": "192.168.1.1",
  "port": 9339,
  "insecure": true
}

期望输出

成功 (当设备可访问时):

✅ Successfully got device time:
Device 192.168.1.1:9339 time: 2024-11-24T16:30:45Z (timestamp: 1732467045000000000)

错误 (当设备无法访问时):

❌ Error calling device:
rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 192.168.1.1:9339: connection refused"