mcp-vcr 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_vcr-0.1.0/LICENSE +21 -0
- mcp_vcr-0.1.0/PKG-INFO +12 -0
- mcp_vcr-0.1.0/README.md +187 -0
- mcp_vcr-0.1.0/mcp_vcr/__init__.py +46 -0
- mcp_vcr-0.1.0/mcp_vcr/cli.py +567 -0
- mcp_vcr-0.1.0/mcp_vcr/diff.py +466 -0
- mcp_vcr-0.1.0/mcp_vcr/interceptor.py +114 -0
- mcp_vcr-0.1.0/mcp_vcr/normalizer.py +218 -0
- mcp_vcr-0.1.0/mcp_vcr/recorder.py +132 -0
- mcp_vcr-0.1.0/mcp_vcr/redactor.py +123 -0
- mcp_vcr-0.1.0/mcp_vcr/replay.py +258 -0
- mcp_vcr-0.1.0/mcp_vcr/schema.py +31 -0
- mcp_vcr-0.1.0/mcp_vcr/schemas/transcript-schema-v1.json +84 -0
- mcp_vcr-0.1.0/mcp_vcr/snapshot.py +216 -0
- mcp_vcr-0.1.0/mcp_vcr/transport.py +288 -0
- mcp_vcr-0.1.0/mcp_vcr/validator.py +111 -0
- mcp_vcr-0.1.0/mcp_vcr.egg-info/PKG-INFO +12 -0
- mcp_vcr-0.1.0/mcp_vcr.egg-info/SOURCES.txt +36 -0
- mcp_vcr-0.1.0/mcp_vcr.egg-info/dependency_links.txt +1 -0
- mcp_vcr-0.1.0/mcp_vcr.egg-info/entry_points.txt +2 -0
- mcp_vcr-0.1.0/mcp_vcr.egg-info/requires.txt +4 -0
- mcp_vcr-0.1.0/mcp_vcr.egg-info/top_level.txt +1 -0
- mcp_vcr-0.1.0/pyproject.toml +38 -0
- mcp_vcr-0.1.0/setup.cfg +4 -0
- mcp_vcr-0.1.0/tests/test_cli_polish.py +215 -0
- mcp_vcr-0.1.0/tests/test_cli_validate.py +111 -0
- mcp_vcr-0.1.0/tests/test_compatibility.py +153 -0
- mcp_vcr-0.1.0/tests/test_diff.py +336 -0
- mcp_vcr-0.1.0/tests/test_interceptor.py +132 -0
- mcp_vcr-0.1.0/tests/test_normalizer.py +280 -0
- mcp_vcr-0.1.0/tests/test_recorder.py +155 -0
- mcp_vcr-0.1.0/tests/test_redactor.py +151 -0
- mcp_vcr-0.1.0/tests/test_redactor_integration.py +73 -0
- mcp_vcr-0.1.0/tests/test_replay.py +397 -0
- mcp_vcr-0.1.0/tests/test_schema.py +82 -0
- mcp_vcr-0.1.0/tests/test_snapshot.py +293 -0
- mcp_vcr-0.1.0/tests/test_transport.py +327 -0
- mcp_vcr-0.1.0/tests/test_validator.py +35 -0
mcp_vcr-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mcp-vcr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mcp_vcr-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-vcr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A deterministic, replayable, human-readable MCP transcript format and proxy.
|
|
5
|
+
Author: mcp-vcr contributors
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: pydantic>=2.0.0
|
|
9
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
10
|
+
Requires-Dist: click>=8.1.0
|
|
11
|
+
Requires-Dist: jsonschema>=4.20.0
|
|
12
|
+
Dynamic: license-file
|
mcp_vcr-0.1.0/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# MCP-VCR 📼
|
|
2
|
+
|
|
3
|
+
**Record and replay stdio MCP server conversations. Catch regressions in CI before your users do.**
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Record a live session from any client
|
|
7
|
+
mcp-vcr record -- python my_server.py
|
|
8
|
+
|
|
9
|
+
# Create a normalized golden snapshot
|
|
10
|
+
mcp-vcr snapshot sessions/voice_session.yaml
|
|
11
|
+
|
|
12
|
+
# Verify your current code against all snapshots
|
|
13
|
+
mcp-vcr verify snapshots/ -- python server.py
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What is MCP-VCR?
|
|
19
|
+
|
|
20
|
+
`mcp-vcr` is a transparent, developer-first stdio proxy and regression testing framework for [Model Context Protocol (MCP)](https://modelcontextprotocol.org) servers.
|
|
21
|
+
|
|
22
|
+
It sits cleanly between an MCP client (such as Claude Desktop, Cursor, Windsurf, or MCP Inspector) and your server, records every JSON-RPC 2.0 exchange in both directions, and saves them as highly human-readable, git-diffable YAML transcripts.
|
|
23
|
+
|
|
24
|
+
### Key Capabilities
|
|
25
|
+
|
|
26
|
+
* **Deterministic Replay**: Replay recorded client commands against your server and automatically match responses by JSON-RPC `id` values.
|
|
27
|
+
* **Golden Snapshots**: Strips out non-deterministic noise (timestamps, UUIDs, request/response IDs, page cursors, local paths) to form a reproducible, byte-identical contract test suite.
|
|
28
|
+
* **In-Flight Redaction**: Walks message payloads recursively to scrub credentials, OpenAI keys, bearer tokens, passwords, and absolute user directory paths *before* writing transcripts to your disk.
|
|
29
|
+
* **Layered Diff Engines**: Spot structural schema drift, type changes, or value regressions using `--structural`, `--semantic`, or `--strict` diffing options.
|
|
30
|
+
* **CI-Native Checking**: Verify your whole server against dozens of snapshots with a single command; exits with code `0` on success or code `1` on regression.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## The Problems It Solves
|
|
35
|
+
|
|
36
|
+
| Developer Pain | How `mcp-vcr` Fixes It |
|
|
37
|
+
| :--- | :--- |
|
|
38
|
+
| **Flaky CI Pipelines** | Golden snapshots normalize IDs, UUIDs, and timestamps, preventing false negatives. |
|
|
39
|
+
| **Invisible Stdio Streams** | Intercepts, structures, and logs bidirectional traffic with relative millisecond offsets. |
|
|
40
|
+
| **Hard-to-Reproduce Bugs** | Capture a failing sequence from Claude Desktop and replay it locally in one command. |
|
|
41
|
+
| **Silent API Schema Drift** | Strict structural diffs flag added/removed tools, arguments, or changed types immediately. |
|
|
42
|
+
| **Credential Leaks in Git** | Built-in redaction keeps secrets and private absolute filesystem paths out of your codebase. |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
Install `mcp-vcr` inside your virtual environment using poetry or pip:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Using poetry (recommended)
|
|
52
|
+
poetry add mcp-vcr
|
|
53
|
+
|
|
54
|
+
# Or using pip
|
|
55
|
+
pip install mcp-vcr
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
*Requires Python 3.10+. Zero databases, heavy external services, or cloud setups required.*
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Quickstart Guide
|
|
63
|
+
|
|
64
|
+
### 1. Record a Live Session
|
|
65
|
+
Run your server through the record proxy. Any standard stdio client interacting with this pipe will be recorded:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mcp-vcr record --name init_tools_list -- python my_server.py
|
|
69
|
+
```
|
|
70
|
+
This produces an auto-redacted transcript inside the default `sessions/` directory (which you should add to `.gitignore`).
|
|
71
|
+
|
|
72
|
+
### 2. Create a Golden Snapshot
|
|
73
|
+
Turn a raw recorded session into a normalized, stable regression baseline:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
mcp-vcr snapshot sessions/session_20260518_init_tools_list.yaml
|
|
77
|
+
```
|
|
78
|
+
This creates a golden snapshot file under the `snapshots/` directory: `snapshots/init_tools_list_golden.yaml`. **Commit this folder to your Git repository.**
|
|
79
|
+
|
|
80
|
+
### 3. Verify for Regressions in CI
|
|
81
|
+
Run the verification command. It replays client traffic from all golden snapshots against your live server code:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
mcp-vcr verify snapshots/ -- python my_server.py
|
|
85
|
+
```
|
|
86
|
+
* **Exit code `0`**: All responses match their golden snapshots perfectly.
|
|
87
|
+
* **Exit code `1`**: Regressions or schema mismatches detected. Prints a readable diff to stderr.
|
|
88
|
+
|
|
89
|
+
### 4. Overwrite Goldens After Intentional Schema Changes
|
|
90
|
+
If you intentionally add a new tool or change response formatting, update your golden snapshots using the `--update` flag:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
mcp-vcr verify --update snapshots/ -- python my_server.py
|
|
94
|
+
```
|
|
95
|
+
Review the changes using `git diff snapshots/` before committing.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Claude Desktop Configuration
|
|
100
|
+
|
|
101
|
+
To capture real interactions from the Claude Desktop app, add `mcp-vcr` as your server launcher inside `claude_desktop_config.json`:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"my-server": {
|
|
107
|
+
"command": "mcp-vcr",
|
|
108
|
+
"args": [
|
|
109
|
+
"record",
|
|
110
|
+
"--name",
|
|
111
|
+
"desktop_session",
|
|
112
|
+
"--",
|
|
113
|
+
"python",
|
|
114
|
+
"/absolute/path/to/my_server.py"
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
> [!NOTE]
|
|
122
|
+
> The `--` separator is required to clearly segregate MCP-VCR command-line flags from the command used to launch your actual server process.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Redaction & Security
|
|
127
|
+
|
|
128
|
+
`mcp-vcr` walks JSON-RPC message payloads recursively to redact known secret keys, environment paths, and pattern matches *before* writing transcripts. The client and server receive the raw streams intact; only the stored file is sanitized.
|
|
129
|
+
|
|
130
|
+
* **Field Rules**: Fields matching `api_key`, `token`, `secret`, `password`, `credential`, or `authorization` are replaced with `<REDACTED_fieldname>`.
|
|
131
|
+
* **Pattern Rules**: Regex strings (e.g., Bearer tokens, AWS keys, OpenAI `sk-` keys) are scrubbed.
|
|
132
|
+
* **Path Rules**: Absolute filesystem paths (e.g., `/home/username/...`) are replaced with `<PATH>`.
|
|
133
|
+
|
|
134
|
+
Configure custom rules in your project's `.mcp-vcr.yaml` file:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
redact:
|
|
138
|
+
fields:
|
|
139
|
+
- secret_config_token
|
|
140
|
+
patterns:
|
|
141
|
+
- "custom-auth-[a-zA-Z0-9]{16}"
|
|
142
|
+
paths: true
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## What Lies Ahead (Roadmap)
|
|
148
|
+
|
|
149
|
+
We are laser-focused on keeping our **versioned, deterministic transcript core** stable and backward-compatible. The following major capabilities are scheduled for implementation:
|
|
150
|
+
|
|
151
|
+
### 1. Timing-Faithful Replay
|
|
152
|
+
Optionally use the recorded `t` relative millisecond values from the transcript to insert deterministic `asyncio.sleep` pauses between client-to-server (`c2s`) messages. Crucial for verifying servers with timeout-sensitive states.
|
|
153
|
+
|
|
154
|
+
### 2. Fuzz Testing Mode
|
|
155
|
+
Add `mcp-vcr fuzz` to replay recorded snapshots with randomized mutations (truncated payloads, type confusion, missing required schema fields, and boundary values) to audit server error handling and crash resistance.
|
|
156
|
+
|
|
157
|
+
### 3. MCP Inspector Integration
|
|
158
|
+
Coordinating with the MCP community to support loading `mcp-vcr` transcripts directly into the official MCP Inspector web interface for timeline visualization, message inspection, and interactive debugging.
|
|
159
|
+
|
|
160
|
+
### 4. Compatibility Matrix Report
|
|
161
|
+
Record and diff identical session exchanges across major MCP client runtimes (Claude Desktop, Cursor, Windsurf, etc.) to generate a public compatibility matrix, letting authors prove their servers work flawlessly across the client ecosystem.
|
|
162
|
+
|
|
163
|
+
### 5. HTTP/SSE Recording
|
|
164
|
+
Extending the stdio proxy architecture to support recording and replaying **HTTP/Server-Sent Events (SSE)**, the second official MCP transport layer.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Design Principles
|
|
169
|
+
|
|
170
|
+
* **Local-First & Offline**: Zero telemetry, zero external database integrations, and zero mandatory cloud services. Your tests run fast and offline.
|
|
171
|
+
* **Protocol-Transparent**: The proxy acts as a silent observer. It never intercepts, manipulates, or alters protocol-level capability negotiations between the client and server.
|
|
172
|
+
* **Git-Friendly Transcripts**: Structured YAML outputs with stable key ordering, deterministic naming, and deep secret scrubbing are designed to be checked in alongside your code.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Developer Resources
|
|
177
|
+
|
|
178
|
+
* [Developer Getting Started Guide](docs/getting-started.md) (onboarding in under 10 minutes)
|
|
179
|
+
* [CI/CD Pipeline Integration Guide](docs/ci-integration.md) (setup for GitHub Actions & GitLab CI/CD)
|
|
180
|
+
* [Internal Architecture & Design Internals](Architecture.md) (deep-dive on proxy buffers and the normalization pipeline)
|
|
181
|
+
* [Pytest Integration Guide](docs/pytest-integration.md)
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from .schema import Transcript, Message, Metadata, Direction
|
|
2
|
+
from .validator import validate_file, validate_transcript
|
|
3
|
+
from .interceptor import MessageInterceptor
|
|
4
|
+
from .redactor import Redactor
|
|
5
|
+
from .normalizer import (
|
|
6
|
+
Normalizer,
|
|
7
|
+
NormalizerChain,
|
|
8
|
+
TimestampNormalizer,
|
|
9
|
+
RequestIdNormalizer,
|
|
10
|
+
UuidNormalizer,
|
|
11
|
+
CursorNormalizer
|
|
12
|
+
)
|
|
13
|
+
from .transport import (
|
|
14
|
+
get_stdin_reader,
|
|
15
|
+
launch_server,
|
|
16
|
+
pump_c2s,
|
|
17
|
+
pump_s2c,
|
|
18
|
+
pump_stderr,
|
|
19
|
+
run_proxy
|
|
20
|
+
)
|
|
21
|
+
from .replay import ReplayEngine
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"Transcript",
|
|
25
|
+
"Message",
|
|
26
|
+
"Metadata",
|
|
27
|
+
"Direction",
|
|
28
|
+
"validate_file",
|
|
29
|
+
"validate_transcript",
|
|
30
|
+
"MessageInterceptor",
|
|
31
|
+
"Redactor",
|
|
32
|
+
"Normalizer",
|
|
33
|
+
"NormalizerChain",
|
|
34
|
+
"TimestampNormalizer",
|
|
35
|
+
"RequestIdNormalizer",
|
|
36
|
+
"UuidNormalizer",
|
|
37
|
+
"CursorNormalizer",
|
|
38
|
+
"get_stdin_reader",
|
|
39
|
+
"launch_server",
|
|
40
|
+
"pump_c2s",
|
|
41
|
+
"pump_s2c",
|
|
42
|
+
"pump_stderr",
|
|
43
|
+
"run_proxy",
|
|
44
|
+
"ReplayEngine",
|
|
45
|
+
]
|
|
46
|
+
|