contract-first-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@contract-first-mcp Check backward compatibility of my updated 'get_user' tool schema."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
contract-first-mcp
A reference MCP server that treats tool schemas as data contracts — versioned, tested for backward compatibility in CI, and hash-pinned against rug pulls.
Built for the MCP 2026-07-28 era: stateless core, explicit handles instead of
protocol sessions, and a formal deprecation discipline borrowed from
event-driven-architecture schema governance.
Why
MCP servers today evolve their tools the way early Kafka producers evolved their events: silently. A tool renames a field, a client's prompt cache goes stale, an agent starts failing mid-plan — and there is no registry, no compat check, no changelog. This repo shows the minimum viable governance layer:
Discipline | Where |
Contract-as-repository: one JSON Schema file per tool version |
|
Additive-only evolution, enforced — including the tightenings that remove nothing and still break clients |
|
Rug-pull detection: canonical SHA-256 of every contract, pinned |
|
Stateless state: HMAC-signed handles the model threads between tools |
|
Fail-fast boot: server refuses to start if a version chain breaks compatibility |
|
Human-readable evolution history |
|
Related MCP server: Schema Drift Gate MCP
Run
pip install "mcp>=2.0" jsonschema
python -m contract_first_mcp.server # stdioClaude Desktop / any MCP client config:
{ "mcpServers": { "contract-first": {
"command": "python", "args": ["-m", "contract_first_mcp.server"],
"env": { "PYTHONPATH": "src", "HANDLE_KEY": "<inject-from-secret-manager>" } } } }What "additive-only" actually means here
The obvious rules — no removals, no type changes, no new required fields, no
enum removals — miss a whole family of breaking changes, because they look for
things that disappear. Lowering maximum from 12 to 6 removes nothing, renames
nothing, and rejects a payload that worked yesterday. So the checker also fails
a version that:
raises a lower bound or lowers an upper bound (
minimum,maxLength,maxItems, and the rest), including introducing a bound where there was none — unbounded is the loosest bound there is;adds or changes
patternormultipleOf;introduces an
enumon a field that was previously open;closes
additionalProperties;narrows a type (widening
stringto["string", "number"]stays legal);does any of the above inside a nested object or an array's items.
The asymmetry is the whole rule: dropping a constraint is always safe, adding one never is. Each case above has a test that first proves the payload really stops validating, then demands the checker catch it — because a compatibility checker nobody adversarially tested is a comment, not a gate.
Evolving a tool
Copy
contracts/<tool>/vN.jsontov(N+1).jsonand make additive changes only (new optional fields, new enum values).pytest— the compat chain test tells you immediately if the change is breaking.Regenerate the lockfile:
python -c "import sys; sys.path.insert(0,'src'); from contract_first_mcp import registry; \ import json,pathlib; pathlib.Path('pinned_tools.lock.json').write_text(\ json.dumps(registry.build_lock(registry.load_contracts()), indent=2)+'\n')"Record the change in
TOOL_CHANGELOG.md.Breaking change needed? Don't mutate — publish a new tool name (
convert_units_v2as a separate tool), deprecate the old one in its description, and remove it no earlier than the spec's own bar: 12 months.
Security posture
See SECURITY.md. Short version: every input is validated against its schema before touching logic, handles are signed and verifiable, contract hashes are auditable by the client, and nothing in a tool result should ever be treated as instructions.
License
MIT
Available Tools
4 toolsconvert_unitsB
Convert between km/mi, kg/lb and °C/°F. Contract: contracts/convert_units (latest: v2).
Inputs: value (required), to_unit (required), from_unit (required), precision.
create_workspace_handleB
Mint an explicit, signed handle for cross-call state (replaces protocol sessions).
The model passes the handle back to other tools as an argument. It is visible in the conversation on purpose: auditable state beats hidden state.
Inputs: name (required).
list_contractsA
Introspection: every tool contract version and its pinned SHA-256.
Inputs: no named parameters.
verify_workspace_handleA
Check that a handle was minted by this server and was not tampered with.
Inputs: handle (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a clearly distinct role: contract introspection, unit conversion, handle creation, and handle verification. Even the two handle tools are complementary rather than overlapping, with create vs verify being unambiguous.
All tool names follow a consistent verb_noun snake_case pattern: list_contracts, convert_units, create_workspace_handle, verify_workspace_handle. This makes the set predictable and easy for an agent to navigate.
Four tools is a well-scoped size for a focused server: one meta/introspection tool, one utility tool, and a small handle lifecycle pair. No tool feels redundant or out of place.
The main gap is that workspace handles can be created and verified but not explicitly revoked or expired. For the stated contract-first scope, this is a minor workaround rather than a critical missing capability.
Maintenance
Related MCP Connectors
Free MCP contract auditing for AI agents and developers. Check tool schemas, detect potential breaking changes between versions, and get structured compatibility findings before deployment. Static analysis only.
Monitor MCP servers, API contracts and AI outputs for schema drift. Alerts on breaking changes.
MCP tools: collectible price-fairness, recall safety, drop tracking, card grading, settlements.
One MCP URL for all your connectors — scoped writes, enforced constraints, and a full audit trail.
Related MCP Servers
- FlicenseAqualityNot gradedmaintenanceStatic analysis engine that detects schema mismatches between data producers (like MCP servers) and consumers (like client code), preventing runtime errors by validating contracts at development time.11-
- FlicenseNot gradedqualityDmaintenancePaid remote MCP server that blocks breaking tool-schema changes by verifying schema drift, requiring approvals, and providing compatibility receipts and audit logs.-
- AlicenseNot gradedqualityCmaintenanceAn MCP server that exposes nine local-first contract-ops CLIs as tools for contract extraction, linting, comparison, conversion, template vaults, and signed-contract vaults, with signing operations strictly human-gated.86 npmMIT
- AlicenseBqualityBmaintenanceContributors: dengyier & Tim Shing(成孝添) Check what an AI agent was authorized to do and what its signed evidence supports. Includes reference SOC alert review and a separately enabled Codex preview-directory Guard; installing MCP does not activate Guard.3231 PyPI261Apache 2.0