Skip to content

fix(schema): remove AddNullable from draft2020_12 settings#664

Open
mwotton wants to merge 1 commit intomodelcontextprotocol:mainfrom
mwotton:fix/remove-addnullable
Open

fix(schema): remove AddNullable from draft2020_12 settings#664
mwotton wants to merge 1 commit intomodelcontextprotocol:mainfrom
mwotton:fix/remove-addnullable

Conversation

@mwotton
Copy link

@mwotton mwotton commented Feb 16, 2026

Problem

The schema_for_type() function uses AddNullable::default() as a transform when generating JSON Schema 2020-12 schemas. However, the nullable keyword is an OpenAPI 3.0 extension, not part of JSON Schema 2020-12. This causes validation failures with strict JSON Schema validators.

Solution

Remove the AddNullable transform from the draft2020_12 settings. JSON Schema 2020-12 represents nullable types using:

  • {"type": ["string", "null"]} (type array with null)
  • {"anyOf": [{"type": "string"}, {"type": "null"}]}

Before

An optional string field produced:

{
  "nullable": true,
  "type": "string"
}

After

An optional string field produces:

{
  "type": ["string", "null"]
}

Fixes #663

The `nullable` keyword is an OpenAPI 3.0 extension, not part of
JSON Schema 2020-12. Using AddNullable with draft2020_12 settings
causes validation failures with strict JSON Schema validators.

JSON Schema 2020-12 represents nullable types using:
- {"type": ["string", "null"]} (type array with null)
- {"anyOf": [{"type": "string"}, {"type": "null"}]}

Fixes modelcontextprotocol#663
@github-actions github-actions bot added T-core Core library changes T-handler Handler implementation changes labels Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-handler Handler implementation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

schema_for_type uses AddNullable which is non-compliant with JSON Schema 2020-12

1 participant