MAD-MCP文物挖掘器
 
AI辅助IDE环境中模型上下文协议(MCP)工件的取证分析框架。
概述
MAD(MCP Artifact Digger)从Cursor IDE环境中的各种工件源中提取并分析MCP服务器活动。它支持多种工件格式、自动服务器推理、事件关联,并提供基于web的可视化仪表板。
主要特点
- 多源伪影分析:支持mcp.json、游标日志、state.vscdb、代理转录、服务器JSONL日志和HAR网络捕获
- 通用MCP服务器支持:适用于任何MCP服务器(文件系统、github、概念、浏览器、数据库等)
- 服务器名称推断:当显式服务器信息不可用时(例如“文件系统MCP”),自动检测用户查询中提到的MCP服务器→
filesystem (estimated)) - 事件重复数据删除:根据时间戳+内容匹配删除重复事件,以提高可读性
- 事件关联:使用请求ID、会话ID和时间接近度跨源匹配事件
- 比较分析:比较本地STDIO、自定义远程和官方远程服务器取证功能
- 网络仪表盘:具有轻主题、可扩展事件和服务器过滤的响应式UI
项目结构
MCP_Artifact_Digger/
├── mad/ # Core Python package
│ ├── __init__.py
│ ├── api.py # FastAPI server & endpoints
│ ├── models/
│ │ ├── __init__.py
│ │ ├── entities.py # MCP Server, Tool, Resource models
│ │ ├── events.py # Timeline events (with deduplication)
│ │ └── comparison.py # Comparison matrix
│ ├── transformers/
│ │ ├── __init__.py
│ │ ├── base.py # Base transformer class
│ │ ├── config.py # mcp.json parser
│ │ ├── cursor_log.py # Cursor MCP log parser
│ │ ├── vscdb.py # state.vscdb SQLite parser
│ │ ├── agent_transcript.py # agent-transcripts JSON parser
│ │ ├── network.py # HAR network capture parser
│ │ ├── server_log.py # MCP server JSONL log parser
│ │ ├── mcps_folder.py # MCPS folder artifact parser
│ │ └── server_inference.py # MCP server inference utility
│ ├── correlation/
│ │ ├── __init__.py
│ │ └── engine.py # Event correlation engine
│ └── analysis/
│ ├── __init__.py
│ └── comparative.py # Local vs Remote analysis
├── web/ # Web dashboard
│ ├── index.html
│ ├── css/style.css
│ └── js/
│ ├── app.js
│ ├── timeline.js
│ └── comparison.js
├── samples/ # Sample artifacts for testing
│ ├── agent-transcript-sample.json
│ ├── MCP user-filesystem.log
│ ├── MCP user-Notion.log
│ ├── notion-mcp.har
│ └── state.vscdb
├── tests/ # Test suite
│ └── __init__.py
├── .gitignore
├── LICENSE # MIT License
├── pyproject.toml # Project configuration
├── requirements.txt
├── run_server.py # Development server runner
└── README.md安装
需求
- Python 3.11+
快速开始
# Clone repository
git clone https://github.com/your-username/mad.git
cd mad
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# or
.\venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Run server
python run_server.py作为软件包安装
pip install -e .访问
- 网络仪表盘: http://localhost:8000/app
- API文件: http://localhost:8000/api/docs
- 健康检查: http://localhost:8000/health
支持的工件
1.state.vscdb(游标状态数据库)
- 位置:
%APPDATA%\Cursor\User\workspaceStorage\\state.vscdb - 内容:对话历史、MCP服务器设置、工具调用记录
- 提取信息:用户查询、人工智能响应、MCP工具调用、服务器映射
2.MCP服务器日志
- 位置:
%APPDATA%\Cursor\logs\\window1\exthost\anysphere.cursor-mcp\MCP *.log - 内容:MCP服务器连接、工具列表、通话记录
- 提取信息:服务器名称、命令、工具计数、连接事件
3.代理记录(代理对话JSON)
- 位置: `%USERPROFILE%\.cursor\projects\
\agent-transcripts\*.json`
- 内容:完整的AI代理对话记录
- 提取信息:服务器MCP工具调用(已确认)、用户查询、人工智能响应、思维过程
- 支持的格式:
- CallMcpTool 格式: {"toolName": "CallMcpTool", "args": {"server": "...", "toolName": "..."}} - mcp_ 前缀格式: {"toolName": "mcp_ServerName_tool-name", "args": {...}}
4.mcp.json(配置)
- 位置:
%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\mcp.json - 内容:MCP服务器配置
- 提取信息:服务器设置、命令、环境变量
5.HAR网络捕获
- 位置:通过浏览器开发工具或Fiddler捕获
- 内容:对远程MCP服务器的HTTP/SSE请求
- 提取信息:请求/响应对、JSON-RPC消息、带参数和结果的工具调用
用法
网络仪表盘
- 导航到http://localhost:8000/app
- 上传工件文件(state.vscdb、\*.log、\*.json、\*.har等)
- 点击“分析工件”
- 按选项卡查看结果:
- 仪表盘:服务器、工具和事件摘要 - 分析:详细的服务器信息 - 时间线:事件时间线(服务器筛选器,展开/折叠)
时间线功能
- 服务器筛选器:通过从下拉列表中选择服务器来筛选事件
- 活动扩展:单击“显示更多”以显示完整内容
- 服务器标签:
- 已确认: [user-filesystem] (由CallMcpTool明确确认) - 预计: [filesystem (estimated)] (根据用户查询推断)
服务器推断
自动检测用户查询中提到的MCP服务器:
| 模式 | 推理结果 |
|---|---|
| “用户文件系统MCP list_allowed_directories” | filesystem (estimated) |
| “github mcp检查问题” | github (estimated) |
| “文件系统服务器读取文件” | filesystem (estimated) |
| “MCP浏览器打开页面” | browser (estimated) |
支持的服务器模式:文件系统、github、git、concept、浏览器、slack、数据库、搜索、内存、fetch、docker、kubernetes、aws、谷歌驱动器、黑曜石等等。
API使用
# Upload and analyze files
curl -X POST http://localhost:8000/api/analyze \
-F "files=@state.vscdb" \
-F "files=@MCP user-filesystem.log"
# Get entities
curl http://localhost:8000/api/entities
# Get timeline
curl http://localhost:8000/api/timeline
# Get comparison matrix
curl http://localhost:8000/api/comparison/matrix比较矩阵
工件可用性
| 工件 | 本地STDIO | 自定义远程 | 官方远程 |
|---|---|---|---|
| mcp.json配置 | 完整 | 完整 | 完全 |
| 光标日志 | 已满 | 已满 | |
| state.vscdb | 已满 | 已满 | |
| 代理人成绩单 | 完整 | 完整 | 完全 |
| 服务器请求日志 | 无 | 满的 | 没有 |
| 服务器响应日志 | 无 | 满的 | 没有 |
| 文件访问日志 | 无 | 满的 | 没有 |
| 网络捕获 | 无 | 完全 | 部分(加密) |
法医能力
| 功能 | 本地STDIO | 自定义远程 | 官方远程 |
|---|---|---|---|
| 时间线重建 | 中等 | 高 | 中等 |
| 行动归因 | 低 | 高 | 中等 |
| 数据泄露跟踪 | 低 | 高 | 低 |
| 安全事件检测 | 低 | 高 | 低 |
建筑
┌─────────────────────────────────────────────────────────────┐
│ Web Dashboard │
│ Upload → Analysis → Entities → Timeline (Filter/Expand) │
└────────────────────────┬────────────────────────────────────┘
│ REST API
▼
┌─────────────────────────────────────────────────────────────┐
│ FastAPI Backend │
├─────────────────────────────────────────────────────────────┤
│ Transformers: │
│ ├── VSCDBTransformer (state.vscdb → conversations) │
│ ├── AgentTranscriptTransformer (*.json → MCP calls) │
│ ├── CursorLogTransformer (MCP *.log → server info) │
│ ├── ConfigTransformer (mcp.json → entities) │
│ ├── NetworkTransformer (*.har → JSON-RPC events) │
│ └── ServerLogTransformer (*.jsonl → events) │
│ ↓ │
│ Server Inference: │
│ └── infer_server_from_text() → "filesystem (estimated)" │
│ ↓ │
│ CorrelationEngine: │
│ ├── Request ID matching │
│ ├── Session ID matching │
│ ├── Time proximity matching │
│ └── Event deduplication (timestamp + content hash) │
└─────────────────────────────────────────────────────────────┘工件位置(Windows)
# state.vscdb (conversation history)
%APPDATA%\Cursor\User\globalStorage\state.vscdb
# MCP server logs
%APPDATA%\Cursor\logs\\window1\exthost\anysphere.cursor-mcp\MCP *.log
# Agent Transcripts
%USERPROFILE%\.cursor\projects\
\agent-transcripts\*.json
# MCP configuration
%USERPROFILE%\.cursor\mcp.json参考文献
- MCP规范: https://modelcontextprotocol.io/specification/
- 光标IDE: https://cursor.sh/
许可证
MIT许可证
