{
  "markdown": "# playwright-network-chaos-mcp 🐸💥\n\n[![npm version](https://img.shields.io/npm/v/playwright-network-chaos-mcp.svg)](https://www.npmjs.com/package/playwright-network-chaos-mcp)\n[![npm downloads](https://img.shields.io/npm/dm/playwright-network-chaos-mcp.svg)](https://www.npmjs.com/package/playwright-network-chaos-mcp)\n[![CI](https://github.com/vola-trebla/playwright-network-chaos-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/vola-trebla/playwright-network-chaos-mcp/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nAn MCP server that gives AI agents **dynamic network chaos control** over Playwright browser sessions.\n\nYour tests run on perfect networks. Your users don't. This MCP lets AI agents simulate API outages, inject latency, drop connections mid-flight, and block third-party resources — then assert whether the app handles it gracefully.\n\n---\n\n## 🤔 The Problem\n\nCI environments have flawless connectivity. APIs respond in milliseconds. CDNs never go down. So your tests pass — and then production breaks when the payment service returns a 503, the network drops mid-checkout, or Google Analytics hangs for 8 seconds and freezes the page.\n\nAI agents writing Playwright tests have no way to introduce or reason about network instability. They can't ask:\n\n- 🙈 _Does the checkout page show an error state when the payment API fails?_\n- 🙈 _Does the skeleton loader appear while the dashboard API is slow?_\n- 🙈 _Does the app still work if all tracking scripts are blocked?_\n- 🙈 _What happens if the network drops after the order is submitted but before the response arrives?_\n\n`playwright-network-chaos-mcp` fixes that.\n\n---\n\n## 🛠️ Tools\n\n### `simulate_api_failure`\n\nIntercepts requests matching a pattern and forces them to return an error status code. Checks if the app shows a fallback UI.\n\n```json\n{\n  \"url\": \"https://your-app.com/checkout\",\n  \"intercept_pattern\": \"**/api/payment**\",\n  \"status_code\": 503,\n  \"fallback_selector\": \".error-boundary\",\n  \"wait_ms\": 2000\n}\n```\n\n```json\n{\n  \"intercepted_count\": 2,\n  \"fallback_found\": true,\n  \"fallback_selector\": \".error-boundary\",\n  \"page_state\": {\n    \"page_errors\": [],\n    \"console_errors\": [\"Failed to load resource: 503\"]\n  }\n}\n```\n\n---\n\n### `inject_latency`\n\nAdds artificial delay to matching requests. Checks if loading states appear while the app waits.\n\n```json\n{\n  \"url\": \"https://your-app.com/dashboard\",\n  \"intercept_pattern\": \"**/api/**\",\n  \"latency_ms\": 3000,\n  \"jitter_ms\": 500,\n  \"loading_selector\": \".skeleton-loader\"\n}\n```\n\n```json\n{\n  \"intercepted_count\": 4,\n  \"intercepted_requests\": [\n    { \"url\": \"https://api.your-app.com/users\", \"method\": \"GET\", \"delay_ms\": 3241 }\n  ],\n  \"loading_state_found\": true,\n  \"load_time_ms\": 3890\n}\n```\n\n---\n\n### `block_resources`\n\nAborts requests to specified URL patterns — for testing third-party outages (analytics, CDNs, tracking pixels).\n\n```json\n{\n  \"url\": \"https://your-app.com\",\n  \"block_patterns\": [\"**/analytics**\", \"*.doubleclick.net/**\", \"**/hotjar**\"],\n  \"core_content_selector\": \".main-content\",\n  \"wait_ms\": 2000\n}\n```\n\n```json\n{\n  \"blocked_count\": 7,\n  \"blocked_urls\": [\"https://www.google-analytics.com/analytics.js\", \"...\"],\n  \"core_content_found\": true,\n  \"page_state\": { \"page_errors\": [], \"console_errors\": [] }\n}\n```\n\n---\n\n### `simulate_network_drop`\n\nAborts requests mid-flight after a delay — simulating connection loss between request and response.\n\n```json\n{\n  \"url\": \"https://your-app.com/checkout\",\n  \"intercept_pattern\": \"**/api/order**\",\n  \"drop_after_ms\": 800,\n  \"fallback_selector\": \".network-error-toast\",\n  \"wait_ms\": 3000\n}\n```\n\n```json\n{\n  \"intercepted_count\": 1,\n  \"fallback_found\": true,\n  \"fallback_selector\": \".network-error-toast\",\n  \"page_state\": { \"page_errors\": [\"TypeError: Failed to fetch\"] }\n}\n```\n\n---\n\n### `trigger_system_network_error`\n\nAborts requests with an OS-level error code — simulating DNS failures, firewall blocks, and connection resets.\n\n```json\n{\n  \"url\": \"https://your-app.com/dashboard\",\n  \"intercept_pattern\": \"**/api/**\",\n  \"error_code\": \"addressunreachable\",\n  \"fallback_selector\": \".network-error\"\n}\n```\n\n```json\n{\n  \"error_code\": \"addressunreachable\",\n  \"intercepted_count\": 3,\n  \"fallback_found\": true,\n  \"page_state\": { \"page_errors\": [], \"console_errors\": [\"net::ERR_ADDRESS_UNREACHABLE\"] }\n}\n```\n\n---\n\n### `simulate_stateful_failure`\n\nFails the first N requests then lets subsequent ones succeed — testing retry logic and recovery flows.\n\n```json\n{\n  \"url\": \"https://your-app.com/dashboard\",\n  \"intercept_pattern\": \"**/api/data**\",\n  \"http_status\": 503,\n  \"failure_count\": 2,\n  \"success_payload\": \"{\\\"data\\\":[]}\",\n  \"fallback_selector\": \".retry-button\"\n}\n```\n\n```json\n{\n  \"failure_count\": 2,\n  \"actual_failed\": 2,\n  \"actual_succeeded\": 1,\n  \"intercepted_requests\": [\n    { \"url\": \"...\", \"method\": \"GET\", \"status\": 503, \"attempt\": 1, \"outcome\": \"failed\" },\n    { \"url\": \"...\", \"method\": \"GET\", \"status\": 200, \"attempt\": 3, \"outcome\": \"passed\" }\n  ],\n  \"fallback_found\": true\n}\n```\n\n---\n\n### `inject_response_corruption`\n\nServes malformed responses at the protocol level — unterminated JSON, content-length lies, or truncated payloads.\n\n```json\n{\n  \"url\": \"https://your-app.com/checkout\",\n  \"intercept_pattern\": \"**/api/order**\",\n  \"corruption_type\": \"malformed_json\",\n  \"fallback_selector\": \".parse-error\"\n}\n```\n\n```json\n{\n  \"corruption_type\": \"malformed_json\",\n  \"intercepted_count\": 1,\n  \"fallback_found\": false,\n  \"page_state\": { \"page_errors\": [\"SyntaxError: Unexpected token u in JSON\"] }\n}\n```\n\n---\n\n### `assert_chaos_handled`\n\nInjects a chaos HTTP status and returns a structured pass/fail verdict — `chaos_survived` is true only when the fallback UI appears and there are no unhandled JS exceptions.\n\n```json\n{\n  \"url\": \"https://your-app.com/checkout\",\n  \"intercept_pattern\": \"**/api/**\",\n  \"http_status\": 500,\n  \"expected_fallback_selector\": \".error-boundary\"\n}\n```\n\n```json\n{\n  \"http_status\": 500,\n  \"unhandled_exceptions\": [],\n  \"console_errors\": [\"Failed to load resource: 500\"],\n  \"fallback_ui_detected\": true,\n  \"chaos_survived\": true\n}\n```\n\n---\n\n## 🚀 Installation\n\n```bash\nnpx playwright-network-chaos-mcp\n```\n\nOr install globally:\n\n```bash\nnpm install -g playwright-network-chaos-mcp\nnpx playwright install chromium\n```\n\n### Claude Desktop config\n\n```json\n{\n  \"mcpServers\": {\n    \"playwright-network-chaos-mcp\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"playwright-network-chaos-mcp\"]\n    }\n  }\n}\n```\n\n---\n\n## 💡 Example Agent Prompts\n\n> _\"Check if the checkout page shows a proper error state when the payment API returns 503\"_\n\n> _\"Simulate a 3 second API delay on the dashboard and verify the skeleton loader appears\"_\n\n> _\"Block all analytics and tracking scripts and confirm the main content still loads\"_\n\n> _\"Drop the order submission request mid-flight and check if the user sees an error message\"_\n\n> _\"Simulate DNS failure for the API and check if the error boundary renders\"_\n\n> _\"Fail the first 3 requests then succeed — does the app retry and recover automatically?\"_\n\n> _\"Inject malformed JSON and assert the app doesn't crash — return a chaos verdict\"_\n\n---\n\n## 🔗 Related Projects\n\n- [playwright-trace-decoder-mcp](https://github.com/vola-trebla/playwright-trace-decoder-mcp) — root-cause analysis of CI failures from Playwright traces\n- [flakiness-knowledge-graph-mcp](https://github.com/vola-trebla/flakiness-knowledge-graph-mcp) — knowledge graph of flaky test patterns\n- [ast-impact-mapper-mcp](https://github.com/vola-trebla/ast-impact-mapper-mcp) — find affected tests from code changes via TypeScript AST\n- [zod-contract-mock-forge-mcp](https://github.com/vola-trebla/zod-contract-mock-forge-mcp) — deterministic mock generation from Zod schemas\n- [playwright-spatial-layout-mcp](https://github.com/vola-trebla/playwright-spatial-layout-mcp) — geometric spatial awareness of web layouts\n\n---\n\n## 📄 License\n\nMIT © [vola-trebla](https://github.com/vola-trebla)\n",
  "bytes": 7996,
  "sha": "738298fced2fefcbd18d2c69651bdb69dbac1439a59c20ad57d586639816c892",
  "repo_slug": "vola-trebla/playwright-network-chaos-mcp",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_vola_trebla_playwright_network_d2ea98ac/readme"
}