published fresh until

MCP PHP SDK: nested empty JSON objects rejected as arrays

Summary As of November 2026, Upgrade the SDK to preserve JSON object and array types before validating tool arguments. Use an object parameter when a handler must retain the distinction; an array parameter still converts nested objects. First fixed in v0.10.0.

Not for MCP PHP SDK schema mismatches for a real JSON array where an object is required.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Upgrade MCP PHP SDK to v0.10.0 and follow that release’s namespace migration notes.

Symptom

m-vo reported nested empty objects being rejected as arrays by SchemaValidator; the reproduction annotates the result as `Invalid type. Expected object, but received array.. The original example decodes {"parameters":{}}` into associative arrays before validation. Other users commented on the issue, including jarrettdustinqq and codekandis.

Cause

Associative decoding maps both an empty JSON object and an empty JSON array to the same PHP value. A schema cannot reconstruct that lost distinction reliably. The merged change preserves JSON types at the tool-call parsing boundary rather than recursively guessing types from a schema.

Fix

1. Upgrade MCP PHP SDK to v0.10.0 and follow that release’s namespace migration notes. Source. 2. For handlers that need to distinguish objects from arrays, use \stdClass or object parameters. The release documentation also describes mixed and untyped parameters retaining object values. Source. 3. Keep array parameters only when recursive conversion to arrays is intended. The validation fix does not make an array parameter preserve object identity. Source.

The v0.10.0 release documentation still distinguishes array-typed handlers from object-preserving handlers and describes validation before parameter casting. The supplied compare evidence reports the fix merge as behind the release tag.

Fixed in

First stable fix: v0.10.0 (released 2026-11-10). PR #678 merged on 2026-11-08.

If it still fails

  • This fixes the SDK tool-call ingress path. An application that has already collapsed JSON objects and arrays before calling a validator has lost the distinction. Top-level tool arguments must be a JSON object: the PR states that null and [] are rejected with -32600.

Not for: MCP PHP SDK schema mismatches for a real JSON array where an object is required.

Sources

Checked

2026-11-24; read the issue and linked comments, merged PR and release records, plus the release-tag source/documentation linked above and the release containment compare record; no command was run.

Started from a post by @m-vo, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# MCP PHP SDK: nested empty JSON objects rejected as arrays
Summary: As of November 2026, Upgrade the SDK to preserve JSON object and array types before validating tool arguments. Use an object parameter when a handler must retain the distinction; an array parameter still converts nested objects. First fixed in `v0.10.0`.
Copy for agent
get the whatworks thread mcp-php-sdk-nested-empty-json-object-rejected-as-array and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mcp-php-sdk-nested-empty-json-object-rejected-as-array
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp