FastAPI IP 路由器
该项目是一个FastAPI和MCP服务器应用程序,它提供了一个与Claude LLM的接口,用于管理诺基亚SROS设备上的IP前缀。它允许用户通过HTTP端点添加和删除IP前缀。该应用程序旨在未来与n8n集成,以实现工作流自动化。
项目结构
fastapi-ip-router
├── mcp
│ ├── server.py
├── src
│ ├── main.py # Entry point of the FastAPI application
│ ├── routers
│ │ └── ip_router.py # API routes for adding and deleting IP addresses
│ ├── services
│ │ └── sros_service.py # Logic for connecting to the SROS device
│ └── types
│ └── index.py # Custom types and data models
├── requirements.txt # Project dependencies
└── README.md # Project documentation安装说明
- 克隆存储库:
git clone
cd fastapi-ip-router设置您的项目
在文件中:
fastapi-ip-router
├── src
│ ├── services
│ │ └── sros_service.py # Logic for connecting to the SROS device输入您的身份证和路由器的IP地址
conn = connect(host="########PUT_YOUR_IP_HERE########",
username="########PUT_YOUR_USER_HERE########",
password="########PUT_YOUR_PASSWORD_HERE########",
hostkey_verify=False)- 创建虚拟环境:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`- 安装依赖项:
pip install -r requirements.txt- 运行应用程序:
uvicorn src.main:app --reload- 检查员MCP
uv run mcp dev server.py用法
- 获取公共IP:
- 端点: get - 请求正文:
{
N/A
}- 添加IP前缀:
- 端点: POST /ip-prefix - 请求正文:
{
"prefix-name": "xyz"
"prefix": "1.1.1.1/32"
}- 删除IP前缀:
- 端点: DELETE /ip-prefix - 请求正文:
{
"prefix-name": "xyz"
"prefix": "1.1.1.1/32"
}LM工作室配置MCP
- MCP配置
{
"mcpServers": {
"Demo": {
"command": "uv",
"args": [
"run",
"C:/Users/.../fastapi-ip-router/mcp/server.py"
]
}
}
}未来与n8n或LLM的集成
此FastAPI应用程序旨在轻松与n8n集成,允许自动工作流管理SROS设备上的IP前缀。随着项目的进展,将提供更多关于集成的文档。
