Token导航 LogoToken导航TokenDH.com
FortiGate MCP Server logo
运维云端stdio官方级别未说明来源级核验

FortiGate MCP Server

MCP Server

FortiGate MCP Server 是一个全面的模型上下文协议(MCP)服务器,用于管理FortiGate设备,提供程序化访问并与MCP兼容工具(如Cursor)集成。

工具数

30

提示词数

0

GitHub Stars

0

资源数

0
设备管理PythonCursorCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

juststank

提供方

juststank

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv .venv

详细介绍

FortiGate MCP服务器

FortiGate MCP服务器-用于管理FortiGate设备的综合模型上下文协议(MCP)服务器。该项目提供对FortiGate设备的编程访问,并支持与Cursor等MCP兼容工具的集成。

🚀 特性

  • 设备管理:添加、删除和测试FortiGate设备的连接
  • 防火墙管理:列出、创建、更新和删除防火墙规则
  • 网络管理:管理地址和服务对象
  • 路由管理:管理静态路由和接口
  • HTTP传输:使用FastMCP的HTTP MCP协议
  • Docker支持:易于安装和部署
  • 光标集成:与Cursor IDE完全集成

📋 需求

  • Python 3.8+
  • FortiGate设备的访问权限
  • API令牌或用户名/密码

🛠️ 安装

1.克隆项目

git clone 
cd fortigate-mcp-server

2.安装依赖项

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # Linux/Mac
# or
.venv\Scripts\activate  # Windows

# Install dependencies
pip install -r requirements.txt

3.配置

编辑 config/config.json 文件:

{
  "fortigate": {
    "devices": {
      "default": {
        "host": "192.168.1.1",
        "port": 443,
        "username": "admin",
        "password": "password",
        "api_token": "your-api-token",
        "vdom": "root",
        "verify_ssl": false,
        "timeout": 30
      }
    }
  },
  "logging": {
    "level": "INFO",
    "file": "./logs/fortigate_mcp.log"
  }
}

🚀 用法

启动HTTP服务器

# Start with script
./start_http_server.sh

# Or manually
python -m src.fortigate_mcp.server_http \
  --host 0.0.0.0 \
  --port 8814 \
  --path /fortigate-mcp \
  --config config/config.json

使用Docker运行

# Build and start
docker-compose up -d

# View logs
docker-compose logs -f fortigate-mcp-server

🔧 光标MCP集成

1.光标MCP配置

编辑 ~/.cursor/mcp_servers.json 在光标中:

选项1:命令连接

{
  "mcpServers": {
    "fortigate-mcp": {
      "command": "python",
      "args": [
        "-m",
        "src.fortigate_mcp.server_http",
        "--host",
        "0.0.0.0",
        "--port",
        "8814",
        "--path",
        "/fortigate-mcp",
        "--config",
        "/path/to/your/config.json"
      ],
      "env": {
        "FORTIGATE_MCP_CONFIG": "/path/to/your/config.json"
      }
    }
  }
}

选项2:URL连接(推荐)

{
  "mcpServers": {
    "FortiGateMCP": {
      "url": "http://0.0.0.0:8814/fortigate-mcp/",
      "transport": "http"
    }
  }
}

2.在游标中使用

要在游标中使用FortiGate MCP:

  1. 启动服务器:
cd /media/workspace/fortigate-mcp-server
python -m src.fortigate_mcp.server_http --host 0.0.0.0 --port 8814 --path /fortigate-mcp --config config/config.json
  1. 重新启动游标
  2. 确保MCP服务器正在运行
  3. 在游标中使用FortiGate命令

📚 API命令

设备管理

  • list_devices -列出已注册的设备
  • get_device_status -获取设备状态
  • test_device_connection -测试连接
  • add_device -添加新设备
  • remove_device -删除设备
  • discover_vdoms -发现VDOM

防火墙管理

  • list_firewall_policies -列出防火墙规则
  • create_firewall_policy -创建新规则
  • update_firewall_policy -更新规则
  • delete_firewall_policy -删除规则

网络管理

  • list_address_objects -列出地址对象
  • create_address_object -创建地址对象
  • list_service_objects -列出服务对象
  • create_service_object -创建服务对象

