Diff MCP server tool schemas against a baseline contract. Detects breaking changes, warnings, and safe additions in your MCP server's API surface.
name: MCP Contract Check
on:
pull_request:
paths:
- "src/**"
- "package.json"
jobs:
contract-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- run: npm install
- name: Check MCP contract
uses: mcp-contracts/github-action@main
with:
baseline: contracts/baseline.mcpc.json
command: node
args: dist/index.js
fail-on: breaking| Input | Required | Default | Description |
|---|---|---|---|
baseline |
Yes | Path to baseline snapshot (.mcpc.json) |
|
command |
No* | Server command to run via stdio (e.g., node dist/index.js) |
|
args |
No | Arguments for the server command (space-separated) | |
url |
No* | Server URL for streamable-http transport | |
fail-on |
No | breaking |
Severity threshold for failure: safe, warning, breaking |
comment-on-pr |
No | true |
Post diff as a PR comment |
github-token |
No | github.token |
GitHub token for PR comments |
* Either command or url is required.
| Output | Description |
|---|---|
has-changes |
Whether any changes were detected (true/false) |
has-breaking |
Whether breaking changes were detected |
summary |
JSON summary object with change counts |
exit-code |
0 = pass, 1 = fail |
- Reads the baseline snapshot from the file path you provide
- Connects to your MCP server (via stdio command or HTTP URL)
- Captures the current tool/resource/prompt schemas
- Diffs the current state against the baseline
- Reports changes as a step summary and optional PR comment
- Fails the check if changes meet the
fail-onseverity threshold
Use the mcpdiff CLI to capture a baseline snapshot:
npx mcpdiff snapshot --command node --args server.js -o contracts/baseline.mcpc.jsonCommit this file to your repository and reference it in the baseline input.