一个强大且精心设计的Python MCP(模型上下文协议)服务器,用于访问NetBox基础设施,旨在教授新程序员并支持生产使用。
100%测试成功率 - 所有测试通过,测试套件简化
# 克隆仓库
git clone https://github.com/fringemonkey/mcp-dc.git
cd mcp-dc
# 安装依赖
pip install -r requirements.txt
pip install -r requirements-dev.txt
# 运行测试
python -m pytest tests/ -v
设置环境变量:
export NETBOX_URL="http://your-netbox-instance"
export VAULT_ADDR="http://your-vault-instance"
export VAULT_TOKEN="your-vault-token"
export POSTGRES_HOST="localhost"
export POSTGRES_DB="mcp_state"
export POSTGRES_USER="mcp_user"
export POSTGRES_PASSWORD="mcp_password"
# 运行所有测试
python -m pytest tests/ -v
# 运行特定测试类别
python -m pytest tests/ -m unit
python -m pytest tests/ -m integration
python -m pytest tests/ -m performance
# 运行带有覆盖率报告
python -m pytest tests/ --cov=src --cov-report=html
# 格式化代码
black src/ tests/
isort src/ tests/
# 检查代码
flake8 src/ tests/
mypy src/
# 安全检查
bandit -r src/
safety check
mcp-dc/
├── src/ # 源代码
│ ├── server.py # 主MCP服务器
│ ├── netbox_client.py # NetBox API客户端
│ ├── vault_client.py # Vault认证
│ ├── state_confidence.py # PostgreSQL客户端
│ ├── structured_protocol.py # JSON协议
│ ├── llm_optimizer.py # LLM优化
│ ├── llm_mcp_server.py # LLM MCP服务器
│ ├── structured_mcp_server.py # 结构化MCP服务器
│ └── tools/ # MCP工具
│ ├── hosts.py
│ ├── virtual_machines.py
│ ├── ip_addresses.py
│ └── vlans.py
├── tests/ # 测试套件
│ ├── test_server.py
│ ├── test_llm_optimization.py
│ ├── test_simple_performance.py
│ └── test_structured_protocol.py
├── examples/ # 示例脚本
├── scripts/ # 实用脚本
├── docs/ # 文档
└── .devcontainer/ # 开发容器
list_hosts - 列出所有设备get_host - 获取特定设备详细信息search_hosts - 按条件搜索设备list_vms - 列出所有虚拟机get_vm - 获取特定虚拟机详细信息list_vm_interfaces - 列出虚拟机接口list_ips - 列出所有IP地址get_ip - 获取特定IP详细信息search_ips - 搜索IP地址list_vlans - 列出所有VLANget_vlan - 获取特定VLAN详细信息list_vlan_ips - 列出VLAN中的IP地址该项目旨在教授:
本项目采用MIT许可证 - 查看LICENSE文件以获取详细信息。
已准备好进行生产部署! 🚀
版本1.0 - 零测试失败,全面功能,生产就绪