HAR解析器MCP服务器
用于解析和分析HTTP存档(HAR)文件的模型上下文协议(MCP)服务器。从网络流量捕获中提取见解,调试API问题,并轻松再现请求。
特性
- 元数据分析 -获取一个包含请求计数、状态分布和错误检测的健康仪表板
- 智能搜索 -按URL模式、资源类型、状态代码或错误条件筛选条目
- 请求详情 -深入了解具有格式化正文和时间细分的单个请求
- cURL生成 -将任何捕获的请求转换为cURL命令以进行再现
- 二元萃取 -解码并保存base64编码的二进制响应(图像、PDF等)
- 智能高速缓存 -解析后的HAR文件会被缓存,并在文件更改时自动失效
安装
使用uvx(推荐)
uvx --from git+https://github.com/c0dn/har-parser-mcp.git har-parser-mcp使用pip
pip install git+https://github.com/c0dn/har-parser-mcp.git
har-parser-mcp来源
git clone https://github.com/c0dn/har-parser-mcp.git
cd har-parser-mcp
uv sync
uv run har-parser-mcp配置
克劳德桌面
添加到您的Claude Desktop配置(~/.config/claude/claude_desktop_config.json 在Linux上, ~/Library/Application Support/Claude/claude_desktop_config.json 在macOS上):
{
"mcpServers": {
"har-parser": {
"command": "uvx",
"args": ["--from", "git+https://github.com/c0dn/har-parser-mcp.git", "har-parser-mcp"]
}
}
}克劳德代码
添加到您的Claude Code MCP设置中:
{
"mcpServers": {
"har-parser": {
"command": "uvx",
"args": ["--from", "git+https://github.com/c0dn/har-parser-mcp.git", "har-parser-mcp"]
}
}
}工具
read_har_metadata
解析HAR文件并返回摘要仪表板。
Parameters:
file_path: string - Path to the .har file
Returns:
- Total entries, pages, and duration
- Response size statistics
- Status code distribution (2xx, 3xx, 4xx, 5xx)
- Network error and incomplete request countssearch_har_entries
使用灵活的条件搜索和过滤HAR条目。
Parameters:
file_path: string - Path to the .har file
query: string (optional) - Regex pattern to match URLs or response bodies
resource_type: string (optional) - Filter by type: xhr, document, stylesheet, image, font, script, media, websocket
has_error: boolean (optional) - Filter to only 4xx/5xx/network errors
status_code: integer (optional) - Filter by exact status code
Returns:
- List of matching entries with index, method, URL, status, and timingget_entry_details
按索引获取特定请求的完整详细信息。
Parameters:
file_path: string - Path to the .har file
entry_index: integer - Zero-based index of the entry
Returns:
- Full request/response headers
- Request/response bodies (auto-formatted for JSON)
- Cookies sent and received
- Detailed timing breakdown (DNS, connect, SSL, TTFB, download)
- Server IP addressgenerate_curl_command
将HAR条目转换为可复制的cURL命令。
Parameters:
file_path: string - Path to the .har file
entry_index: integer - Zero-based index of the entry
unsafe: boolean (optional) - Include sensitive headers (Authorization, Cookie, etc.)
Returns:
- Ready-to-use cURL command
- Warning if sensitive headers are exposedextract_binary_content
解码base64编码的二进制响应并保存到临时文件。
Parameters:
file_path: string - Path to the .har file
entry_index: integer - Zero-based index of the entry
Returns:
- Path to extracted file
- MIME type and file size
- Original URL用例
- API调试 -分析失败的请求、检查标头并重现问题
- 性能分析 -识别缓慢的请求并分析时间故障
- 安全性审计 -审查请求/响应中的敏感数据
- 文档 -从记录的流量中提取API模式
- 测试 -生成cURL命令以再现特定场景
如何捕获HAR文件
Chrome/Edge
- 打开DevTools(F12)
- 转到“网络”选项卡
- 执行要捕获的操作
- 在网络列表中右键单击→ “将所有内容另存为HAR”
火狐
- 打开DevTools(F12)
- 转到“网络”选项卡
- 执行要捕获的操作
- 点击齿轮图标→ “全部另存为HAR”
游猎
- 启用“开发人员”菜单(首选项→ 高级)
- 开放式Web检查器(开发→ 显示Web检查器)
- 转到“网络”选项卡
- 执行要捕获的操作
- 导出(文件→ 出口HAR)
发展
# Install dependencies
uv sync
# Run tests
uv run pytest
# Type checking
uv run mypy src
# Linting
uv run ruff check src tests许可证
麻省理工学院
