Use Cases
Real-world scenarios where Madhyamas helps you debug, test, and build better software. Each use case includes a concrete walkthrough with commands and configuration you can copy.
API Development & Debugging
Inspect API calls from your frontend
You're building a React app and the API returns unexpected data. You need to see exactly what your frontend sends and what the server returns.
Steps:
- Start Madhyamas and configure your browser to use
localhost:8888as the HTTP proxy. - Open
http://localhost:3001for the dashboard. - Interact with your app — every request appears in real time.
- Click any request to inspect headers, query params, request body, and response body side by side.
- Use the JSON viewer to navigate large JSON responses with Tree view and JSONPath queries (
$.data.users[*].name).
# Start Madhyamas
./madhyamas
# Or via CLI, then use your browser
# Filter for just API calls
madhyamas traffic list --host api.example.com --status 200Tip: Use Focus Mode to highlight requests from a specific API host without hiding other traffic — useful when your page loads assets from CDNs alongside API calls.
Debug CORS errors
Your frontend at localhost:3000 calls an API at api.example.com and the browser blocks the request with a CORS error. You need to see the actual response headers.
Steps:
- Capture the preflight
OPTIONSrequest and the actual request. - Inspect the
Access-Control-Allow-Origin,Access-Control-Allow-Headers, andAccess-Control-Allow-Methodsresponse headers. - If the API is under your control, fix the server. If not, use a rewrite rule to inject CORS headers:
# Add CORS headers to responses from api.example.com
madhyamas rewrites add \
--name "Add CORS" \
--match-host "api.example.com" \
--action "response-header:Access-Control-Allow-Origin:*" \
--action "response-header:Access-Control-Allow-Methods:GET,POST,PUT,DELETE,OPTIONS" \
--enabledOr apply the built-in Add CORS rewrite template with one click from the Web UI.
Mobile App Debugging
Debug an iOS app's network calls
Your iOS app works in the simulator but fails on a real device. You need to inspect its network traffic.
Steps:
- Start Madhyamas on your development machine.
- On your iPhone, go to Settings > Wi-Fi > Configure Proxy and set it to your machine's IP on port
8888. - Install the Madhyamas CA certificate: visit
http://localhost:3001/certon your phone, then trust it in Settings > General > About > Certificate Trust Settings. - Use your app — all HTTPS traffic is now visible in the dashboard.
# Start with public IP so your phone can connect
./madhyamas --host 0.0.0.0 --public-ip 192.168.1.100See the Mobile Setup Guide for detailed iOS and Android instructions.
Bypass certificate pinning on Android
Some Android apps use certificate pinning and won't trust your proxy's CA. Madhyamas records these failed TLS handshakes as 502 entries so you can see which domains are pinning.
Steps:
- Start Madhyamas with HTTPS interception enabled.
- Use your app — pinned connections appear as
502entries with the error "TLS handshake failed." - To bypass pinning on a rooted device, use tools like Frida or
objectionalongside Madhyamas.
See Android Cert Pinning for detailed bypass instructions.
Mock APIs
Build a frontend before the backend is ready
Your team is building a new feature but the API isn't implemented yet. You need realistic responses to develop the UI.
Steps:
- Create a mock that matches the planned API endpoint:
madhyamas mocks add \
--name "Get Users" \
--match-method GET \
--match-url "*/api/users" \
--status 200 \
--content-type "application/json" \
--body '{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]}' \
--enabled- Your frontend now receives the mock response instead of a 404.
- Create multiple mocks for different endpoints and organize them into a collection.
- When the real API is ready, disable the mock with one click.
Record real traffic as mocks
You want to reproduce a production issue locally. Record real API responses from production, then replay them in your dev environment.
Steps:
- Point Madhyamas at production traffic.
- Use the Record feature to capture responses.
- Export recorded mocks as JSON:
madhyamas mocks export --output production-mocks.json- In your dev environment, import and enable them:
madhyamas mocks import --input production-mocks.json
madhyamas mocks enable --allTest error handling
You need to verify your app handles 500 errors, timeouts, and rate limiting gracefully.
# Mock a 500 error
madhyamas mocks add \
--name "Server Error" \
--match-url "*/api/payments" \
--status 500 \
--body '{"error":"internal_server_error"}' \
--enabled
# Mock a 429 rate limit
madhyamas mocks add \
--name "Rate Limited" \
--match-url "*/api/search" \
--status 429 \
--header "Retry-After:60" \
--enabledPerformance Testing
Simulate slow network conditions
Your app works great on fast WiFi but users on 3G report it's unusable. Test under realistic network conditions.
Steps:
- Enable throttling with a preset:
# Slow 3G preset
madhyamas throttle enable --preset "slow-3g"
# Or customize: 500ms latency, 1 Mbps bandwidth, 1% packet loss
madhyamas throttle enable --latency 500 --bandwidth 1mbps --packet-loss 1- Use your app and observe loading behavior.
- Check the waterfall timeline to see which requests are blocking and how long each takes.
Batch replay for load testing
You want to send the same request 100 times with 10 concurrent connections to stress-test an endpoint.
# Save a request first
madhyamas replay save --request-id abc123 --name "Login Test"
# Batch replay: 100 iterations, 10 concurrent, 100ms delay
madhyamas replay batch --id abc123 --iterations 100 --concurrency 10 --delay 100msView results in the dashboard or via CLI:
madhyamas replay history --limit 100Bug Reproduction & Regression Testing
Capture and replay a failing request
A user reports a bug but you can't reproduce it. Capture the exact request from their session and replay it.
Steps:
- Export the user's session as HAR:
madhyamas export har --session "bug-report-123" --output bug.har- Import it on your machine:
madhyamas sessions import --input bug.har --name "Bug Report 123"- Find the failing request and replay it:
madhyamas replay execute --id <request-id>- Modify the request and replay to test fixes:
madhyamas replay execute --id <request-id> \
--override-url "https://staging.example.com/api/login" \
--override-header "Authorization: Bearer test-token"API regression testing after deployment
After deploying a new version of your API, replay a captured session to verify nothing broke.
# Save a session of normal API usage
madhyamas sessions save --name "baseline-v1"
# After deployment, replay all requests against the new version
madhyamas replay batch --session "baseline-v1" \
--override-host "staging.example.com" \
--iterations 1 \
--compareSecurity Analysis
Inspect authentication tokens
You want to verify your app sends the correct auth headers and tokens aren't leaking to third-party domains.
Steps:
- Capture traffic while logging in and using the app.
- Filter for auth-related requests:
madhyamas traffic list --header "Authorization" --host "api.example.com"- Inspect the
Authorizationheader value — is it a JWT? An API key? Is it being sent to the right domains? - Check that third-party domains (analytics, CDNs) are not receiving your auth tokens.
Block ads and trackers during development
Ad and analytics scripts pollute your traffic logs. Block them to see only your app's requests.
# Block common ad/tracker domains
madhyamas blocklist add --pattern "*doubleclick.net*"
madhyamas blocklist add --pattern "*google-analytics.com*"
madhyamas blocklist add --pattern "*facebook.net*"
madhyamas blocklist add --pattern "*hotjar.com*"Or use the Web UI's Block List panel to add patterns with one click. See Block List for pattern syntax.
Remove security headers for testing
You need to test your app without CSP (Content-Security-Policy) to isolate whether CSP is blocking a script.
madhyamas rewrites add \
--name "Remove CSP" \
--match-host "localhost:3000" \
--action "response-header-remove:Content-Security-Policy" \
--enabledOr apply the Remove Security Headers template.
Automation & Scripting
Log all API calls automatically
You want a running log of every API call your app makes, written to a file for later analysis.
Create a JavaScript script in the Web UI or via CLI:
// script: api-logger
// hook: onResponse
function onResponse(request, response) {
if (request.url.includes("/api/")) {
console.log(`${request.method} ${request.url} -> ${response.status} (${response.bodySize} bytes)`);
}
return {};
}madhyamas scripts add --name "api-logger" --file ./api-logger.js --enabledEvery API call is now logged. View logs in the Scripts panel or in the terminal output.
Auto-inject auth headers for local development
Your local dev server doesn't implement auth, but your frontend expects an auth token. Inject one automatically.
madhyamas rewrites add \
--name "Inject Dev Auth" \
--match-host "localhost:3000" \
--action "request-header:Authorization:Bearer dev-token-12345" \
--enabledBlock specific domains with a script
You want fine-grained blocking logic that patterns can't express — for example, block all requests except those from your own domain.
// script: domain-guard
// hook: onRequest
function onRequest(request) {
const allowed = ["api.example.com", "cdn.example.com"];
const host = request.headers["host"] || "";
if (!allowed.some(a => host.includes(a))) {
return {
block: true,
status: 403,
body: "Blocked by domain-guard script"
};
}
return {};
}See the Scripting Guide for the full JS API and 13 built-in templates.
AI-Assisted Debugging
Debug with Claude Desktop
Connect Claude to your Madhyamas instance so it can inspect traffic, create mocks, and replay requests on your behalf.
Steps:
- Start Madhyamas in MCP server mode:
madhyamas mcp- Add to your Claude Desktop config (
~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"madhyamas": {
"command": "/path/to/madhyamas",
"args": ["mcp"]
}
}
}- Restart Claude Desktop and ask:
"List all failed requests from the last 10 minutes and tell me what went wrong."
Claude will use Madhyamas MCP tools to query traffic, inspect responses, and summarize the issues. See the MCP Guide for setup with Windsurf, Cursor, Devin, and other agents.
Automated traffic analysis in CI/CD
Use the REST API to capture and analyze traffic during automated tests.
# Start a fresh session for your test run
curl -X POST http://localhost:3001/api/sessions \
-H "Content-Type: application/json" \
-d '{"name":"e2e-test-run-$(date +%s)"}'
# Run your tests...
# Check for any 5xx errors
curl "http://localhost:3001/api/traffic?status=5xx&session=current" | jq '.[] | {url, status, error}'
# Export the session for archival
curl -X GET "http://localhost:3001/api/export/har?session=current" -o test-run.harTeam & Enterprise Scenarios
Shared debugging proxy for a team
Multiple developers need to debug the same staging server. Instead of running individual proxies, deploy one Madhyamas Enterprise instance with authentication.
Steps:
- Deploy Madhyamas Enterprise with PostgreSQL and Redis (see Enterprise Getting Started):
- Create user accounts for each developer:
madhyamas users create --username alice --role admin
madhyamas users create --username bob --role user- Each developer configures their browser to use the shared proxy and logs in with their credentials.
- All traffic is captured with per-user attribution in the audit log.
Compliance audit trail
Your organization requires an audit trail of who inspected what traffic and when.
Steps:
- Deploy Madhyamas Enterprise with audit logging enabled.
- All user actions (login, traffic inspection, config changes, mock creation) are recorded in the audit log with SHA-256 hash chaining for tamper detection.
- Export the audit log for compliance reviews:
madhyamas audit export --from 2025-01-01 --to 2025-01-31 --output audit-january.json- Verify hash chain integrity:
madhyamas audit verify --input audit-january.jsonSee the Audit Logging Guide for details.
Multi-instance production debugging
You run Madhyamas behind a load balancer with multiple instances for high availability. Traffic captured on any instance is visible on all.
Steps:
- Deploy 2+ Madhyamas instances with shared PostgreSQL and Redis (see Multi-Instance Deployment).
- Configure nginx as the load balancer:
upstream madhyamas {
server instance1:3001;
server instance2:3001;
}- All instances share the same traffic store, sessions, and configuration.
- Redis pub/sub propagates real-time traffic events across instances — the WebSocket dashboard updates regardless of which instance served the request.
API key for CI/CD pipelines
Your CI pipeline needs to interact with Madhyamas programmatically.
# Create an API key (admin only)
madhyamas auth api-keys create --name "ci-pipeline" --scope "traffic:read,mocks:write"
# Use the API key in your pipeline
export MADHYAMAS_API_KEY="mad_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
curl -H "X-API-Key: $MADHYAMAS_API_KEY" http://madhyamas:3001/api/trafficSee Enterprise CLI & MCP for authenticated API and MCP access.
Advanced Networking
Chain through a corporate proxy
Your office network requires all outbound traffic through a corporate proxy. Madhyamas can chain through it.
./madhyamas --upstream-proxy-enabled \
--upstream-proxy corporate-proxy.example.com:8080 \
--upstream-protocol httpUse the bypass list for internal hosts that shouldn't go through the corporate proxy:
--upstream-no-proxy "localhost,127.0.0.1,*.internal.example.com"See Upstream Proxy for all options.
Debug gRPC microservices
Your microservices communicate via gRPC and you need to inspect the protobuf payloads.
Steps:
- Enable HTTP/2 downstream:
./madhyamas --enable-http2- Configure your gRPC client to use Madhyamas as its HTTP/2 proxy.
- gRPC calls appear in the dashboard with decoded protobuf messages (when schema is available).
See HTTP/2 & gRPC for configuration details.
Inspect WebSocket traffic
Your chat app uses WebSockets and messages aren't being delivered. Inspect the WebSocket frames.
Steps:
- Capture traffic while using the chat app.
- WebSocket connections appear in the traffic list with a
WSbadge. - Click the connection to see all frames — both client-to-server and server-to-client — with timestamps and payload inspection.
See WebSocket Inspection for details.
Tunnel non-HTTP traffic with SOCKS5
You need to tunnel a database connection or SSH through the proxy.
./madhyamas --enable-socks --socks-port 1080
# Connect through SOCKS5
ssh -o ProxyCommand="nc -X 5 -x localhost:1080 %h %p" user@db-server.internalSee SOCKS5 Proxy for supported protocols and limitations.
Session Management & Collaboration
Share a debugging session with a teammate
You captured traffic that reproduces a bug. Export it so a teammate can import and investigate.
# Export as HAR
madhyamas export har --session "bug-repro" --output bug-repro.har
# Share the HAR file (via Slack, email, GitHub, etc.)
# Your teammate imports it:
madhyamas sessions import --input bug-repro.har --name "Bug from Alice"Compare staging vs production traffic
You suspect the API behaves differently in staging vs production. Capture both and compare.
Steps:
- Create a session named "production":
madhyamas sessions create --name "production"- Browse your app against production.
- Switch to a "staging" session and browse against staging:
madhyamas sessions switch --name "staging"- Use the Focus feature to highlight requests from the API host in both sessions and compare responses side by side.
Data Archival & Compliance
Auto-save sessions for long-running captures
You're running a long capture session and want automatic backups in case of a crash.
# Enable auto-save every 5 minutes, keep last 10 backups
madhyamas autosave enable --interval 5m --max-backups 10 --format harSee Auto Save for rotation and retention options.
Mirror API responses to disk
You want to archive API responses for offline analysis or build a mock data library from real traffic.
# Enable mirror tool — saves response bodies to ~/.madhyamas/mirror/
madhyamas mirror enable --path ~/.madhyamas/mirror/Responses are saved following the URL path structure. See Mirror Tool for configuration.
Migrating from Other Tools
Switch from Charles Proxy
Coming from Charles? Here's how to map your workflow:
| Charles Feature | Madhyamas Equivalent |
|---|---|
| Map Local | Rewrites — replace response body |
| Map Remote | Rewrites — redirect host |
| Breakpoints | Breakpoints |
| Repeat Advanced | Batch Replay |
| Throttling | Throttling |
| SSL Certificates | Automatic CA generation |
| Sessions | Sessions |
Import your Charles sessions:
# Export from Charles as HAR, then import
madhyamas sessions import --input charles-export.har --name "Charles Import"See the full Migration Guide.
Switch from Fiddler
Import Fiddler captures (exported as HAR):
madhyamas sessions import --input fiddler-export.har --name "Fiddler Import"Use rewrite templates to replace Fiddler's auto-responder rules.
Quick Reference: Use Case to Feature Map
| I want to... | Use this feature |
|---|---|
| See all HTTP traffic | Traffic Inspection |
| Pause and modify a request | Breakpoints |
| Return fake responses | Mocks |
| Automatically modify traffic | Rewrites |
| Re-send a captured request | Replay |
| Simulate slow network | Throttling |
| Block domains | Block List |
| Highlight specific hosts | Focus |
| See request timing | Timeline View |
| Organize traffic into groups | Sessions |
| Export traffic for sharing | HAR Export |
| Import traffic from browser | HAR Import |
| Write custom automation | Scripting |
| Extend with WASM | Plugins |
| Debug with AI agents | MCP |
| Tunnel non-HTTP TCP | SOCKS5 |
| Chain through corporate proxy | Upstream Proxy |
| Inspect gRPC | HTTP/2 & gRPC |
| Inspect WebSocket | WebSocket |
| Save responses to disk | Mirror |
| Auto-backup sessions | Auto Save |
| Add auth and RBAC | Enterprise |
| Audit who did what | Audit Logging |
| Scale across instances | Multi-Instance |
| Authenticate API access | API Keys |