Metadata-Version: 2.5
Name: mcp-proxy-inspect
Version: 0.1.0
Summary: DevTools for MCP servers: a transparent stdio proxy with a live web dashboard, schema-driven conformance tests, fault injection, and record/replay/mock for CI.
Project-URL: Homepage, https://github.com/rampangeni/mcp-proxy-inspect
Project-URL: Issues, https://github.com/rampangeni/mcp-proxy-inspect/issues
Author: Ram Pangeni
License: MIT
License-File: LICENSE
Keywords: debugging,devtools,inspector,mcp,model-context-protocol,proxy,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# mcp-proxy-inspect

**DevTools for MCP servers.** Put it between your MCP client and a stdio server: see every message live in a browser,
record sessions, replay them as a mock, run conformance checks, and break things on purpose with fault injection.

![mcp-proxy-inspect demo on the official "everything" server](docs/demo.gif)

<sub>Demo recorded against `@modelcontextprotocol/server-everything`.</sub>

Zero dependencies, pure Python 3.10+. The web UI is local-only (127.0.0.1) and ships inside the package.

```bash
pip install mcp-proxy-inspect
```

## 1. Watch a server live

Replace the server command in your client's MCP config with `mcp-proxy-inspect run -- <original command>`:

```json
{ "mcpServers": { "files": {
    "command": "mcp-proxy-inspect",
    "args": ["run", "--open", "--", "npx", "-y", "@modelcontextprotocol/server-filesystem", "/tmp"] } } }
```

A timeline with a latency waterfall, request/response pairing, a tool schema browser, a latency histogram and an
**Issues** tab (invalid JSON on stdout, wrong `jsonrpc`, unknown or duplicate ids, requests that never got a response,
malformed error objects…). Traffic is forwarded byte for byte; the proxy never prints to stdout.
Every session is also recorded to `mcp-sessions/<time>.mcp.jsonl`.

### Call the server yourself (interactive client)

The **Send** tab is a DevTools-style request console: pick a method, pick a tool, fill in a form generated from its
input schema (or edit the raw JSON), and send. In the Timeline, any request has **Edit & resend**; in Tools, each tool has
**Try it**. Responses show inline and in the Timeline (tagged `sent`).

```bash
mcp-proxy-inspect play -- python my_server.py          # no client needed: mcp-proxy-inspect initializes the connection for you
mcp-proxy-inspect play --url https://example.com/mcp --header "Authorization: Bearer $TOKEN"
```

Inside `mcp-proxy-inspect run` the same tab sends requests next to your real client's traffic (ids are prefixed
`mcp-proxy-inspect-`, and the answers are never forwarded to the client); use `--read-only` to turn that off. The send endpoint
is protected by a per-run secret token, loopback-only Host/Origin checks and a JSON content type, so other web pages
cannot make your browser call your tools. Calls are real: they can have side effects like any client call.
Faults only apply to your client's traffic, not to requests sent from the UI.

### Remote servers (streamable HTTP)

```bash
mcp-proxy-inspect run --url https://example.com/mcp --open     # then point your client at http://127.0.0.1:8765/mcp
mcp-proxy-inspect test --url https://example.com/mcp --header "Authorization: Bearer $TOKEN"
```

The proxy forwards requests unchanged (JSON and SSE responses, session ids, auth headers) and records the JSON-RPC
messages. HTTP headers are forwarded but **never recorded**. `--fault`, `--redact`, the UI and `test` all work the same
as with stdio. The proxy only accepts loopback `Host`/`Origin` headers.

## 2. Test a server

```bash
mcp-proxy-inspect test -- python my_server.py                  # protocol checks only (safe)
mcp-proxy-inspect test --call-tools --probe-invalid -- python my_server.py
mcp-proxy-inspect test --json --junit report.xml -- python my_server.py   # CI-friendly, exit code 1 on failure
```

Checks `initialize` shape, `ping`, unknown-method errors, `tools/list` (pagination, unique names, object schemas),
clean stdout and clean shutdown. With the opt-in flags it also calls every tool with arguments **derived from its
JSON Schema** and with deliberately invalid ones, and expects a proper error.

> **Warning:** `--call-tools` and `--probe-invalid` really call your tools. Only use them on servers (or
> sandboxes) where that is safe. Without them, no tool is ever invoked.

## 3. Break it on purpose

```bash
mcp-proxy-inspect run --fault "tools/call:tool=search,delay=2000" \
                --fault "tools/call:error=-32000,message=upstream down,rate=0.3" --fault-seed 7 -- python server.py
```

Delay, error, or drop responses by method glob and tool name, optionally at a given rate. Nothing is altered unless
you pass `--fault`; faulted messages are flagged in the UI and the original server answer is kept next to them.

## 4. Catch regressions between versions

Record a session once (a golden recording), then check every new version of your server against it:

```bash
mcp-proxy-inspect replay golden.mcp.jsonl -- python my_server.py             # exit 1 on breaking changes
mcp-proxy-inspect replay golden.mcp.jsonl --format markdown -- python my_server.py >> "$GITHUB_STEP_SUMMARY"
mcp-proxy-inspect diff old.mcp.jsonl new.mcp.jsonl --ignore timestamp         # compare two recordings
```

Output separates **breaking** changes (removed tools, new required arguments, changed argument types, changed or failing
responses) from informational ones (new tools, descriptions, slower p95). `serverInfo.version` is ignored by default; add
`--ignore KEY` (a key name or a dotted path) for volatile fields. `replay` skips `tools/call` unless you pass
`--call-tools`, because calling tools can have side effects.

```yaml
# .github/workflows/mcp-regression.yml (excerpt)
- run: pip install mcp-proxy-inspect
- run: mcp-proxy-inspect replay tests/golden.mcp.jsonl --call-tools --format markdown -- python server.py >> "$GITHUB_STEP_SUMMARY"
```

## 5. Record, replay, share

```bash
mcp-proxy-inspect mock session.mcp.jsonl            # serve the recorded responses over stdio (offline client dev)
mcp-proxy-inspect inspect session.mcp.jsonl         # open a recording in the UI   (--text for a terminal summary)
mcp-proxy-inspect export session.mcp.jsonl --redact -o session.html   # one self-contained HTML file
```

`--redact` masks secrets by key name (`token`, `api_key`, `password`…) and by pattern (Bearer tokens, `sk-…`, GitHub,
AWS, Slack tokens, JWTs, private keys) in the recording and export. It never alters live traffic.

## How it compares

Recorders such as mcpsnoop, agent-vcr and mcp-recorder cover capture and replay. This project adds a DevTools-style
browser UI, schema-driven conformance tests and fault injection in one zero-dependency tool.

## Limits (v0.1)

stdio and streamable HTTP only (the legacy 2024-11-05 HTTP+SSE transport is not supported); the proxy does not terminate TLS for clients (it speaks plain HTTP on 127.0.0.1 and TLS to the upstream); the playground does not answer requests the server sends back (sampling, roots); `mock` matches by method + params, no stateful scenarios.

MIT licensed.
