Skip to content

[Schema] Always emit {} for empty tool schema properties - #407

Open
BrocksiNet wants to merge 1 commit into
modelcontextprotocol:mainfrom
BrocksiNet:fix/405-normalize-empty-tool-schema-properties
Open

[Schema] Always emit {} for empty tool schema properties#407
BrocksiNet wants to merge 1 commit into
modelcontextprotocol:mainfrom
BrocksiNet:fix/405-normalize-empty-tool-schema-properties

Conversation

@BrocksiNet

Copy link
Copy Markdown

Summary

  • Move empty-properties normalization into Tool::__construct() so every construction path (not only fromArray / SchemaGenerator) emits JSON Schema objects as {} instead of [].
  • Make the walk recursive across nested property schemas, items, additionalProperties, and combinators, and apply it to outputSchema as well.
  • Add unit coverage for direct construction, json_decode round-trips, nested objects, array item schemas, and empty outputSchema.properties.

Fixes #405

Test plan

  • make unit-tests (834 tests)
  • make phpstan
  • make cs
  • make inspector-tests (95 tests, 7 skipped)
  • composer validate --strict
  • Confirm a parameterless tool serializes "properties":{} in tools/list against a strict client (e.g. OpenAI-compatible)

Normalize empty properties arrays (including nested object schemas and
outputSchema) in Tool::__construct so tools/list never serializes
invalid JSON Schema properties: [].

Fixes modelcontextprotocol#405
@chr-hertel chr-hertel added the bug Something isn't working label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool serializes empty inputSchema.properties as [] instead of {}

2 participants