[Server] Decode JSON-RPC objects as stdClass, not associative arrays
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Individua il punto di ingresso della decodifica JSON-RPC in ingresso e traccia i metodi interni che consumano i messaggi decodificati. Verifica come la semantica di oggetti e array raggiunge Opis\JsonSchema\Validator, quindi aggiorna i percorsi interessati affinché i valori degli oggetti rimangano istanze di stdClass e la validazione abbia esito positivo per i parametri degli strumenti di tipo oggetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 1.6k
- Fork
- 173
- Merge medio
- 2g 49m
- PR unite (30g)
- 23
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di modelcontextprotocol/php-sdk
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan ApertaServer
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
modelcontextprotocol/php-sdk#468 · 2 commenti ·
-
needs confirmation needs maintainer action Server
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/php-sdk#398 · 1 reazione ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/php-sdk#370 ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
modelcontextprotocol/php-sdk#504 ·
-
bug P2 Server
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
modelcontextprotocol/php-sdk#498 · 2 commenti ·
Tutte le issue di modelcontextprotocol/php-sdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getgrav/grav-plugin-api#45 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
RSS-Bridge/rss-bridge#5098 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
phingofficial/phing#2025 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
silverstripe/developer-docs#911 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100