[Server] Decode JSON-RPC objects as stdClass, not associative arrays
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Locate the inbound JSON-RPC decoding entry point and trace the internal methods that consume decoded messages. Verify how object and array semantics reach Opis\JsonSchema\Validator, then update the affected paths so object values remain stdClass instances and validation succeeds for object-typed tool parameters.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
The current implementation uses associative array for the decoding the JSON-RPC message. Which will break the Opis\JsonSchema\Validator since it needs the stdClass for a object as described in the docs. Currently the empty array/object ambiguity exists and the validation fails.
Describe the solution you'd like
Preserve JSON object/array semantics on inbound MCP messages and set associative parameter to false. Update all internal methods to work with stdClass objects instead of associative arrays.
json_decode($input, false, JSON_THROW_ON_ERROR)
Additional context
This feature would allow to work with fully validated object structures with #Schema attribute on input parameters in tool calls. Here is an example how a tool call failed and the model confusion about the parameter typing. The tool method is using this signature: McpServer::updateDocument(array $document) So i asked the model why did it fail, this is the answer:
The document parameter type should be object (not array), and the description should clarify the expected root structure:
{
"document": {
"type": "object",
"description": "Complete document (root object with type, name, version properties)",
"properties": {
"type": { "type": "string" },
"name": { "type": "string" },
"version": { "type": "string" },
},
"required": ["type", "name", "version"]
}
}
The key fix: changing "type": "array" to "type": "object" and adding a required array so it's explicit what the root document needs.
- Dominant language
- PHP
- Stars
- 1.6k
- Forks
- 173
- Avg merge
- 2d 49m
- Merged PRs (30d)
- 23
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/php-sdk
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan OpenServer
Difficulty 1/5 Under an hour Newbie friendliness 78/100
modelcontextprotocol/php-sdk#468 · 2 comments ·
-
needs confirmation needs maintainer action Server
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/php-sdk#398 · 1 reaction ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/php-sdk#370 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
modelcontextprotocol/php-sdk#504 ·
-
bug P2 Server
Difficulty 4/5 3-5 days Newbie friendliness 68/100
modelcontextprotocol/php-sdk#498 · 2 comments ·
All issues in modelcontextprotocol/php-sdk
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·