一个提供AI模型和自动化工具访问TheHive事件响应平台的MCP(模型上下文协议)服务器。
此服务器作为MCP客户端(如AI助手)与TheHive之间的桥梁,允许它们进行以下操作:
get_thehive_alerts - 从TheHive获取警报列表
limit(默认值:100)get_thehive_alert_by_id - 获取特定警报的详细信息
alert_idget_thehive_cases - 从TheHive获取案件列表
limit(默认值:100)get_thehive_case_by_id - 获取特定案件的详细信息
case_idpromote_alert_to_case - 将警报提升为案件
alert_idcreate_thehive_case - 在TheHive中创建新的案件
title 和 descriptionseverity、tags、tlp、pap、status、assignee、case_template、start_date你可以从GitHub Releases页面下载适用于各种操作系统的预编译二进制文件。下载适合你系统的二进制文件,使其可执行,并放置在你希望的位置。
git clone <repository-url>
cd mcp-server-thehive
cargo build --release
服务器需要以下环境变量:
THEHIVE_URL - TheHive API基础URL(默认值:http://localhost:9000/api)THEHIVE_API_TOKEN - TheHive 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_TOKEN# 使用cargo
cargo run
# 使用已构建的二进制文件
./target/release/mcp-server-thehive
服务器通过标准输入输出使用MCP协议进行通信。配置你的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": "潜在恶意软件爆发",
"description": "多个终端报告可疑进程活动。",
"severity": 3,
"tags": ["恶意软件", "终端", "EPP"],
"tlp": 2,
"assignee": "soc_level2"
}
}
}
mcp-server-thehive/
├── src/
│ ├── main.rs # 主服务器实现
│ ├── lib.rs # 库导出
│ └── thehive/
│ ├── mod.rs # 模块声明
│ ├── client.rs # TheHive API客户端
│ └── error.rs # 错误类型
├── tests/
│ ├── bin/
│ │ └── mock_thehive_server.rs # 测试使用的模拟TheHive API服务器
│ ├── integration_test.rs # 集成测试
│ └── mcp_stdio_test.rs # 标准输入输出接口测试
├── Cargo.toml # 依赖项和元数据
└── README.md # 此文件
该项目包含一套全面的集成测试,利用模拟的TheHive服务器。这个模拟服务器模拟TheHive API,使得可以在没有实际TheHive实例的情况下进行隔离和重复的测试。
运行测试:
# 运行所有测试(包括使用模拟服务器的集成测试)
cargo test
# 运行带有详细日志的测试(包括MCP服务器和模拟服务器的日志)
RUST_LOG=debug MCP_SERVER_THEHIVE_VERBOSE_TEST_LOGS=true cargo test
连接被拒绝
THEHIVE_URL是否正确身份验证失败
THEHIVE_API_TOKEN是否正确且未过期SSL证书错误
VERIFY_SSL=false用于测试(不推荐用于生产环境)启用调试日志以进行故障排除:
RUST_LOG=debug cargo run
本项目根据MIT许可发布 - 查看LICENSE文件了解详情。