Mcp Failure Lab

io.github.anilloutombam由 GitHub 账号 anilloutombam 发布v0.13.2更新于 Oct 31, 2026

Deterministic fault-injection server for testing how MCP clients handle failures and recover.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

一个确定性的故障注入 MCP 服务器,让助手和测试工具复现 MCP 客户端故障并检验其恢复能力。

可以做什么
  • 触发受控故障:延迟、挂起、传输中断、格式错误或重复的 JSON-RPC 响应、取消后的迟到响应、会话丢失、超大负载和无效进度通知
  • 用普通 ping 工具和调用进行中的协议 ping 检查存活与健康状态
  • 运行内置场景,记录故障结果后再发一次请求,观察连接是否仍可用
  • 通过 HTTP 或 stdio 对自己的 MCP 服务器运行场景,校验工具结果、超时以及适配器的建立与清理
  • 生成 JSON 或 JUnit 报告,并用退出码接入 CI
适用场景
适用于开发或测试 MCP 客户端与 SDK 时,需要可重复地复现超时、取消竞态、传输中断和非法响应,包括在 CI 中运行。日常助手任务不需要它。
运行要求
需要 Node.js 22.23.4 或更高版本及 npm;以 stdio 或本地 Streamable HTTP(默认 API 密钥。测试外部目标(如 GitHub MCP 服务器)需要该服务器的可执行文件位于 PATH,并在环境中设置 GITHUB_PERSONAL_ACCESS_TOKEN。
安装前请注意
HTTP 传输没有身份验证和 TLS,不可暴露到不受信任的网络。对外部目标运行时可能从环境传入 GITHUB_PERSONAL_ACCESS_TOKEN 等凭据,请勿写入配置文件。故障会故意破坏连接,可能终止服务器进程;一次通过的运行只代表所测的 SDK、版本、传输和协议组合。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

MCP Failure Lab

Reproduce MCP timeouts, cancellation races, transport loss, and invalid responses with repeatable tests and CI reports.

[MCP Failure Lab — Break it here. Trust it everywhere.]

[npm version] [CI] [MCP Registry] [GitHub MCP Registry]

[License: MIT]

Documentation · Compatibility · Project page

Example output (duration varies):

text
$ npx mcp-failure-lab demoMCP Failure Lab — DemoRunning a real 500ms delay scenario...
Scenario: Deterministic delay demoOutcome: successDuration: ~500 msAssertions: passed

Why this exists

Real MCP clients behave differently when things break. A timeout may leave a connection usable; an interrupted response may close it. A malformed reply may be rejected by one client and accepted by another.

Failure Lab makes those cases repeatable so you can check both the failed call and what happens next.

Real-world findings

  • Python SDK #3522: Python mcp 2.2.0 stayed closed after an interrupted HTTP response, rejected the next request, and raised an ExceptionGroup during cleanup.
  • Rust SDK #1283: rmcp 3.4.0 accepted an invalid response containing both result and error over stdio and HTTP.
  • Ruby SDK #589: mcp 1.6.1 accepted responses missing jsonrpc or declaring jsonrpc: "1.0" over stdio and HTTP in all three repeats. The Ruby report records all 60 executions; the results and upstream finding are included in the Observatory export.
  • Java SDK 2.0.1 accepted jsonrpc: "1.0" over both transports (#1156). Over stdio, responses missing jsonrpc or containing both result and error left the next ping timing out (#1157). See the Java report.
  • Duplicate-response comparison: all five tested SDKs completed the next ping. TypeScript reported the duplicate through its error callback; the other harnesses surfaced no call-level duplicate error.

The SDK comparisons describe specific tested versions, not every release. See the versioned reports for reproduction steps and limitations.

[MCP Failure Lab demonstrating a bounded delay and an expected timeout]

Quick start

Requires Node.js 22.23.4 or newer and npm.

bash
npx mcp-failure-lab demo

The demo needs no API key, external server, or global installation. To test your own MCP client, connect it to Failure Lab over stdio or local Streamable HTTP:

bash
npx mcp-failure-lab serve# Or:npx mcp-failure-lab serve --transport http

The stdio process waits for a client; it is not an interactive terminal command. Configure your client to launch it, or follow the getting started guide. Press Ctrl+C to stop a manually started server.

HTTP defaults to http://127.0.0.1:3000/mcp. It provides neither authentication nor TLS; do not expose it to an untrusted network.

Test your own MCP server

External targets support HTTP and stdio. After the repository setup, install the official GitHub MCP server with its executable on PATH and set GITHUB_PERSONAL_ACCESS_TOKEN in your environment. Then run:

bash
npm run dev -- run examples/scenarios/github-get-me.json \  --target examples/targets/github-stdio.json

The example calls GitHub's read-only get_me tool. Its target configuration uses envFrom to pass the token from your environment rather than storing it in JSON. For your own scenario and target configuration, use:

bash
npx mcp-failure-lab run scenario.json --target target.json

External runs check tool results, deadlines, and adapter setup and cleanup. They do not inject faults into another server; Failure Lab is not a proxy.

See the external targets guide for prerequisites, credential handling, and configuration.

What Failure Lab can break

The built-in server exposes these tools for testing client behavior:

ToolBehavior
pingReturns a deterministic health response
protocol_ping_livenessSends a bounded protocol ping during its in-flight call
delayWaits for a bounded duration before returning
hangRemains pending until the client cancels
disconnectInterrupts the active transport while a request is in flight
malformed_messageViolates one selected JSON-RPC response rule exactly once
duplicate_responseSends the same JSON-RPC response twice for one request
response_after_cancellationSends one late response for a cancelled stdio request
session_lossInvalidates the caller's legacy HTTP session
oversized_responseReturns a deterministic text payload up to 256 KiB
invalid_progressSends an unknown, regressing, or late progress notification

Protocol ping is distinct from the ping tool. Built-in scenarios default to MCP 2026-07-28; protocol liveness requires scenario protocolVersion: "2025-11-25". Both public transports accept legacy clients.

See the fault tools reference for timing bounds, activation, cancellation, cleanup, and transport limits.

oversized_response accepts sizeBytes from 0 through 262,144. It generates only ASCII x characters, so the text size is exact in UTF-8 bytes and contains no external data. The cap applies on both stdio and HTTP. Choose a size below your client's configured response limit to check success, then a size above that limit (but no more than 262,144) to check client rejection. The included 64 KiB scenario checks the exact returned text size and a follow-up request. The JSON-RPC and transport framing add bytes around the text, so a client's whole-message limit may trigger before sizeBytes reaches its threshold. The integration test confirms that a stdio client with a 4 KiB message limit accepts a 1 KiB payload and rejects an 8 KiB payload.

invalid_progress requires a client progress token and accepts unknown-token, regressing-progress, or after-completion. These are protocol notifications associated with one tool call; they are not tool result content. The unknown-token variant sends one notification with a different token. The regressing variant sends progress 2 followed by 1. The late variant sends one notification after the matching response on stdio or in the HTTP response stream. These violate request-token correlation, monotonic progress, and the completed-request lifecycle, respectively. Each variant is bounded and consumed once. See the regressing, unknown-token, and after-completion scenarios. The built-in runner can assert callback values with expect.progressValues; external target adapters do not report progress notifications and cannot use that assertion.

How recovery testing works

Trigger a fault, record its outcome, then make a second request on the same connection. A detected fault does not prove recovery; the follow-up must succeed too.

Scenario observe calls run after the primary call, including errors and timeouts. For example, duplicate-response.json calls duplicate_response, then uses ping to check that the connection remains usable:

bash
# From a repository checkoutnpm run dev -- run examples/scenarios/duplicate-response.json

This checks post-fault behavior, not an automatic recovery policy. A stdio disconnect terminates the server process and requires a new process and connection.

See Scenarios for outcome, duration, result, and observer assertions.

SDK / transport evidence

MCP Failure Observatory collects SDK and transport evidence. The repository reports preserve tested versions, methods, and limitations.

Results vary by SDK, version, transport, and protocol. A passing run is evidence for that combination, not a guarantee for every client.

CI usage

Save a scenario file with explicit expectations and timeouts, then produce a JUnit report:

bash
npx mcp-failure-lab run scenario.json --report junit > junit.xml

Pin the Failure Lab package version in CI so upgrades do not change the test environment unexpectedly.

Exit codes: 0 means expectations passed, 1 means the scenario could not be loaded or executed, and 2 means an assertion failed. An expected timeout can pass; an unexpected success can fail.

See Reporting for JSON, JUnit, and lifecycle diagnostics.

Documentation

Detailed guides live at mcplab.dev: Getting started · CLI · Architecture · Troubleshooting.

Contributing

See CONTRIBUTING.md for setup, tests, and the contribution workflow. Planned work is tracked in GitHub Issues.

If Failure Lab helps you test an MCP integration, consider starring the repository.

License

MIT

来源:README.md,提交 8c8772e

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:服务器未能启动。

版本历史

7
  1. v0.13.2最新Oct 31, 2026
  2. v0.13.1Oct 22, 2026
  3. v0.13.0Oct 18, 2026
  4. v0.12.0Oct 4, 2026
  5. v0.11.0Sep 27, 2026
  6. v0.10.0Sep 19, 2026
  7. v0.9.0Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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