Install: pip install mcp-testbench |
PyPI: pypi.org/project/mcp-testbench
GitHub Action
The mcp-testbench repository is itself a GitHub Action:
name: mcp-testbench
on: [pull_request]
jobs:
mcp-contract:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint the MCP server schema
uses: mcp-testbench/mcp-testbench@v1
with:
mode: lint # check | lint | replay | snapshot
server-command: "python my_server.py"
- name: Fail on breaking schema changes
uses: mcp-testbench/mcp-testbench@v1
with:
mode: check
server-command: "python my_server.py"
snapshot-path: mcp-snapshot.json
Inputs: server-command or url (exactly one),
mode, snapshot-path, calls-file,
python-version, mcp-testbench-version, and
fail-on -- breaking (check mode),
errors / warnings (lint mode),
failures (replay mode), or never for report-only
runs. The action installs mcp-testbench from PyPI, so there is nothing else
to vendor.
pre-commit / prek hooks
The hooks test a live server (not files), so the server command is passed
through args in your config:
# .pre-commit-config.yaml
repos:
- repo: https://github.com/mcp-testbench/mcp-testbench
rev: v0.4.0
hooks:
- id: mcp-testbench-lint
args: [--, python, my_server.py]
- id: mcp-testbench-check
args: [mcp-snapshot.json, --, python, my_server.py]
prek reads the same hook definitions and config format -- no separate prek setup.
Exit codes are the gate
| Command | Exit 0 | Exit 1 | Exit 2 |
|---|---|---|---|
check / diff | no breaking changes | breaking change found | protocol / IO error |
lint | no errors (warnings allowed) | lint errors, or any finding with --strict | protocol / IO error |
replay | all calls passed | at least one call failed | protocol / IO error |
snapshot / inspect | success | -- | protocol / IO error |
Any CI system that can run a shell command can gate on these -- the GitHub Action and hooks are conveniences, not requirements.
Badge
[](https://pypi.org/project/mcp-testbench/)