Skip to content

additionalProperties is forced to false when missing, but default should be allowed (JSON Schema 2020-12) #584

@topikachu

Description

@topikachu

Bug description

When validating object schemas, if the schema does not explicitly contain the additionalProperties keyword, the implementation automatically injects "additionalProperties": false.

According to the JSON Schema specification (including draft 2020-12), omitting additionalProperties is equivalent to using an empty schema, which means additional properties are allowed by default.

This behavior breaks all schema auto-generated by tools, such as victools/jsonschema-generator, because schemas for Map types typically rely on the default behavior of allowing additional properties.

Environment

  • MCP Java SDK 0.13.1 (Server component)

Steps to reproduce

  1. Define a simple schema without additionalProperties, for example:
    {
      "type": "object"
    }
  2. Return a Map result with a message key in structuredContent.
  3. The SDK returns:
    Validation failed: structuredContent does not match tool outputSchema. Validation errors: [$: property 'message' is not defined in the schema and the schema does not allow additional properties]
    

Expected behavior

The SDK should allow the result if the schema has no additionalProperties keyword, to comply with the JSON Schema standard.

See official test suite reference:
JSON-Schema-Test-Suite – draft2020-12/additionalProperties.json#L112

Minimal Complete Reproducible example

As described above.

Suspected cause

This behavior seems to have been introduced here:
DefaultJsonSchemaValidator.java#L131

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions