Repository navigation
[Server] Fix result lists being sent as JSON objects - #656
Merged
chr-hertel merged 1 commit intoNov 2, 2026
Merged
chr-hertel merged 1 commit into
chr-hertel merged 1 commit into
Conversation
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
November 2, 2026 22:04
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the resource-read serialization changes.
No open issues 🎉
What changed in this PR
Fixes resource-read serialization in the PHP MCP SDK so non-list arrays produce JSON arrays and repeated named keys in nested mixed results no longer cause content loss.
Changes:
- Reindexes
contentsduring serialization and appends nested resource contents in order. - Adds regression coverage for non-list keys and updates nested-result assertions.
- Corrects the serialization return annotation, removes its PHPStan baseline entry, and documents the fixes.
| File | Description |
|---|---|
tests/Unit/Schema/Result/ReadResourceResultTest.php |
Tests list serialization for named and sparse numeric keys. |
tests/Unit/Capability/Formatter/ResourceResultFormatterTest.php |
Verifies flattening preserves all contents and their order. |
src/Schema/Result/ReadResourceResult.php |
Reindexes serialized contents and corrects the return annotation. |
src/Capability/Formatter/ResourceResultFormatter.php |
Appends nested contents without replacing matching named keys. |
phpstan-baseline.neon |
Removes the resolved return-type suppression. |
CHANGELOG.md |
Documents both resource-read fixes. |
Review effort: Balanced
Non-list handler results of tools, prompts and resources now serialize as an array, and named keys in mixed results no longer overwrite each other.
chr-hertel
force-pushed
the
fix/read-resource-contents-list
branch
from
November 2, 2026 22:14
3a33dd8 to
8082a5d
Compare
contents of a resource read being sent as a JSON object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spotted while reviewing #650 & #651, but not caused by them.
array_filter(), sentcontent,messagesorcontentsas a JSON object instead of an array - now re-indexed injsonSerialize(), like the other list results