Tool-call replay

Record the calls your agents make. Replay them against every new version of the server.

Install: pip install mcp-testbench  |  PyPI: pypi.org/project/mcp-testbench

The replay file

One JSON object per line -- the tool, its arguments, and what the result must look like:

{{"tool": "echo", "arguments": {{"text": "hi"}}, "expect": {{"contains": "hi"}}}}
{{"tool": "add", "arguments": {{"a": 2, "b": 3}}, "expect": {{"text": "5"}}}}
{{"tool": "boom", "arguments": {{}}, "expect": {{"is_error": true}}}}
{{"tool": "add", "arguments": {{"a": 2, "b": 3}}, "expect": {{"structured": {{"result": 5}}}}}}
{{"tool": "add", "arguments": {{"a": 2, "b": 3}}, "expect": {{"json_path": {{"result": 5}}}}}}

Expectations

expect keyAsserts
contains / textthe text result contains / equals the value
is_errorthe call's isError flag
structureddeep-subset match against structuredContent (nested dicts subset-match recursively, lists match element-for-element, extra actual keys are ignored)
json_pathdotted path -> expected value, resolved against structuredContent when present, else the whole result

With no expect, a call passes if it does not error.

Running replay

mcp-testbench replay calls.jsonl -- python my_server.py
mcp-testbench replay calls.jsonl --url http://localhost:8000/mcp

Replay prints PASS/FAIL per call and exits 1 if any call fails, so it gates CI like the other commands. Replay needs a live server -- it is the one mode that cannot run from an offline definition, because it actually calls tools.

Replay vs snapshot testing

Snapshots prove the contract did not change. Replay proves the behaviour did not change: same calls, same expected results, new server version. Serious MCP test suites run both -- and until mcp-testbench, no Python MCP testing package shipped recorded tool-call replay at all (see the comparison).