Record and replay MCP servers — VCR for the Model Context Protocol.
Project description
mcp-rec
VCR for the Model Context Protocol. Record any MCP server's traffic to a JSONL file, then replay it deterministically — for tests, bug reports, or running your client offline.
Why
MCP servers are great until they aren't:
- Your server passes locally but fails for someone else — and you have no way to share the exact session that broke.
- You want CI tests for your MCP server but you can't pin upstream API responses.
- You want to demo your agent offline.
- You want to bisect "when did this tool start returning empty results?" against a recording.
mcp-rec solves all four by acting as a transparent proxy: it sits between
your MCP client and any stdio MCP server, forwards every byte, and writes a
JSONL transcript. Later you can replay that transcript as if it were the
real server.
Install
pip install mcp-rec
# or
uvx mcp-rec --help
Zero dependencies. Pure Python ≥3.10.
Record
Point your MCP client at mcp-rec record instead of your usual server command:
// claude_desktop_config.json
{
"mcpServers": {
"filesystem": {
"command": "mcp-rec",
"args": [
"record",
"-o", "/tmp/filesystem-session.jsonl",
"--",
"npx", "-y", "@modelcontextprotocol/server-filesystem", "/some/path"
]
}
}
}
Use your client normally. Every JSON-RPC message in both directions is appended to the JSONL file:
{"ts": 1750000001.23, "dir": "client->server", "msg": {"jsonrpc":"2.0","id":1,"method":"tools/list"}}
{"ts": 1750000001.45, "dir": "server->client", "msg": {"jsonrpc":"2.0","id":1,"result":{"tools":[...]}}}
Replay
Replace the real server with mcp-rec replay <jsonl> in your client config:
{
"mcpServers": {
"filesystem": {
"command": "mcp-rec",
"args": ["replay", "/tmp/filesystem-session.jsonl"]
}
}
}
Incoming requests are matched against the recording by (method, params)
and the corresponding response is returned with the caller's id rewritten
in. Repeated identical requests pop their responses in original order.
Unknown methods return a JSON-RPC -32601 error so your client can tell
the recording doesn't cover them.
Use cases
| Workflow | How mcp-rec helps |
|---|---|
| Bug report | Record the failing session, attach the JSONL — anyone can reproduce. |
| CI tests | Replay against your client to assert behavior without hitting upstream APIs. |
| Offline demo | Record once, demo anywhere without the upstream service. |
| Regression bisect | Diff two recordings to find when the server's output changed. |
| Stress test the client | Replay to verify the client handles all your tool's response shapes. |
Limitations
- stdio transport only for now. SSE/HTTP transports are on the roadmap.
- Notifications (server-initiated, no id) are replayed once at startup, not interleaved with the request stream.
- The matcher is exact-match on
(method, params). If your params include timestamps or random IDs you'll get a-32601on replay — strip those fields in your client tests, or open an issue and we'll add a matcher config.
Companion projects
- ai-first-scraper-mcp — sample MCP server you can record against.
License
MIT © yubinkim444
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_rec-0.1.0.tar.gz.
File metadata
- Download URL: mcp_rec-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25c625e452bfe5a6eff07254cb34ee2f03fbb69a02aab7f465968172b44deb59
|
|
| MD5 |
122c5e8adad0206afeddb60a2db41360
|
|
| BLAKE2b-256 |
836e8656136965c6d6fd30c55de79e25825753d0f72a44b07f04ab3503dd6e45
|
File details
Details for the file mcp_rec-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_rec-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cd473748fbf7c103e92be4d030fc90b28855c2ff6f573838c4d912d43079dea
|
|
| MD5 |
9d6ef24413d9d6f2f62ad8c8fd6c8ed8
|
|
| BLAKE2b-256 |
9d0eab2acb8c734405aca70848501c602a88ddf1a7f0942f8aca4ee4826d8f7a
|