虚拟IP管理

  • list_virtual_ips -列出虚拟IP
  • create_virtual_ip -创建虚拟IP
  • update_virtual_ip -更新虚拟IP
  • get_virtual_ip_detail -获取虚拟IP详细信息
  • delete_virtual_ip -删除虚拟IP

路由管理

  • list_static_routes -列出静态路线
  • create_static_route -创建静态路由
  • update_static_route -更新静态路由
  • delete_static_route -删除静态路由
  • get_static_route_detail -获取静态路线详细信息
  • get_routing_table -获取路由表
  • list_interfaces -列出接口
  • get_interface_status -获取接口状态

系统命令

  • health -健康检查
  • test_connection -连接测试
  • get_schema_info -架构信息

🧪 测试

运行测试

# Run all unit tests (default)
python -m pytest

# Run with coverage
python -m pytest --cov=src --cov-report=html

# Run specific test categories
python -m pytest tests/test_device_manager.py
python -m pytest tests/test_fortigate_api.py
python -m pytest tests/test_tools.py

# Run integration tests (requires server running)
python integration_tests.py

# Run only unit tests (default)
python -m pytest tests/

# Run with verbose output
python -m pytest -v

# Run with detailed error information
python -m pytest --tb=long

测试类别

  • 单元测试:测试单个组件和功能
  • 集成测试:测试HTTP服务器功能(需要服务器运行)
  • 覆盖:带有HTML输出的代码覆盖率报告

HTTP服务器测试

# Run test script
python test_http_server.py

手动测试

# Health check
curl -X POST http://localhost:8814/fortigate-mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "health", "params": {}}'

# List devices
curl -X POST http://localhost:8814/fortigate-mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "list_devices", "params": {}}'

📁 项目结构

fortigate-mcp-server/
├── src/
│   └── fortigate_mcp/
│       ├── __init__.py
│       ├── server_http.py          # HTTP MCP server
│       ├── config/                 # Configuration management
│       ├── core/                   # Core components
│       ├── tools/                  # MCP tools
│       └── formatting/             # Response formatting
├── config/
│   ├── config.json                # Main configuration
│   └── config.example.json        # Example configuration
├── examples/
│   └── cursor_mcp_config.json     # Cursor MCP config
├── logs/                          # Log files
├── tests/                         # Test files
├── docker-compose.yml             # Docker compose
├── Dockerfile                     # Docker image
├── start_http_server.sh           # Startup script
├── test_http_server.py            # Test script
└── README.md                      # This file

🔍 故障排除

常见问题

  1. 连接错误

- 确保FortiGate设备可访问 - 验证API令牌或用户名/密码 - 使用 verify_ssl: false SSL证书问题

  1. 端口冲突

- 确保端口8814可用 - 使用更改端口 --port 参数

  1. 配置错误

- 确保 config.json 格式正确 - 检查JSON语法

  1. 光标MCP连接问题

- 确保服务器正在运行 - 验证URL是否正确 - 重新启动游标

日志

使用以下方式检查日志:

# HTTP server logs
tail -f logs/fortigate_mcp.log

# Docker logs
docker-compose logs -f fortigate-mcp-server

🔒 安全

建议

  1. 使用API令牌

- 使用API令牌而不是用户名/密码 - 安全地存储令牌

  1. SSL证书

- 在生产中使用SSL证书 - 集 verify_ssl: true

  1. 网络安全

- 仅在安全网络上运行MCP服务器 - 使用防火墙规则限制访问

  1. 速率限制

- 启用速率限制 - 限制API调用

🤝 贡献

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

📄 许可证

该项目根据MIT许可证获得许可。看 LICENSE 文件以获取详细信息。

🙏 致谢

📞 支持

对于问题:

  • 使用 问题
  • 检查文档
  • 查看日志

______________________________________________________________________

备注:该项目已使用FortiGate设备进行了测试。请在投入生产前进行全面测试。

目录标签

目录标签

设备管理PythonCursor本地部署防火墙管理网络管理路由管理HTTP传输Docker支持

支持客户端

Cursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

30

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotokenremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP