IP前缀管理工具

一个基于FastAPI和MCP Server的应用程序,用于通过HTTP端点管理Nokia SROS设备上的IP前缀,支持添加和删除操作,并设计用于与n8n集成实现工作流自动化。

  • by drupertifranco
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 drupertifranco/mcp-api-sros

使用说明

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

安装说明

  1. 克隆存储库:

    git clone <repository-url>
    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)
    
  2. 创建虚拟环境:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  3. 安装依赖项:

    pip install -r requirements.txt
    
  4. 运行应用程序:

    uvicorn src.main:app --reload
    
  5. 检查员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前缀。随着项目的进展,将提供更多关于集成的文档。