Repository navigation
Conversation
Match the OpenAPI jsonSchemaDialect and the official MCP server.json schema by emitting https://json-schema.org/draft/2020-12/schema from the extractor and regenerating the draft artifact. Fixes modelcontextprotocol#842
JosephDoUrden
left a comment
There was a problem hiding this comment.
Applied this on current main (edd9fa7): make check-schema exits 0, make validate passes every example, go test ./internal/validators/... is green, and the two one-line hunks do not touch the lines #1364 and #1404 change. The runtime is unaffected today because schema.go:196 only compiles the embedded internal/validators/schemas/*.json, which are all still draft-07.
One thing changes silently. jsonschema v5.3.1 only enforces format for 2019-09 and later when AssertFormat is set (compiler.go:666); under draft-07 it is on by default. The compiler.Draft = Draft7 in tools/validate-*/main.go is only the fallback for a missing $schema, so once this file says 2020-12 the five format: uri fields stop being checked. I probed it with a document carrying repository.url: "::bad": the main schema rejects it, the PR schema accepts it, with and without the Draft7 fallback. That reaches publish-time validation the moment the next version is synced into the embedded set.
The fix is small: AssertFormat = true on the three compilers. With that in, this closes #842.
Not tested: a full 2020-12 vocabulary audit beyond definitions refs, items, dependencies and $id, which all look fine here.
Summary
The generated
server.schema.jsonstill advertised JSON Schema draft-07 while OpenAPI already setsjsonSchemaDialectto 2020-12. This updates the extractor and regenerates the draft artifact to match.Approach
https://json-schema.org/draft/2020-12/schemafromtools/extract-server-schemadocs/reference/server-json/draft/server.schema.jsonTest plan
make generate-schemamake check-schemaFixes #842