Turn HAR traffic files into working mock API servers. No manual configuration needed.
- Capture HTTP traffic (browser DevTools, proxy, or built-in recorder)
- Feed the HAR file to MockClaw
- Get a running FastAPI mock server with realistic responses
# Install
pip install -r src/requirements.txt
pip install -e .
# Try the built-in example
mockclaw example
# Or generate from your own HAR file
mockclaw generate your_traffic.har ./mocks --smart-fallback
# Start the mock server
mockclaw serve ./mocks --port 8000
# Test it
curl http://localhost:8000/healthWhen --smart-fallback is enabled, MockClaw automatically analyzes request bodies to generate conditional routing:
# If your HAR has these requests to the same endpoint:
# POST /checkout {"role": "admin", "data": "..."} -> 200
# POST /checkout {"role": "user", "data": "..."} -> 200
# POST /checkout {"role": "guest", "data": "..."} -> 403
# MockClaw auto-detects "role" as the differing field and generates:
@app.post("/checkout")
async def post__checkout(request: Request):
body = await request.json()
if body.get("role") == "admin":
return {"status": "ok", "data": {...}}
elif body.get("role") == "user":
return {"status": "ok", "data": {...}}
elif body.get("role") == "guest":
raise HTTPException(status_code=403, detail=...)
else:
return {"status": "ok", "data": {...}}No hardcoded field names. Works with any JSON request body -- coupon codes, user roles, action types, or anything else.
- Auto conditional routing -- analyzes request bodies to generate if/elif/else logic
- No LLM required -- works offline with zero API keys
- Auto-injected security -- rate limiting, path traversal protection, error handling
- Swagger UI -- interactive API docs at /docs
- LLM-assisted mode -- optional OpenAI integration for richer mocks
# Quick start with sample data
mockclaw example
# Generate from HAR file
mockclaw generate traffic.har ./mocks --smart-fallback
# Start mock server
mockclaw serve ./mocks --port 8000
# Record traffic from running API
mockclaw record --url http://localhost:9000 --output traffic.har
# Run chaos tests
mockclaw test ./mocks# Windows PowerShell
Invoke-RestMethod -Uri http://localhost:8000/health
# Python
import requests
requests.get('http://localhost:8000/health').json()
# cURL
curl http://localhost:8000/healthSee docs/architecture.md for technical details.
Frontend development -- Generate mocks from backend HAR files before the real API is ready.
Testing edge cases -- Record real traffic with different inputs, get automatic conditional routing.
CI/CD -- Replace flaky external API dependencies with reliable local mocks.
pip install -e ".[dev]"
pytest tests/ -vMIT License - See LICENSE file.