⚠️ 存储库已存档
此项目不再维护或更新。由于继续开发的时间和带宽有限,我正在归档此存储库。
Nautobot MCP
这个Nautobot应用程序将MCP(模型上下文协议)服务器与Nautobot集成在一起,为网络自动化和管理提供了AI就绪的工具和接口。
概述
Nautobot MCP使AI助手或应用程序能够通过标准化协议与您的网络数据进行交互。该应用程序与Nautobot一起运行MCP服务器,该服务器公开了可供AI系统使用的工具。
https://modelcontextprotocol.io/introduction
使用Librechat的演示-连接到Nautobot MCP
https://github.com/user-attachments/assets/283d68c2-d35f-4506-b909-45c1850e7281
安装
1.安装包装
pip install nautobot-mcp2.在Nautobot配置中添加到INSTALLED_APPS
# In your nautobot_config.py
PLUGINS = [
"nautobot_mcp",
# ... other plugins
]3.配置
通过Nautobot的配置系统配置应用程序:
# In your nautobot_config.py
PLUGINS_CONFIG = {
"nautobot_mcp": {
"MCP_PORT": 8005, # MCP server port
"MCP_HOST": "0.0.0.0", # Default is 0.0.0.0
"MCP_CUSTOM_TOOLS_DIR": "/path/to/your/custom/tools", # Directory for custom tools
"MCP_LOAD_CORE_TOOLS": False, # Load built-in tools
},
}4.升级后运行nautobot
nautobot-server post_upgrade自定义工具
您可以通过在中指定的目录中定义Python函数来创建自己的自定义工具 MCP_CUSTOM_TOOLS_DIR.
自定义工具示例:
# In /path/to/your/custom/tools/my_tools.py
def some_tool(param1: str, param2: str) -> dict:
"""Some tool description"""
# Your implementation here
return {"result": f"Tool result for {param1} and {param2}"}MCP服务器将自动发现并注册指定目录中的所有基于功能的工具。
部署选项
方法1:手动启动
您可以手动启动MCP服务器:
nautobot-server start_mcp_server方法2:系统化服务(推荐用于生产)
在以下位置创建systemd服务文件 /etc/systemd/system/nautobot-mcp.service:
[Unit]
Description=Nautobot MCP Server
After=network-online.target
Wants=network-online.target
[Service]
User=nautobot
Group=nautobot
WorkingDirectory=/opt/nautobot
ExecStart=/opt/nautobot/venv/bin/nautobot-server start_mcp_server
Restart=on-failure
RestartSec=30
PrivateTmp=true
[Install]
WantedBy=multi-user.target然后启用并启动服务:
sudo systemctl daemon-reload
sudo systemctl enable --now nautobot-mcp.service查看可用工具
您可以在Nautobot web界面中查看所有已注册的工具,网址为:
https://your-nautobot-server/plugins/nautobot-mcp/tools/此页面显示了所有可用的工具、它们的描述、模块路径和参数规范。
全部
- \[\]添加一种将工具执行路由到特定Nautobot worker的方法。
- \[\]增强Nautobot web界面中的工具视图,以显示工具使用统计数据。
- \[\]创建一个docker容器来运行MCP服务器。
- \[\]添加测试。
许可证
此项目在Apache License 2.0下获得许可-有关详细信息,请参阅License文件。
