Playwright Network Chaos Mcp

io.github.vola-trebla由 GitHub 账号 vola-trebla 发布v0.2.1更新于 Oct 24, 2026

MCP server that gives AI agents dynamic network chaos control over Playwright browser sessions

已验证STDIO仅桌面浏览器自动化开发者工具

概览

AI 生成的概览

让 AI 助手在 Playwright 浏览器会话中注入网络故障、延迟和资源拦截,并检查页面是否能正常处理。

可以做什么
运行 Playwright 浏览器会话,拦截匹配的请求以强制返回错误状态码、加入带抖动的延迟、中止第三方资源、在请求中途断开连接,或返回操作系统级网络错误。还支持有状态失败(前 N 次请求失败后恢复成功)以及协议层响应损坏,例如畸形 JSON。每个工具都会报告拦截请求数量、是否出现兜底或加载选择器,以及收集到的页面与控制台错误;assert_chaos_handled 返回通过或失败的判定。
适用场景
适合编写或验证 Playwright 测试中的错误处理、重试逻辑、加载状态和第三方服务中断的容错能力。当助手需要复现不稳定的网络条件并断言页面显示兜底界面而不是崩溃时,值得添加。
运行要求
需要本地 Node.js 运行环境;该 npm 包通过 npx 启动或全局安装。需要为 Playwright 安装 Chromium(npx playwright install chromium)。未声明需要账号、API 密钥或环境变量。
安装前请注意
该服务器会驱动真实浏览器并访问工具调用中给出的 URL,因此可能加载线上页面并向第三方主机发送请求。它只拦截和中止请求,不会修改应用数据,但测试可能触达结账或订单等真实接口,建议指向测试环境而非生产环境。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Playwright Network Chaos Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

playwright-network-chaos-mcp 🐸💥

[npm version] [npm downloads] [CI] [License: MIT]

An MCP server that gives AI agents dynamic network chaos control over Playwright browser sessions.

Your 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.


🤔 The Problem

CI 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.

AI agents writing Playwright tests have no way to introduce or reason about network instability. They can't ask:

  • 🙈 Does the checkout page show an error state when the payment API fails?
  • 🙈 Does the skeleton loader appear while the dashboard API is slow?
  • 🙈 Does the app still work if all tracking scripts are blocked?
  • 🙈 What happens if the network drops after the order is submitted but before the response arrives?

playwright-network-chaos-mcp fixes that.


🛠️ Tools

simulate_api_failure

Intercepts requests matching a pattern and forces them to return an error status code. Checks if the app shows a fallback UI.

json
{  "url": "https://your-app.com/checkout",  "intercept_pattern": "**/api/payment**",  "status_code": 503,  "fallback_selector": ".error-boundary",  "wait_ms": 2000}
json
{  "intercepted_count": 2,  "fallback_found": true,  "fallback_selector": ".error-boundary",  "page_state": {    "page_errors": [],    "console_errors": ["Failed to load resource: 503"]  }}

inject_latency

Adds artificial delay to matching requests. Checks if loading states appear while the app waits.

json
{  "url": "https://your-app.com/dashboard",  "intercept_pattern": "**/api/**",  "latency_ms": 3000,  "jitter_ms": 500,  "loading_selector": ".skeleton-loader"}
json
{  "intercepted_count": 4,  "intercepted_requests": [    { "url": "https://api.your-app.com/users", "method": "GET", "delay_ms": 3241 }  ],  "loading_state_found": true,  "load_time_ms": 3890}

block_resources

Aborts requests to specified URL patterns — for testing third-party outages (analytics, CDNs, tracking pixels).

json
{  "url": "https://your-app.com",  "block_patterns": ["**/analytics**", "*.doubleclick.net/**", "**/hotjar**"],  "core_content_selector": ".main-content",  "wait_ms": 2000}
json
{  "blocked_count": 7,  "blocked_urls": ["https://www.google-analytics.com/analytics.js", "..."],  "core_content_found": true,  "page_state": { "page_errors": [], "console_errors": [] }}

simulate_network_drop

Aborts requests mid-flight after a delay — simulating connection loss between request and response.

json
{  "url": "https://your-app.com/checkout",  "intercept_pattern": "**/api/order**",  "drop_after_ms": 800,  "fallback_selector": ".network-error-toast",  "wait_ms": 3000}
json
{  "intercepted_count": 1,  "fallback_found": true,  "fallback_selector": ".network-error-toast",  "page_state": { "page_errors": ["TypeError: Failed to fetch"] }}

trigger_system_network_error

Aborts requests with an OS-level error code — simulating DNS failures, firewall blocks, and connection resets.

json
{  "url": "https://your-app.com/dashboard",  "intercept_pattern": "**/api/**",  "error_code": "addressunreachable",  "fallback_selector": ".network-error"}
json
{  "error_code": "addressunreachable",  "intercepted_count": 3,  "fallback_found": true,  "page_state": { "page_errors": [], "console_errors": ["net::ERR_ADDRESS_UNREACHABLE"] }}

simulate_stateful_failure

Fails the first N requests then lets subsequent ones succeed — testing retry logic and recovery flows.

json
{  "url": "https://your-app.com/dashboard",  "intercept_pattern": "**/api/data**",  "http_status": 503,  "failure_count": 2,  "success_payload": "{\"data\":[]}",  "fallback_selector": ".retry-button"}
json
{  "failure_count": 2,  "actual_failed": 2,  "actual_succeeded": 1,  "intercepted_requests": [    { "url": "...", "method": "GET", "status": 503, "attempt": 1, "outcome": "failed" },    { "url": "...", "method": "GET", "status": 200, "attempt": 3, "outcome": "passed" }  ],  "fallback_found": true}

inject_response_corruption

Serves malformed responses at the protocol level — unterminated JSON, content-length lies, or truncated payloads.

json
{  "url": "https://your-app.com/checkout",  "intercept_pattern": "**/api/order**",  "corruption_type": "malformed_json",  "fallback_selector": ".parse-error"}
json
{  "corruption_type": "malformed_json",  "intercepted_count": 1,  "fallback_found": false,  "page_state": { "page_errors": ["SyntaxError: Unexpected token u in JSON"] }}

assert_chaos_handled

Injects 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.

json
{  "url": "https://your-app.com/checkout",  "intercept_pattern": "**/api/**",  "http_status": 500,  "expected_fallback_selector": ".error-boundary"}
json
{  "http_status": 500,  "unhandled_exceptions": [],  "console_errors": ["Failed to load resource: 500"],  "fallback_ui_detected": true,  "chaos_survived": true}

🚀 Installation

bash
npx playwright-network-chaos-mcp

Or install globally:

bash
npm install -g playwright-network-chaos-mcpnpx playwright install chromium

Claude Desktop config

json
{  "mcpServers": {    "playwright-network-chaos-mcp": {      "command": "npx",      "args": ["-y", "playwright-network-chaos-mcp"]    }  }}

💡 Example Agent Prompts

"Check if the checkout page shows a proper error state when the payment API returns 503"

"Simulate a 3 second API delay on the dashboard and verify the skeleton loader appears"

"Block all analytics and tracking scripts and confirm the main content still loads"

"Drop the order submission request mid-flight and check if the user sees an error message"

"Simulate DNS failure for the API and check if the error boundary renders"

"Fail the first 3 requests then succeed — does the app retry and recover automatically?"

"Inject malformed JSON and assert the app doesn't crash — return a chaos verdict"


🔗 Related Projects


📄 License

MIT © vola-trebla

来源:README.md,提交 dc79862

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.2.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分