TIE MCP服务器
🎯 概述
TIE MCP服务器根据观察到的攻击行为,为网络安全专业人员和研究人员提供基于人工智能的MITRE ATT&CK技术预测。基于模型上下文协议,它与人工智能助手和安全工具无缝集成,以增强威胁分析和事件响应能力。
🔄 MCP的工作原理-架构和流程
模型上下文协议(MCP)通过标准化协议实现了人工智能助手(如克劳德)和专用工具之间的无缝通信。以下是TIE MCP服务器的操作方式:
MCP通信流程
graph TB
subgraph "Client Side"
A[AI Assistant/Claude]
B[MCP Client]
end
subgraph "MCP Server"
C[TIE MCP Server]
D[Tool Registry]
E[Resource Manager]
F[Request Handler]
end
subgraph "Core Components"
G[TIE Engine Manager]
H[ML Models
WALS/BPR/MF]
I[ATT&CK Data Store]
J[Prediction Engine]
end
A -->|User Query| B
B -->|JSON-RPC Request| C
C --> F
F -->|Route Request| D
F -->|Access Data| E
D -->|predict_techniques| G
D -->|get_attack_techniques| I
D -->|list_models| H
G --> H
G --> J
J -->|Predictions| G
G -->|Response| F
I -->|Technique Data| F
H -->|Model Info| F
F -->|JSON-RPC Response| C
C -->|Formatted Result| B
B -->|Display to User| A
style A fill:#f9f,stroke:#333,stroke-width:4px
style C fill:#bbf,stroke:#333,stroke-width:4px
style G fill:#bfb,stroke:#333,stroke-width:4px工具执行顺序
sequenceDiagram
participant User
participant Claude
participant MCP_Client
participant TIE_Server
participant TIE_Engine
participant ML_Models
User->>Claude: "Predict next techniques after T1059, T1055"
Claude->>MCP_Client: Parse request
MCP_Client->>TIE_Server: tools/predict_techniques
TIE_Server->>TIE_Server: Validate input
TIE_Server->>TIE_Engine: Load technique vectors
TIE_Engine->>ML_Models: Get model (WALS/BPR)
ML_Models->>ML_Models: Compute embeddings
ML_Models->>TIE_Engine: Return predictions
TIE_Engine->>TIE_Engine: Rank & filter
TIE_Engine->>TIE_Server: Formatted results
TIE_Server->>MCP_Client: JSON-RPC response
MCP_Client->>Claude: Structured data
Claude->>User: Natural language response
Note over User,ML_Models: Total execution time: Processing
Processing --> ResponseMCP实现的关键特征
- 无状态设计:每个请求都是独立的,确保可靠性
- 架构验证:根据定义的模式验证所有输入/输出
- 错误处理:优雅的降级,并显示详细的错误消息
- 性能监控:延迟和吞吐量的内置指标
- 安全第一:输入净化、速率限制和访问控制
主要特点
- 🔮 智能技术预测:先进的机器学习模型预测攻击链中可能的下一步技术
- 🧠 多算法支持:WALS、BPR、矩阵分解等
- 📊 实时推理:操作使用的亚秒级预测延迟
- 🔄 模型再培训:使用新的CTI数据进行动态再培训
- 🛡️ 安全第一设计:本地执行,无数据泄露
- 🔌 MCP集成:与Claude和其他AI助手无缝集成
📋 先决条件
安装前,请确保:
- Python 3.10或更高版本 (下载Python)
- Git 用于存储库管理
- 8GB+内存 建议用于模型操作
- 基本了解 MITRE ATT&CK框架
系统要求
| 组件 | 最小值 | 推荐 |
|---|---|---|
| Python | 3.10+ | 3.11+ |
| RAM | 4GB | 8GB+ |
| 存储空间 | 2GB | 5GB+ |
| 操作系统 | Windows 10+、macOS 10.15+、Ubuntu 20.04+ | 最新版本 |
🚀 安装
方法1:从GitHub直接安装
# Clone the repository
git clone https://github.com/Nidhi2302/TIE-mcp-server.git
cd TIE-mcp-server
# Create and activate virtual environment
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate
# Install the package
pip install -e .方法二:用诗(推荐发展)
# Clone the repository
git clone https://github.com/Nidhi2302/TIE-mcp-server.git
cd TIE-mcp-server
# Install Poetry if not already installed
pip install poetry
# Install dependencies
poetry install
# Activate the virtual environment
poetry shell方法三:Docker安装
# Clone the repository
git clone https://github.com/Nidhi2302/TIE-mcp-server.git
cd TIE-mcp-server
# Build and run with Docker Compose
docker-compose up -d⚙️ 配置
MCP客户端配置
通过将服务器添加到配置文件中来配置MCP客户端(例如Claude Desktop):
Claude桌面配置:
- 找到您的配置文件:
- 视窗: %APPDATA%\Claude\claude_desktop_config.json - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - Linux: ~/.config/Claude/claude_desktop_config.json
- 添加TIE MCP服务器:
{
"mcpServers": {
"tie-mcp-server": {
"command": "python",
"args": ["-m", "tie_mcp.server"],
"cwd": "/path/to/your/tie-mcp-server"
}
}
}- 复制示例配置:
# Copy and customize configuration examples
cp claude_desktop_config.example.json claude_desktop_config.json
cp mcp_config.example.json mcp_config.json环境配置
创建一个 .env 自定义配置文件:
# Basic Configuration
ENVIRONMENT=development
LOG_LEVEL=INFO
DEBUG=true
# Data Paths (optional - defaults provided)
ENTERPRISE_ATTACK_FILEPATH=data/datasets/stix/enterprise-attack.json
DEFAULT_DATASET_FILEPATH=data/datasets/combined_dataset_full_frequency.json
# Model Settings
MODEL_DEFAULT_MODEL_TYPE=wals
MODEL_DEFAULT_EMBEDDING_DIMENSION=4
MODEL_VALIDATION_RATIO=0.1
MODEL_TEST_RATIO=0.2📖 使用示例
基础技术预测
询问Claude(或您的MCP客户):
Can you predict what ATT&CK techniques might be used next if an attacker has already used:
- T1059 (Command and Scripting Interpreter)
- T1055 (Process Injection)预期响应格式:
{
"predicted_techniques": [
{
"technique_id": "T1105",
"technique_name": "Ingress Tool Transfer",
"score": 0.85,
"in_training_data": true
},
{
"technique_id": "T1053",
"technique_name": "Scheduled Task/Job",
"score": 0.72,
"in_training_data": true
}
],
"input_techniques": ["T1059", "T1055"],
"model_id": "default",
"prediction_method": "dot",
"execution_time_seconds": 0.1
}自定义参数的高级用法
Predict the top 10 techniques using cosine similarity for techniques T1566.001 and T1204.002获取ATT&CK技术信息
What techniques are related to "command execution" in the MITRE ATT&CK framework?模型管理
List all available trained models with their performance metrics🛠️ API文档
可用的MCP工具
predict_techniques
根据观察到的技术预测MITRE ATT&CK技术。
参数:
techniques(必填):技术ID数组(例如,\[“T1059”、“T1055”\])model_id(可选):用于预测的特定模型top_k(可选,默认值:20):要返回的预测数(1-100)prediction_method(可选,默认:“点”):使用方法(“点”或“余弦”)
get_attack_techniques
获取有关MITRE ATT&CK技术的信息。
参数:
technique_ids(可选):要检索的特定技术ID数组search_term(可选):搜索词过滤技术tactic(可选):按特定策略过滤
list_models
列出所有可用的训练模型。
参数:
include_metrics(可选,默认值:true):包括性能指标
MCP通信协议
TIE MCP服务器使用以下消息类型实现标准MCP协议:
请求消息结构
{
"jsonrpc": "2.0",
"method": "tools/predict_techniques",
"params": {
"techniques": ["T1059", "T1055"],
"top_k": 10,
"model_id": "default"
},
"id": "req-001"
}响应消息结构
{
"jsonrpc": "2.0",
"result": {
"predicted_techniques": [...],
"model_used": "wals_v1",
"execution_time": 0.087
},
"id": "req-001"
}错误响应结构
{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Invalid params",
"data": {
"details": "technique_id T9999 not found"
}
},
"id": "req-001"
}可用MCP资源
models://-访问经过训练的模型信息datasets://-访问可用数据集attack://techniques-MITRE ATT&CK技术数据metrics://system-系统性能指标
🔧 开发设置
当地发展环境
# Clone and setup
git clone https://github.com/your-username/tie-mcp-server.git
cd TIE-mcp-server
# Install in development mode
pip install -e ".[dev]"
# Setup pre-commit hooks
pre-commit install
# Run tests
pytest
# Run with coverage
pytest --cov=tie_mcp --cov-report=html
# Format code
black src/ tests/
ruff check src/ tests/ --fix
# Type checking
mypy src/项目结构
tie-mcp-server/
├── src/tie_mcp/ # Main application code
│ ├── server.py # MCP server implementation
│ ├── core/ # Core TIE functionality
│ │ ├── engine_manager.py # High-level engine interface
│ │ └── tie/ # TIE algorithm implementations
│ ├── config/ # Configuration management
│ ├── models/ # Model management
│ ├── storage/ # Data storage interfaces
│ └── utils/ # Utility functions
├── tests/ # Test suite
│ ├── unit/ # Unit tests
│ └── performance/ # Performance tests
├── data/ # Data files (gitignored)
├── docker/ # Docker configuration
├── examples/ # Example notebooks
└── .github/ # GitHub workflows🔍 故障排除
常见问题
1.导入错误
# Error: ModuleNotFoundError: No module named 'tie_mcp'
# Solution: Install in editable mode
pip install -e .2.权限错误
# Error: PermissionError when starting server
# Solution: Check file permissions and virtual environment
chmod +x venv/bin/python # On Unix systems3.内存问题
# Error: Out of memory during model operations
# Solution: Increase system RAM or reduce model parameters
export OMP_NUM_THREADS=1 # Limit OpenMP threads4.MCP连接问题
# Error: Server not responding
# Solutions:
# 1. Check server logs
python -m tie_mcp.server --debug
# 2. Verify configuration paths
# 3. Test server standalone
python -c "from tie_mcp.server import TIEServer; print('OK')"5.模型加载错误
# Error: Model files not found
# Solution: Check data paths in configuration
ls -la data/datasets/调试模式
启用详细日志记录:
# Set environment variable
export LOG_LEVEL=DEBUG
# Or run with debug flag
python -m tie_mcp.server --debug性能优化
为了获得更好的性能:
# Set thread limits
export OMP_NUM_THREADS=4
export MKL_NUM_THREADS=4
# Use system BLAS
pip install numpy[blas]获取帮助
- GitHub问题: 报告错误或请求功能
- 文档:检查内联代码文档
- 日志:查看服务器日志以获取详细的错误信息
🤝 贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详情。
贡献者快速入门
- 分叉存储库
- 创建要素分支:
git checkout -b feature/amazing-feature - 进行更改并添加测试
- 运行测试套件:
pytest - 提交您的更改:
git commit -m 'Add amazing feature' - 推你的叉子:
git push origin feature/amazing-feature - 提交拉取请求
代码质量标准
- 测试:保持>80%的测试覆盖率
- 类型提示:所有函数都必须有类型注释
- 文档:为公共函数添加文档字符串
- 格式化:使用黑色和Ruff进行代码格式化
- 承诺:关注 常规承诺
🔒 安全
安全最佳实践
- 仅限本地执行:默认情况下没有网络暴露
- STDIO通信:安全的进程间通信
- 无数据持久性:无状态运营模式
- 输入验证:所有输入都经过验证和消毒
报告安全问题
请通过电子邮件私下报告安全漏洞 security@example.com.
📊 演出
基准结果
| 操作 | 延迟(P95) | 吞吐量 |
|---|---|---|
| 第一次预测 | \<5秒 | N/A |
| 后续预测 | \<100ms | 100+需求/秒 |
| 模型加载 | \<10秒 | N/A |
| 内存使用量 | ~500MB | 典型 |
优化提示
- 首次运行:初始模型加载可能需要更长的时间
- 记忆:将模型保存在内存中以获得最佳性能
- 并发:服务器处理多个并发请求
- 缓存:ATT&CK技术信息已缓存
📜 许可证
此项目根据Apache许可证2.0获得许可-请参阅 许可证 文件以获取详细信息。
第三方许可证
- MITRE ATT&CK:用于 MITRE许可证
- 模型上下文协议:MIT许可证
- Python依赖关系:各种开源许可证(见要求)
🙏 致谢
- MITRE公司 用于原始TIE项目和ATT&CK框架
- 威胁知情防御中心 用于威胁情报研究
- 模型上下文协议团队 对于MCP规范
- 开源社区 对于令人惊叹的Python ML生态系统
📈 更新日志
看 更改日志.md 查看更改和发布的详细历史记录。
🔗 相关项目
- 人字结:原始技术推理引擎
- MCP规范:模型上下文协议文档
- MITRE ATT&CK:MITRE ATT&CK框架
______________________________________________________________________
由以下材料制成❤️ 网络安全社区
如有疑问、问题或意见,请访问我们的 .
