DEV Community

GERALD MUDDLETHWACK
GERALD MUDDLETHWACK

Posted on

Would your MCP contract checker flag a harmless JSON change?

A calendar tool still describes itself as “Read-only.” Yesterday a caller could list events by sending from and to. Today the same call fails schema validation. What changed?

In RugSnare’s schema-drift fixture, list_events acquired a required session object. Its description stayed the same. In the same fixture, update_event narrowed the allowed values for mode from ["read", "write"] to ["read"]. A caller sending "write" now fails validation too. A checker that watches only tool names and descriptions misses both changes.

The second fixture makes a different kind of edit. The keys in the definitions of create_note and search_notes move around, including inside their input schemas. A byte comparison reports a change. Parsing the JSON and comparing the tool definitions gives equality.

Try both pairs

Download and extract the archive from Zenodo. From the extracted directory, run this Python snippet. It reads the four snapshots locally.

import json
from pathlib import Path

def read_tools(pair, version):
    path = Path(f"{pair}-{version}.json")
    return json.loads(path.read_text())["result"]["tools"]

for pair in ("02-schema-drift", "05-key-reorder"):
    before = read_tools(pair, "v1")
    after = read_tools(pair, "v2")
    print(pair, "unchanged" if before == after else "changed")
Enter fullscreen mode Exit fullscreen mode

The output is 02-schema-drift changed and 05-key-reorder unchanged. Python compares dictionary contents independently of key order and preserves list order. These fixtures keep the order of the tools themselves fixed.

For a CI check, run both pairs. Ask it to identify the new required field and the removed enum value in the calendar pair, then check whether the notes pair passes quietly. Together they test two failure modes with four files. Detector accuracy in production is a separate measurement.

The versioned dataset includes SHA-256 checksums and source revisions. RugSnare on GitHub.

Disclosure: This article was drafted with AI assistance. The examples and expected output were checked against the published dataset.

Top comments (0)