TheCive的MCP服务器
MCP(模型上下文协议)服务器,为AI模型和自动化工具提供对TheSive事件响应平台的访问。
概述
此服务器充当MCP客户端(如AI助手)和TheWive之间的桥梁,允许它们:
- 检索和分析安全警报
- 访问案例信息
- 促进案件警报
- 执行事故响应操作
特性
可用工具
- get_thehive_alerts -从TheSive检索警报列表
- 可选的 limit 参数(默认值:100) - 返回格式化的警报信息,包括ID、标题、严重性和状态
- get_thehive_alert_by_id -获取特定警报的详细信息
- 必需 alert_id 参数 - 返回全面的警报详细信息
- getthehive_cases -从TheSive检索案例列表
- 可选的 limit 参数(默认值:100) - 返回格式化的案例信息
- get_thehive_case_by_id -获取特定案例的详细信息
- 必需 case_id 参数 - 返回全面的案例详细信息
- promote_alert_to-case -发布案件警报
- 必需 alert_id 参数 - 返回有关新创建案例的信息
- create_thehive_case -在TheSive中创建新案例
- 必需 title 和 description 参数 - 可选参数: severity, tags, tlp, pap, status, assignee, case_template, start_date - 返回有关新创建案例的信息
安装
先决条件
- 访问TheSive 5实例
- 有效的TheHive API令牌
下载预编译的二进制文件
您可以从以下网址下载各种操作系统的预编译二进制文件 。下载适合您系统的二进制文件,使其可执行,并将其放置在所需的位置。
从源头构建
git clone
cd mcp-server-thehive
cargo build --release配置
服务器需要以下环境变量:
THEHIVE_URL-配置单元API基本URL(默认值:http://localhost:9000/api)THEHIVE_API_TOKEN-Hive API令牌(必需)VERIFY_SSL-是否验证SSL证书(默认值:false)RUST_LOG-日志记录级别(可选。,debug,info)
环境文件
创建一个 .env 项目根目录中的文件:
THEHIVE_URL=https://your-thehive-instance.com/api
THEHIVE_API_TOKEN=your-api-token-here
VERIFY_SSL=true
RUST_LOG=info获取TheHive API令牌
- 登录到您的TheSive实例
- 首选 用户设置 → API密钥
- 点击 创建API密钥
- 复制生成的令牌并将其用作
THEHIVE_API_TOKEN
用法
运行服务器
# Using cargo
cargo run
# Using the built binary
./target/release/mcp-server-thehive与MCP客户端集成
服务器使用MCP协议通过stdio进行通信。配置您的MCP客户端以使用此服务器:
{
"mcpServers": {
"thehive": {
"command": "/path/to/mcp-server-thehive",
"env": {
"THEHIVE_URL": "https://your-thehive-instance.com:9000/api",
"THEHIVE_API_TOKEN": "your-api-token-here"
}
}
}
}例子
检索最近的警报
{
"method": "tools/call",
"params": {
"name": "get_thehive_alerts",
"arguments": {
"limit": 10
}
}
}获取警报详细信息
{
"method": "tools/call",
"params": {
"name": "get_thehive_alert_by_id",
"arguments": {
"alert_id": "~123456"
}
}
}提高对案件的警惕
{
"method": "tools/call",
"params": {
"name": "promote_alert_to_case",
"arguments": {
"alert_id": "~123456"
}
}
}创建新案例
{
"method": "tools/call",
"params": {
"name": "create_thehive_case",
"arguments": {
"title": "Potential Malware Outbreak",
"description": "Multiple endpoints reporting suspicious process activity.",
"severity": 3,
"tags": ["malware", "endpoint", "epp"],
"tlp": 2,
"assignee": "soc_level2"
}
}
}发展
项目结构
mcp-server-thehive/
├── src/
│ ├── main.rs # Main server implementation
│ ├── lib.rs # Library exports
│ └── thehive/
│ ├── mod.rs # Module declarations
│ ├── client.rs # TheHive API client
│ └── error.rs # Error types
├── tests/
│ ├── bin/
│ │ └── mock_thehive_server.rs # Mock TheHive API server for testing
│ ├── integration_test.rs # Integration tests
│ └── mcp_stdio_test.rs # Stdio interface tests
├── Cargo.toml # Dependencies and metadata
└── README.md # This file依赖项
- rmcp -MCP协议实现
- 他的客户 -Hive API客户端库
- 东京 -异步运行时
- reqwest -HTTP客户端
- 塞尔德 -序列化框架
- 追踪 -测井和仪器
测试
该项目包括一套全面的集成测试,利用模拟的TheHive服务器。该模拟服务器模拟TheHive API,允许对MCP服务器的功能进行隔离和可重复的测试,而不需要实时的TheHive实例。
运行测试:
# Run all tests (including integration tests that use the mock server)
cargo test
# Run tests with verbose logging (includes MCP server and mock server logs)
RUST_LOG=debug MCP_SERVER_THEHIVE_VERBOSE_TEST_LOGS=true cargo test安全考虑
- 安全存储API令牌(使用环境变量或安全凭据存储)
- 永远不要将API令牌提交到版本控制
- 在生产环境中启用SSL验证
- 限制对TheWive实例的网络访问
- 使用最少特权API令牌访问TheHive
- 监控并记录所有API交互
- 定期轮换API令牌
故障排除
常见问题
- 连接被拒绝
- 验证 THEHIVE_URL 是正确的 - 检查与TheWive实例的网络连接 - 确保TheChive正在运行且可访问
- 认证失败
- 验证 THEHIVE_API_TOKEN 正确且未过期 - 检查API令牌是否具有必要的权限 - 确保令牌格式正确
- SSL证书错误
- 集 VERIFY_SSL=false 用于测试(不建议用于生产) - 安装正确的SSL证书 - 使用有效的证书颁发机构
日志记录
启用调试日志以进行故障排除:
RUST_LOG=debug cargo run贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 如果适用,添加测试
- 提交拉取请求
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
相关项目
- 这位客户 -TheHive API的Rust客户端库
- mcp服务器皮层 -Cortex的MCP服务器
- mcp服务器wazuh -Wazuh SIEM的MCP服务器
