m# MCP-Forge:动态MCP服务器生成器与管理器
MCP-Forge 是一个强大的框架,用于动态生成、管理和监控模型上下文协议(MCP)服务器。通过使用官方的 MCP SDK,此工具允许您通过集中式界面按需创建专用的 MCP 服务器。
克隆仓库:
git clone https://github.com/iddv/mcp-forge.git
cd mcp-forge
创建虚拟环境:
python -m venv venv
source venv/bin/activate # 在Windows上:venv\Scripts\activate
安装所需依赖:
pip install -r requirements.txt
python forge_mcp_server.py --port 9000
使用客户端创建新服务器:
python client.py create name="my-server" description="我的自定义MCP服务器" capabilities=["echo","time","uptime"]
python client.py list --details
python client.py start <server-id>
python client.py stop <server-id>
python client.py restart <server-id>
python client.py info <server-id>
python client.py logs <server-id>
python client.py stats <server-id>
python client.py --port 9001 tools
python client.py delete <server-id>
MCP-Forge 支持对生成的服务器进行广泛的自定义:
python client.py create name="advanced-server" handlers=["file_reader","http_request"]
python client.py create name="storage-server" options={"persistence":"sqlite","auth":"basic"}
配置服务器组的自动扩展:
python client.py call manage_auto_scaling action="create_group" group_name="web-servers" min_instances=1 max_instances=
设置服务器的资源限制:
python client.py call set_resource_limit server_id="server-id" limit_name="cpu_percent" limit_value=50.0
获取和设置配置选项:
python client.py call get_config
python client.py call set_config section="server" key="log_level" value="debug"
访问并搜索所有服务器的日志:
python client.py call get_logs source="system" log_level="error" limit=50
python client.py call get_logs source="server-id" limit=100
获取所有服务器的实时状态信息:
python client.py call get_server_status
python client.py call get_server_status server_id="server-id"
访问系统或特定服务器的性能指标:
python client.py call get_metrics source="system" time_period="hour"
python client.py call get_metrics source="server-id" time_period="day"
管理和响应系统告警:
python client.py call get_alerts active_only=true
python client.py call acknowledge_alert alert_id="alert-id" user="admin"
python client.py call resolve_alert alert_id="alert-id" resolution_message="已解决问题"
MCP-Forge 包含全面的安全防护机制:
# 生成CSRF令牌以进行安全操作
python client.py call get_csrf_token session_id="your-session-id"
# 测试安全防护机制
python test_protection.py --host localhost --port 9000 --test all
MCP-Forge 实现了多层次的安全方法:
更多详情,请参阅安全防护文档。
mcp-forge/
├── forge_mcp_server.py # 核心锻造服务器
├── server_manager.py # 服务器实例管理
├── config_manager.py # 配置管理
├── auto_scaler.py # 自动扩展系统
├── resource_monitor.py # 资源监控
├── process_monitor.py # 进程监控
├── logging_system.py # 集中日志系统
├── log_aggregator.py # 日志聚合服务
├── status_reporter.py # 状态报告系统
├── metrics_collector.py # 性能指标收集
├── alerting_system.py # 关键问题告警系统
├── audit_logger.py # 安全审计日志系统
├── authentication_system.py # 认证和授权
├── protection_mechanisms.py # 安全防护机制
├── request_validator.py # 请求验证和净化
├── quota_manager.py # 资源配额管理
├── template_system/ # 生成服务器的模板系统
│ ├── template_manager.py # 模板加载和解析
│ ├── customization.py # 自定义点
│ ├── handlers/ # 自定义处理器模板
│ └── templates/ # 服务器模板
├── client.py # 与服务器交互的客户端
├── test_protection.py # 安全测试工具
├── servers/ # 生成的服务器脚本目录
├── docs/ # 文档目录
│ ├── api_specification.md # API规范
│ ├── security_protection.md # 安全文档
│ └── development_workflow.md # 开发指南
└── progress_tracker.py # 开发进度追踪实用程序
完整的API文档,请参阅docs/api_specification.md文件,其中包含详细信息:
MCP-Forge 的开发已完成100%,包括所有40个计划任务的实现,以及全面的安全防护机制。
运行python progress_tracker.py stats查看整体进度:
总任务数:40
完成:40(100.0%)
正在进行:0(0.0%)
未开始:0(0.0%)
阻塞:0(0.0%)
MIT