A minimal MCP server demonstrating mcp-contracts — the GitHub Action for schema diffing and the @mcp-contracts/test library for contract testing.
This repo has a simple MCP server (server.js) with a baseline contract snapshot in contracts/baseline.mcpc.json. Two CI workflows run on pull requests:
Schema Diff (GitHub Action) — automatically:
- Captures the current MCP tool schemas from the server
- Diffs them against the baseline snapshot
- Posts a PR comment with the diff report
- Fails the check if breaking changes are detected
Contract Tests (@mcp-contracts/test) — automatically:
- Verifies server schemas conform to the contract
- Tests boundary inputs (empty strings, zero values, oversized payloads)
- Runs behavioral assertions on tool outputs
- Fork this repo
- Create a branch and modify
server.js(e.g., add a required parameter to a tool, or remove a tool) - Open a pull request
- Watch the MCP Contract Check workflow run and report changes
npm install
npm startThe server communicates over stdio using the MCP protocol.
npm run start:http
# or with a custom port:
node server.js --http 8080The server listens on http://localhost:3000/mcp (default port 3000) using MCP Streamable HTTP transport.
You can then diff against it with the CLI:
npx mcpdiff diff --live contracts/baseline.mcpc.json --url http://localhost:3000/mcpRun contract conformance tests with:
npm testThis runs contract.test.js which uses @mcp-contracts/test to:
- Verify all tool schemas match the contract
- Send boundary inputs (empty strings, zero values, etc.) and verify graceful handling
- Run behavioral assertions on tool outputs
You can also run the CLI directly:
npx mcp-test run contracts/baseline.mcpc.json --command "node server.js"