终端指挥安全分析仪
使用AI驱动的工具分析终端命令以解决安全问题 mcp使用 和 克劳德·十四行诗4.5.
🎯 目的
旨在展示对mcp使用库的熟练程度 MCP使用软件工程师 角色。该项目展示了:
- mcp使用的MCPAgent和MCPClient的集成
- MCP在开发工具中的实际应用
- 生产就绪的Python代码
- 通过LangChain实现Claude API集成
✨ 特性
- 模式匹配:检测30多种危险命令模式
- AI分析:Claude提供情境感知安全评估
- 严重级别:临界、高、中、低分类
- 安全替代方案:建议更安全的方法来完成任务
- MCP集成:使用文件系统MCP服务器获取上下文
🚀 安装
# Install dependencies
pip install -r requirements.txt
# Set up API key
echo "ANTHROPIC_API_KEY=your_key_here" > .env💻 用法
交互模式
python safety_analyzer.py演示模式(用于演示)
python demo.py🏗️ 建筑
User Command → Safety Analyzer → Pattern Check → Claude Analysis → Result
↓
MCP Client → Filesystem MCP Server🔧 技术栈
- mcp使用:代理和客户端的MCP框架
- 克劳德·十四行诗4.5:通过Anthropic API进行人工智能分析
- LangChain:LLM集成层
- Python 3.10+:核心语言
📊 输出示例
==================================================================
COMMAND: rm -rf /
==================================================================
⚠️ SAFETY WARNING: This command is potentially DANGEROUS
[CRITICAL] file_system_destruction
Pattern: rm -rf /
✓ Safe alternative: Specify exact directory to remove
Claude's Analysis:
------------------------------------------------------------------
This command is EXTREMELY DANGEROUS and should NEVER be run.
What it does: Attempts to recursively delete all files starting
from the root filesystem.
Risks: Complete system destruction, data loss, unrecoverable system
Safer alternative: Always specify the exact directory path and
verify before deletion: rm -rf /path/to/specific/directory
==================================================================🎓 我学到了什么
构建这个项目教会了我:
- mcp的使用如何简化mcp集成
- 模式匹配+AI分析相结合的力量
- 用户友好错误消息的重要性
- 生产就绪的Python项目结构
🔗 链接
📝 许可证
麻省理工学院
📚 引用
@软件{mcp_use2025, 作者={祖洛、彼得罗和贡献者}, title={MCP使用:Python和TypeScript的完整MCP生态系统}, 年份={2025}, 发布者={GitHub}, url={https://github.com/mcp-use/mcp-use}
}
