MCP Failure Lab
A chaos-engineering and resilience-testing toolkit for Model Context Protocol servers, enabling deterministic fault injection and testing of reliability scenarios.
README
MCP Failure Lab
A chaos-engineering and resilience-testing toolkit for Model Context Protocol servers.
Goal
MCP Failure Lab helps server authors reproduce transport failures, hanging tools, malformed responses, session loss, cancellation races, and other reliability problems in a deterministic way.
The project is being built incrementally, with an emphasis on protocol correctness, reproducible tests, explicit failure semantics, and clean operational behavior.
Status
Early development.
The first working milestone includes:
- A TypeScript command-line application
- A
servecommand - An MCP server factory
- MCP communication over stdio
- A discoverable
pingtool - Dependency-injected time for deterministic testing
- Unit coverage for the ping result
- Graceful
SIGINTandSIGTERMhandling - Clean, reproducible build output
- Manual end-to-end verification with MCP Inspector
Scenario execution and fault injection are not implemented yet.
Architecture
Current architecture
graph LR
Host[MCP Host or Inspector] --> Transport[stdio Transport]
Transport --> Host
Transport --> Server[MCP Server]
Server --> Transport
Server --> Registration[Ping Tool Registration]
Registration --> Result[Ping Result]
CLI[CLI serve command] --> Transport
CLI --> Server
The current implementation has four responsibilities:
- CLI — parses commands and starts the server through
serve. - Transport —
StdioServerTransportexchanges JSON-RPC messages over standard input and output. - Server factory —
createServerconstructs and configures the MCP server without starting I/O. - Ping tool — registers the first MCP capability and returns a deterministic, testable health response.
Server construction and server execution remain separate. This allows future transports and integration tests to reuse the same server configuration.
Request flow
MCP Host
→ stdio transport
→ MCP server
→ ping tool handler
→ ping result
→ MCP response
Diagnostics must never be written to stdout while the stdio transport is active because stdout carries MCP protocol messages. Operational diagnostics are written to stderr.
Planned architecture
graph TD
CLI[CLI] --> Runner[Scenario Runner]
Runner --> Proxy[Fault Injection Proxy]
Proxy --> Target[Target MCP Server]
Runner --> Assertions[Assertion Engine]
Assertions --> Reporters[Reporters]
Reporters --> ConsoleReport[Console Report]
Reporters --> JsonReport[JSON Report]
Reporters --> JunitReport[JUnit Report]
Planned capabilities include:
- Deterministic fault scenarios
- Response delays and hanging tools
- Transport interruption
- Malformed MCP messages
- Duplicate responses
- Session loss
- Cancellation testing
- Timeout assertions
- Reproduction metadata
- Console, JSON, and JUnit reports
The architecture will evolve incrementally. New abstractions will be introduced only when supported by a concrete requirement and corresponding tests.
Requirements
- Node.js 22.19.0 or newer
- npm
Install for development
Clone the repository and install its dependencies:
git clone https://github.com/anilloutombam/mcp-failure-lab.git
cd mcp-failure-lab
npm install
The package has not been published to npm yet.
Usage
Display CLI help:
npm run dev -- --help
Display the current version:
npm run dev -- --version
Start the MCP server over stdio:
npm --silent run dev -- serve
The process waits silently for an MCP client. Press Ctrl+C to shut it down gracefully.
Inspect the MCP server
Launch the official MCP Inspector:
npx @modelcontextprotocol/inspector npm --silent run dev -- serve
In the Inspector:
- Connect using the stdio transport.
- Open Tools.
- List the available tools.
- Select
ping. - Run the tool.
A successful response resembles:
{
"status": "ok",
"timestamp": "2026-07-31T16:32:47.570Z"
}
Do not share or commit the temporary authentication token included in the Inspector URL.
Development commands
Format the repository:
npm run format
Check formatting without modifying files:
npm run format:check
Run TypeScript validation:
npm run typecheck
Run tests:
npm test
Create a clean production build:
npm run build
Run the compiled CLI:
npm run start -- --help
Project structure
mcp-failure-lab/
├── README.md
├── package.json
├── package-lock.json
├── tsconfig.json
├── src/
│ ├── cli.ts
│ ├── ping.ts
│ └── server.ts
└── tests/
├── unit/
│ └── ping.test.ts
├── integration/
└── e2e/
Generated directories such as dist/, coverage/, and node_modules/ are not committed.
Testing strategy
The project separates tests by responsibility:
- Unit tests validate isolated domain behavior.
- Integration tests will validate MCP client-server communication and transports.
- End-to-end tests will validate CLI-driven scenarios involving real processes.
The current ping test injects a fixed clock so its result is deterministic across machines, timezones, and test runs.
Engineering principles
- Prefer small, explicit interfaces.
- Keep transport logic separate from tool behavior.
- Treat all protocol and scenario data as untrusted.
- Handle cancellation, timeouts, process signals, and cleanup explicitly.
- Avoid writing diagnostics to stdout during stdio operation.
- Introduce abstractions only after a concrete requirement appears.
- Add regression coverage for every bug fix.
- Keep commits focused and reviewable.
Development workflow
Development happens through focused branches and pull requests:
git switch -c feat/example-change
Before opening a pull request, run:
npm run format:check
npm run typecheck
npm test
npm run build
The main branch should remain in a working, reviewable state.
Roadmap
- [x] Initialize the TypeScript CLI
- [x] Add the MCP server factory
- [x] Add stdio transport
- [x] Add the deterministic
pingtool - [x] Validate the server with MCP Inspector
- [ ] Add MCP client-server integration coverage
- [ ] Define the scenario schema
- [ ] Add the first response-delay fault
- [ ] Add timeout assertions
- [ ] Add structured reports
- [ ] Add CI
- [ ] Add Streamable HTTP support
- [ ] Publish the first npm prerelease
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。