一个用于YARA扫描的模型上下文协议(MCP)服务器,提供给大型语言模型(LLMs)分析文件的能力。
YaraFlux MCP Server 允许AI助手通过标准化的模型上下文协议接口执行基于YARA规则的威胁分析。该服务器集成了YARA扫描与现代AI助手,支持全面的规则管理、安全扫描以及详细的分析结果,通过模块化架构实现。
+------------------------------------------+
| AI 助手 |
+--------------------+---------------------+
|
| 模型上下文协议
|
+--------------------v---------------------+
| YaraFlux MCP Server |
| |
| +----------------+ +---------------+ |
| | MCP 服务器 | | 工具注册表 | |
| +-------+--------+ +-------+-------+ |
| | | |
| +-------v--------+ +-------v-------+ |
| | YARA 服务 | | 存储层 | |
| +----------------+ +---------------+ |
| |
+------------------------------------------+
| |
+-----------------+ +---------------+
| YARA 引擎 | | 存储 |
| - 规则编译 | | - 本地文件系统|
| - 文件扫描 | | - MinIO/S3 |
+-----------------+ +---------------+
YaraFlux 遵循模块化架构,分离了以下关注点:
对于详细的架构图,请参阅架构文档。
🔄 模块化架构
🤖 MCP 集成
🔍 YARA 扫描
📝 规则管理
📊 文件分析
🔐 安全特性
# 拉取最新Docker镜像
docker pull threatflux/yaraflux-mcp-server:latest
# 运行容器
docker run -p 8000:8000 \
-e JWT_SECRET_KEY=your-secret-key \
-e ADMIN_PASSWORD=your-admin-password \
-e DEBUG=true \
threatflux/yaraflux-mcp-server:latest
### 从源码构建Docker镜像
```bash
# 克隆仓库
git clone https://github.com/ThreatFlux/YaraFlux.git
cd YaraFlux/
# 构建Docker镜像
docker build -t yaraflux-mcp-server:latest .
# 运行容器
docker run -p 8000:8000 \
-e JWT_SECRET_KEY=your-secret-key \
-e ADMIN_PASSWORD=your-admin-password \
-e DEBUG=true \
yaraflux-mcp-server:latest
# 克隆仓库
git clone https://github.com/ThreatFlux/YaraFlux.git
cd YaraFlux/
# 安装依赖项(需要Python 3.13+)
make install
# 运行服务器
make run
YaraFlux 设计用于通过模型上下文协议与Claude Desktop无缝集成。
docker build -t yaraflux-mcp-server:latest .
~/Library/Application Support/Claude/claude_desktop_config.json):{
"mcpServers": {
"yaraflux-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--env",
"JWT_SECRET_KEY=your-secret-key",
"--env",
"ADMIN_PASSWORD=your-admin-password",
"--env",
"DEBUG=true",
"--env",
"PYTHONUNBUFFERED=1",
"threatflux/yaraflux-mcp-server:latest"
],
"disabled": false,
"autoApprove": [
"scan_url",
"scan_data",
"list_yara_rules",
"get_yara_rule"
]
}
}
}
YaraFlux 提供了19个集成的MCP工具:
完整的文档位于docs/目录下:
yaraflux_mcp_server/
├── src/
│ └── yaraflux_mcp_server/
│ ├── app.py # FastAPI 应用程序
│ ├── auth.py # JWT 认证和用户管理
│ ├── config.py # 配置设置加载器
│ ├── models.py # 请求/响应的Pydantic模型
│ ├── mcp_server.py # MCP 服务器实现
│ ├── utils/ # 工具函数包
│ │ ├── __init__.py # 包初始化
│ │ ├── error_handling.py # 标准化的错误处理
│ │ ├── param_parsing.py # 参数解析工具
│ │ └── wrapper_generator.py # 工具包装生成器
│ ├── mcp_tools/ # 模块化MCP工具包
│ │ ├── __init__.py # 包初始化
│ │ ├── base.py # 基础工具注册工具
│ │ ├── file_tools.py # 文件管理工具
│ │ ├── rule_tools.py # YARA规则管理工具
│ │ ├── scan_tools.py # 扫描工具
│ │ └── storage_tools.py # 存储管理工具
│ ├── storage/ # 存储实现包
│ │ ├── __init__.py # 包初始化
│ │ ├── base.py # 基础存储接口
│ │ ├── factory.py # 存储客户端工厂
│ │ ├── local.py # 本地文件系统存储
│ │ └── minio.py # MinIO/S3存储
│ ├── routers/ # API 路由定义
│ │ ├── __init__.py # 包初始化
│ │ ├── auth.py # 认证API路由
│ │ ├── files.py # 文件管理API路由
│ │ ├── rules.py # YARA规则管理API路由
│ │ └── scan.py # YARA扫描API路由
│ ├── yara_service.py # YARA规则管理和扫描
│ ├── __init__.py # 包初始化
│ └── __main__.py # CLI 入口点
├── docs/ # 文档
├── tests/ # 测试套件
├── Dockerfile # Docker配置
├── entrypoint.sh # 容器入口脚本
├── Makefile # 构建自动化
├── pyproject.toml # 项目元数据和依赖项
├── requirements.txt # 核心依赖项
└── requirements-dev.txt # 开发依赖项
# 设置开发环境
make dev-setup
# 运行测试
make test
# 代码质量检查
make lint
make format
make security-check
# 生成测试覆盖率报告
make coverage
# 运行开发服务器
make run
此项目使用GitHub Actions进行持续集成和部署:
CI 测试:在主分支和develop分支上的每次推送和拉取请求时运行
版本自动递增:在主分支上推送时自动递增版本
发布版本:在成功版本自动递增后触发
这些工作流确保了代码质量并自动化了发布过程。
在拉取请求上运行以下状态检查:
交互式API文档可在以下位置找到:
对于详细的API文档,请参阅API参考。
欢迎贡献!请随意提交Pull Request。
git checkout -b feature/amazing-feature)git commit -m '添加一些惊人的功能')git push origin feature/amazing-feature)本项目采用MIT许可 - 详情见LICENSE文件。