har-mcp
v0.1.1
Published
MCP server for analyzing HAR (HTTP Archive) files with LLM-friendly output
Downloads
216
Maintainers
Readme
HAR MCP Server
An MCP (Model Context Protocol) server for analyzing HAR (HTTP Archive) files with LLM-friendly output.
Runtime Requirement: This server requires Bun >= 1.0.0.
Features
- Multiple analysis modes: summary, list, detail, content, stats, timeline, size, cookies
- Powerful filtering: URL patterns, HTTP methods, status codes, content types, duration, body content
- Sorting & pagination: Sort by various fields, paginate large result sets
- Export capabilities: Export entries as cURL commands
- JSON output: Programmatic JSON output for integration
- Chrome DevTools support: Full support for Chrome-exported HAR files with extension fields
- Truncated HAR repair: Automatic recovery of truncated HAR files (common with large exports)
Installation
bun installThis server only supports Bun runtime.
Usage
With Claude Desktop
After installing from npm, use bunx:
{
"mcpServers": {
"har": {
"command": "bunx",
"args": ["har-mcp"]
}
}
}For local development:
{
"mcpServers": {
"har": {
"command": "bun",
"args": ["run", "/path/to/har-mcp/src/index.ts"]
}
}
}With OpenCode
After installing from npm, use bunx:
{
"mcp": {
"servers": {
"har": {
"type": "local",
"command": ["bunx", "har-mcp"]
}
}
}
}For local development:
{
"mcp": {
"servers": {
"har": {
"type": "local",
"command": ["bun", "run", "/path/to/har-mcp/src/index.ts"]
}
}
}
}With MCP Inspector
npx @modelcontextprotocol/inspector bun run src/index.tsTools
read_har
Reads and analyzes HAR files with multiple output modes.
Parameters:
| Parameter | Type | Description |
| ---------- | -------- | ---------------------------------------------------------- |
| path | string | Required. Path to the HAR file |
| mode | string | Output mode (default: "summary") |
| filter | object | Filter criteria |
| sort | object | Sorting options |
| page | number | Page number for pagination (default: 1) |
| pageSize | number | Entries per page (default: 20, max: 100) |
| entries | number[] | Specific entry indexes (required for content/detail modes) |
| format | string | Output format: "markdown" or "json" |
Output Modes:
| Mode | Description |
| ---------- | ------------------------------------------------------------------ |
| summary | Overview statistics (total entries, methods, status codes, timing) |
| list | Paginated entry list with basic info |
| detail | Full metadata for specific entries (headers, timing, query params) |
| content | Response/request bodies for specific entries |
| stats | Aggregate statistics grouped by endpoint |
| timeline | Text-based waterfall visualization |
| size | Payload size analysis |
| cookies | Cookie propagation tracking |
Filter Options:
| Filter | Type | Description |
| -------------- | -------------------------- | --------------------------------------------------------- |
| url | string | URL pattern (substring, glob with *, or ~regex) |
| method | string | string[] | HTTP method(s) to filter |
| status | number | string | object | Status code, pattern (e.g., "4xx"), or range {min, max} |
| contentType | string | Response content type filter |
| minDuration | number | Minimum request duration in ms |
| hasError | boolean | Filter to errors only (4xx/5xx) |
| bodyContains | string | Filter by response body content |
Sort Options:
| Field | Description |
| ---------- | -------------------------- |
| index | Original order in HAR file |
| time | Request start time |
| duration | Request duration |
| size | Response size |
| status | HTTP status code |
Examples:
// Get summary of a HAR file
read_har(path: "/path/to/file.har")
// List all POST requests
read_har(path: "...", mode: "list", filter: { method: "POST" })
// Find slow requests (over 1 second)
read_har(path: "...", mode: "list", filter: { minDuration: 1000 }, sort: { by: "duration", order: "desc" })
// Get response body for first two entries
read_har(path: "...", mode: "content", entries: [0, 1])
// Find requests matching URL pattern
read_har(path: "...", mode: "list", filter: { url: "*/api/*" })
// Filter by regex
read_har(path: "...", mode: "list", filter: { url: "~\\.json$" })
// Find errors
read_har(path: "...", mode: "list", filter: { hasError: true })
// Filter by status range
read_har(path: "...", mode: "list", filter: { status: { min: 400, max: 499 } })
// Analyze request sizes
read_har(path: "...", mode: "size")
// View timeline waterfall
read_har(path: "...", mode: "timeline")
// Track cookies
read_har(path: "...", mode: "cookies")
// Get JSON output
read_har(path: "...", mode: "summary", format: "json")export_har_curl
Export HAR entries as cURL commands for replay or debugging.
Parameters:
| Parameter | Type | Description |
| ---------------- | -------- | --------------------------------------- |
| path | string | Required. Path to the HAR file |
| entries | number[] | Required. Entry indexes to export |
| includeHeaders | boolean | Include request headers (default: true) |
| includeCookies | boolean | Include cookies (default: false) |
| compressed | boolean | Add --compressed flag |
| verbose | boolean | Add -v flag |
Example:
// Export first request as cURL
export_har_curl(path: "/path/to/file.har", entries: [0])
// Export with cookies and verbose output
export_har_curl(path: "...", entries: [0, 1], includeCookies: true, verbose: true)Browser Compatibility
This MCP server fully supports HAR files exported from:
- Chrome DevTools - Including all Chrome-specific extension fields (
_initiator,_priority,_resourceType,_transferSize,_workerRespondWithSettled, etc.) - Firefox DevTools - Standard HAR 1.2 format
- Safari Web Inspector - Standard HAR format
- Other tools - Any HAR 1.2 compliant export
Truncated HAR Repair
Large HAR files exported from browsers can sometimes be truncated (incomplete JSON). This server automatically detects and repairs truncated HAR files by:
- Finding the last complete HTTP entry
- Reconstructing valid JSON structure
- Displaying a warning with the number of recovered entries
When a truncated file is repaired, you'll see a warning like:
⚠️ **Warning**: HAR file was truncated and has been repaired.
Recovered 182 entries using chrome-timings repair method.
Some entries at the end of the file may be missing.Development
bun start # Run the server
bun test # Run tests
bun lint # Check code style
bun format # Format codeProject Structure
src/
├── index.ts # Entry point - stdio transport setup
├── server.ts # MCP server configuration and tool registration
└── tools/
└── har/
├── index.ts # Tool exports and registration
├── schema.ts # Zod schemas for input validation
└── modes/ # Output mode implementationsLicense
MIT
