-
Notifications
You must be signed in to change notification settings - Fork 711
Description
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
- Define a simple schema without
additionalProperties, for example:{ "type": "object" } - Return a
Mapresult with amessagekey instructuredContent. - 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