使用说明
Clixon MCP服务器
A. 模型上下文协议 用于通过RESTCONF获取和查询网络设备配置的服务器。连接到基于Clixon(或任何支持RESTCONF)的设备,并使配置可用于OpenCode等AI编码代理。
此项目使用UV(https://github.com/astral-sh/uv)用于包装控制。
设置
uv sync
跑
uv run server.py --restconf-url https://localhost:8443/restconf/
CLI参数
| 参数 | 默认值 | 描述 |
|---|---|---|
--restconf-url |
https://localhost:8443/restconf/ |
用于从中获取配置的RESTCONF URL |
--restconf-username |
(空) | RESTCONF的HTTP基本身份验证用户名(可选) |
--restconf-password |
(空) | RESTCONF的HTTP基本身份验证密码(可选) |
--restconf-verify-ssl |
False |
获取RESTCONF配置时验证SSL证书 |
工具
| 工具 | 说明 |
|---|---|
fetch_config |
通过RESTCONF获取设备配置(支持基本身份验证和TLS) |
write_config |
通过RESTCONF将缓存的配置写回设备 |
get_config |
返回当前缓存的配置 |
get_config_path |
通过点分隔路径提取特定部分(例如。 ietf-interfaces:interfaces.interface) |
get_config_url |
返回用于获取配置的RESTCONF URL |
set_config_url |
设置用于获取配置的RESTCONF URL |
clear_config_cache |
清除缓存的配置 |
list_tools |
列出可用工具 |
help |
返回描述服务器和可用工具的帮助消息 |
资源
config://server-info--服务器元数据(名称、版本、可用工具)
提示
analyze_config--获取并分析设备配置(接口、路由等)
连接到OpenCode
添加到您的 opencode.json (~/.opencode/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"clixon": {
"type": "remote",
"url": "http://localhost:8000/mcp",
"enabled": true
}
}
}
OpenCode中的示例用法
连接后,问以下问题:
Fetch the config and summarize it.What interfaces are configured?Show me the routing configurationAre there any interfaces that are down?
AI代理将呼叫 fetch_config 要提取RESTCONF数据,请将其缓存在内存中,然后使用 get_config / get_config_path 回答有关设备配置的后续问题。
