Install: pip install mcp-testbench |
PyPI: pypi.org/project/mcp-testbench
What is mcp-testbench?
mcp-testbench is a testing, validation and CI tool for MCP (Model Context
Protocol) servers. It snapshots a server's tools, prompts and resources,
detects breaking changes against that
snapshot, lints the schema, and
replays recorded tool calls -- the full MCP server
testing workflow in one package with zero runtime dependencies
(stdlib only, no dependency on the official mcp package). It works
over stdio, Streamable HTTP and legacy SSE, and treats the server as a
black box, so it tests servers written in any language or framework --
including FastMCP and the official MCP SDK.
Quickstart
# 1. record the contract; commit the snapshot file
mcp-testbench snapshot -o mcp-snapshot.json -- python my_server.py
# 2. CI gate: exit 1 when a change breaks existing callers
mcp-testbench check mcp-snapshot.json -- python my_server.py
# 3. lint the schema (tools + prompts + resources)
mcp-testbench lint -- python my_server.py
# 4. replay recorded tool calls (JSONL); exit 1 if any call fails
mcp-testbench replay calls.jsonl -- python my_server.py
Guides
- Testing MCP servers -- the workflow, end to end
- MCP CI -- GitHub Action, pre-commit / prek hooks, exit codes
- Snapshot testing -- how MCP schema snapshots work
- Breaking changes -- what counts as breaking, input vs output
- FastMCP testing -- black-box testing for FastMCP servers
- Lint rules -- every MCP lint rule, with severities
- Tool-call replay -- replay recorded MCP tool calls in tests
- MCP server mode -- run mcp-testbench as an MCP server (serve, safe and live tools)
- Comparison -- mcp-testbench vs MCP Inspector, mcp-contract, mcptest, pytest-mcptest
pytest plugin
The pytest plugin loads automatically after install. Point it at your server and assert on the schema, the snapshot, and live tool calls:
def test_no_breaking_changes(mcp_schema, mcp_snapshot):
mcp_snapshot(mcp_schema, "mcp-snapshot.json") # writes on first run
def test_call(mcp_client):
result = mcp_client.call_tool("echo", {"text": "hi"})
assert result["content"][0]["text"] == "hi"