Mission: Turn production traffic into testable mock servers in under 2 minutes - zero configuration required.
MockClaw = Traffic Capture + AI Analysis + One-Click Mock Server
Stop writing 500-line JSON mock configs by hand. Stop waiting for backend teams to give you API docs. Stop manually crafting test data for every edge case.
MockClaw watches your app make HTTP requests, analyzes the traffic patterns, and instantly generates a fully-functional mock API server - complete with:
- Smart conditional routing (different responses for different inputs)
- Auto-injected security (rate limiting, path traversal protection)
- Interactive API docs (Swagger UI)
- Chaos engineering (built-in adversarial testing)
Linux/Mac:
./install.shWindows:
install.batThis will:
- Check Python version (requires 3.11+)
- Create virtual environment
- Install all dependencies
- Install MockClaw CLI
After installation:
# Activate environment
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate.bat # Windows
# Try it out!
mockclaw example# 1. Install
pip install -r src/requirements.txt
# 2. Launch Web UI
web\start.bat
# 3. In browser:
# - Drag & drop HAR file (or use sample)
# - Click "Generate Mock Server"
# - Click "Start Server"
# - Done! Test at http://localhost:8000/docsTotal time: < 2 minutes from install to testing
# 1. Install
pip install -r src/requirements.txt
# 2. Generate from sample (no LLM key needed!)
python -m src.cli generate tests/gauntlet/flow.har ./my_mocks --smart-fallback
# 3. Start server
python -m src.cli serve ./my_mocks --port 8000
# 4. Test (in new terminal)
pytest tests/ -vExpected output:
Generated 6/6 endpoints
Server running on port 8000
API docs: http://localhost:8000/docs
Windows PowerShell:
# Health check
Invoke-RestMethod -Uri http://localhost:8000/health
# Test expired coupon
$body = @{user_id="test123"; coupon_code="EXPIRED2026"; shipping_address="123 Main St"} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri http://localhost:8000/checkout -ContentType "application/json" -Body $body
# Test valid coupon
$body = @{user_id="test123"; coupon_code="SAVE10"; shipping_address="123 Main St"} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri http://localhost:8000/checkout -ContentType "application/json" -Body $bodyPython (Cross-Platform):
import requests
# Health check
requests.get('http://localhost:8000/health').json()
# Test expired coupon
requests.post('http://localhost:8000/checkout',
json={'user_id': 'test123', 'coupon_code': 'EXPIRED2026', 'shipping_address': '123 Main St'})
# Test valid coupon
requests.post('http://localhost:8000/checkout',
json={'user_id': 'test123', 'coupon_code': 'SAVE10', 'shipping_address': '123 Main St'})cURL (Linux/Mac/Git Bash):
# Health check
curl http://localhost:8000/health
# Test expired coupon
curl -X POST http://localhost:8000/checkout \
-H "Content-Type: application/json" \
-d '{"user_id":"test123","coupon_code":"EXPIRED2026","shipping_address":"123 Main St"}'
# Test valid coupon
curl -X POST http://localhost:8000/checkout \
-H "Content-Type: application/json" \
-d '{"user_id":"test123","coupon_code":"SAVE10","shipping_address":"123 Main St"}'# 1. Manually write mock config (2-3 hours)
cat > mock_config.json << 'EOF'
{
"/api/login": {
"POST": {
"responses": {
"200": { "body": {...} },
"400": { "body": {...} },
"401": { "body": {...} }
}
}
},
"/api/checkout": {
"POST": {
"responses": {
"200": { "body": {...} },
"400": { "body": {...} },
"500": { "body": {...} }
}
}
},
# ... 500 more lines of tedious JSON
}
EOF
# 2. Set up mock server (30 min)
# 3. Configure routing logic (1 hour)
# 4. Add security middleware (30 min)
# 5. Test manually (1 hour)
# Total: 5+ hours of soul-crushing work# 1. Browse your app once (automatic HAR capture)
# 2. Run one command (3 seconds)
python -m src.cli generate traffic.har ./mocks --smart-fallback
# 3. Start server (instant)
python -m src.cli serve ./mocks
# Total: 2 minutes, zero configuration, production-perfect mocks| Problem | Old Way | MockClaw Way |
|---|---|---|
| Test data creation | Manual JSON writing (hours) | Traffic capture (seconds) |
| Mock configuration | 500+ line config files | Auto-generated from HAR |
| Environment setup | Wait for backend APIs | Start mock server instantly |
| Edge case testing | Manually craft each scenario | Record real user sessions |
| Security | Forget to add rate limiting | Auto-injected middleware |
"I captured production traffic, generated a mock server, and was testing my frontend - all in under 2 minutes. My team thought I was a wizard."
- Every MockClaw User Ever
- Drag & Drop HAR file
- Preview detected endpoints
- Generate mock server with one click
- Launch interactive API docs
Generated code from a single HAR file:
@app.post("/checkout")
async def post__checkout(request: Request):
body = await request.json()
# Auto-generated conditional routing
if body.get("coupon_code") == "EXPIRED2026":
raise HTTPException(400, detail={"error": "Coupon expired"})
elif body.get("coupon_code") == "SAVE10":
return {"order_id": "ORD-123", "status": "confirmed"}
else:
return {"status": "default"} # FallbackNo LLM. No configuration. Pure rule-based magic.
- Rule-based routing - Analyzes request bodies to generate if/elif/else logic
- No LLM required - Works offline with zero API keys
- Backward compatible - Falls back to first response if no patterns match
Every generated mock includes:
- Rate Limiting (60 requests/minute per IP)
- Path Traversal Protection (blocks
../attacks) - Global Error Handling (safe JSON responses)
Built-in Swagger UI at http://localhost:8000/docs:
- Test endpoints directly in browser
- View request/response schemas
- Download OpenAPI spec
Built-in adversarial testing:
# Standard tests (no Docker)
python scripts/enhanced_chaos_test.py
# Hardcore tests (with Docker infrastructure sabotage)
python scripts/hardcore_chaos_test.py --use-dockerTests include:
- Container kill during requests
- Network drop simulation
- Disk pressure (fill to 99%)
- Garbage payload handling
- Path traversal attacks
# Record traffic (requires Dummy Shop running)
mockclaw record --output my_traffic.har
# Generate mocks
mockclaw generate my_traffic.har ./mocks --smart-fallback
# Start server
mockclaw serve ./mocks --port 8000
# Run chaos tests
mockclaw test ./mocks --hardcoreSee docs/API.md for complete CLI and library API documentation.
See docs/ARCHITECTURE.md for technical deep-dive.
Scenario: Backend API isn't ready yet.
MockClaw Solution:
- Get HAR file from backend team (or record from staging)
- Generate mock server
- Develop frontend against realistic mocks
- Swap in real API when ready
Time saved: Days of waiting → 2 minutes
Scenario: Need to test expired coupons, invalid tokens, rate limits.
MockClaw Solution:
- Record real user checkout flow
- Generate mocks with Smart Fallback
- Mock automatically routes based on coupon code
- Test all scenarios without manual setup
Time saved: Hours of config → seconds
Scenario: Tests flake out due to external API dependencies.
MockClaw Solution:
# .github/workflows/test.yml
- name: Generate mocks
run: mockclaw generate tests/fixtures.har ./mocks --smart-fallback
- name: Start mock server
run: mockclaw serve ./mocks --port 8000 &
- name: Run tests
run: pytest tests/ -vResult: 100% reliable tests, zero external dependencies
If you have an OpenAI API key:
export OPENAI_API_KEY=sk-...
mockclaw generate traffic.har ./mocksLLM will generate more realistic mock implementations with:
- Better variable names
- More descriptive docstrings
- Smarter default responses
Add your own middleware to generated mocks:
# custom_middleware.py
from fastapi import Request, Response
from starlette.middleware.base import BaseHTTPMiddleware
class AuthMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next):
token = request.headers.get("Authorization")
if not token or token != "Bearer secret":
return JSONResponse(401, {"error": "Unauthorized"})
return await call_next(request)Generated code will include:
from custom_middleware import AuthMiddleware
app.add_middleware(AuthMiddleware)# Build image
docker build -t mockclaw-mocks .
# Run with Docker Compose
docker-compose up -d
# Health check
curl http://localhost:8000/health| Metric | MockClaw | Manual Setup |
|---|---|---|
| Setup time | 2 minutes | 5+ hours |
| Config size | Auto-generated | 500+ lines JSON |
| Security | Auto-injected | Manual (often forgotten) |
| Edge cases | Recorded from traffic | Manually crafted |
| CI/CD ready | Yes | Usually not |
# Fork and clone
git clone https://github.com/YOUR_USERNAME/mockclaw.git
cd mockclaw
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Start Web UI (auto-reload)
streamlit run web/app.pySee CONTRIBUTING.md for detailed guidelines.
- Smart Fallback bug fixes
- Web UI MVP (Streamlit)
- Fresh Install testing (< 2 min FTUE)
- Viral README and demo GIFs
- WebSocket support
- Database mock generation
- Traffic replay mode
- Multi-language support (Node.js, Go)
Built with:
- FastAPI - Modern Python web framework
- Streamlit - Web UI framework
- Typer - CLI framework
- orjson - Fast JSON library
MIT License - See LICENSE file.
- GitHub Issues: Report bugs or request features
- Discussions: Share your use cases
- Twitter: @MockClaw
Made with love by Test Developers, for Test Developers
