PCF-MCP服务器
基于Golang的模型上下文协议(MCP)服务器,与Pentest协作框架(PCF)集成,使AI助手能够与Pentest项目交互,管理安全发现,并在安全评估方面进行协作。
特性
- MCP协议支持:全面实施AI助手集成的模型上下文协议
- PCF集成:用于Pentest协作框架操作的完整API客户端
- 多运输:支持stdio(功能齐全)和HTTP(无状态)传输
- 云原生:构建时考虑了Kubernetes、可观察性和容器化
- 全面配置:支持CLI参数、环境变量、配置文件和Kubernetes ConfigMaps
- 生产就绪可观察性:
- 与OpenTetry(OTEL)兼容的分布式跟踪 - Prometheus兼容指标 - 具有可配置级别的结构化日志记录
快速开始
先决条件
- 达到1.21或更高
- Docker(可选,用于容器化部署)
- 访问PCF实例
安装
# Clone the repository
git clone https://github.com/aRustyDev/pcf-mcp
cd pcf-mcp
# Install dependencies
just deps
# Run tests
just test
# Build the binary
just build跑步
# Run with default configuration
./bin/pcf-mcp
# Run with custom PCF endpoint
./bin/pcf-mcp --pcf-url http://localhost:5000 --pcf-api-key your-api-key
# Run with environment variables
export PCF_MCP_PCF_URL=http://localhost:5000
export PCF_MCP_PCF_API_KEY=your-api-key
./bin/pcf-mcp码头工人
# Build Docker image
just docker
# Run container
docker run -p 8080:8080 pcf-mcp:latest配置
服务器支持分层配置(按优先级顺序):
- 命令行参数
- 环境变量(前缀为
PCF_MCP_) - 配置文件(YAML/JSON/TOML)
- Kubernetes配置映射
- 默认值
配置文件示例
server:
host: "0.0.0.0"
port: 8080
transport: "stdio" # or "http"
pcf:
url: "http://localhost:5000"
api_key: "your-api-key"
timeout: 30s
logging:
level: "info" # debug, info, warn, error
format: "json" # or "text"
metrics:
enabled: true
port: 9090
tracing:
enabled: true
exporter: "jaeger" # or "zipkin", "otlp"
endpoint: "http://localhost:14268/api/traces"MCP工具可用
- 项目管理
- list_projects:列出所有最重要的项目 - create_project:创建新项目 - update_project:更新项目详细信息
- 主机管理
- list_hosts:列出项目中的主机 - add_host:添加新主机 - update_host:更新主机信息
- 问题跟踪
- list_issues:列出安全问题 - create_issue:创建新的安全发现 - update_issue:更新问题详细信息
- 凭据存储
- list_credentials:列出存储的凭据 - add_credential:存储新凭据 - get_credential:检索特定凭据
- 报告生成
- generate_report:生成各种格式的报告
发展
项目结构
pcf-mcp/
├── cmd/pcf-mcp/ # Main application entry point
├── internal/
│ ├── config/ # Configuration management
│ ├── pcf/ # PCF client implementation
│ ├── mcp/ # MCP server implementation
│ ├── observability/ # Tracing, metrics, logging
│ └── transport/ # Stdio and HTTP transports
├── pkg/ # Public packages
├── tests/ # Test files
├── docs/ # Documentation
├── Dockerfile # Multi-stage build
├── justfile # Task automation
├── go.mod & go.sum # Dependencies
└── README.md # This file测试
# Run all tests
just test
# Run quick tests (no coverage)
just test-quick
# Run integration tests
just test-integration
# View coverage report
just cover建筑
# Build for current platform
just build
# Build Docker image
just docker
# Clean build artifacts
just clean文档
CI/CD
该项目使用GitHub Actions进行持续集成和部署。
容器图像
预构建的容器图像可在以下网址获得:
- Docker Hub:
arustydev/pcf-mcp - GitHub容器注册表:
ghcr.io/arustydev/pcf-mcp
# Pull from Docker Hub
docker pull arustydev/pcf-mcp:latest
# Pull from GitHub Container Registry
docker pull ghcr.io/arustydev/pcf-mcp:latest自动化工作流程
- CI管道:在每次推送和PR上运行(测试、linting、安全扫描)
- Docker发布:在主分支更新时构建和发布多拱形图像
- 释放管道:在标签上创建GitHub版本和版本图像
所有图片均为:
- 多架构(amd64、arm64)
- 与Cosign签字验证
- 已扫描漏洞
- 包括SBOM(软件物料清单)
看 有关详细的CI/CD文档。
部署
请参阅 部署指导 有关以下内容的详细说明:
- 当地开发设置
- Docker部署
- Docker编写配置
- Kubernetes部署示例
- 生产最佳实践
可观测性
指标
Prometheus指标公开于 /metrics 端点(默认端口9090):
pcf_mcp_requests_total:MCP请求总数pcf_mcp_request_duration_seconds:请求持续时间直方图pcf_mcp_active_connections:当前活动连接
追踪
OpenTetry跟踪支持多个导出器:
- 猎手
- 斯普肯
- OTLP
日志记录
结构化日志记录,支持:
- JSON和文本格式
- 可配置的日志级别
- Kubernetes友好输出
贡献
- 分叉存储库
- 创建要素分支
- 先写测试(TDD)
- 实现您的功能
- 确保所有测试通过
- 提交拉取请求
许可证
支持
版本历史记录
看 更改日志.md 查看版本历史和发行说明。
