Preserve native JSON types when passing arguments to tool handlers
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- php
- Ambito
- backend-api-design
Direzione di ricerca
Start by tracing how validated arguments are passed to tool handlers and review the related decoding work in issue #586. Check the tests covering nested JSON values and handler arguments to identify where objects are converted to associative arrays. Done means handlers receive recursive stdClass, array, and scalar values as specified, with tests confirming the behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is your feature request related to a problem? Please describe.
The SDK currently converts JSON objects into associative PHP arrays before passing them to tool handlers. This forces a specific PHP representation on consumers instead of preserving the original JSON types.
Describe the solution you'd like
Pass validated arguments to tool handlers without implicit type conversion:
- JSON objects →
stdClass - JSON arrays →
array - Scalar values → their corresponding PHP types
This should apply recursively to nested structures.
For consumers preferring associative arrays, the SDK could provide an optional, documented recursive stdClass-to-array converter. Its use should be explicitly controlled by the consumer.
Describe alternatives you've considered
A configurable automatic conversion to associative arrays would preserve existing behavior, but introduce application-specific conversion logic and additional maintenance overhead into the SDK's argument-handling pipeline.
Existing Composer packages also provide object-to-array conversion, so consumers could handle this independently without additional SDK functionality.
Additional context
Related to #586, which addresses the loss of JSON type information during decoding and its impact on schema validation.
This request concerns the subsequent delivery of validated values to tool handlers.
The change would be breaking for consumers expecting associative arrays, but could be introduced before the SDK reaches 1.0. Preserving the current interface merely for convenience or backward compatibility would be an unfortunate design decision, as it would perpetuate unnecessary coupling to a specific PHP representation instead of establishing a clean, type-preserving API.
- Lingua principale
- PHP
- Stelle
- 1.6k
- Fork
- 180
- Merge medio
- 2g 16h
- PR unite (30g)
- 36
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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 PHPStanApertaServer
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
modelcontextprotocol/php-sdk#468 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Builder::build() silently skips configured file-based discovery when symfony/finder is missing — should fail loudlyForse già presa @ousamabenyounes l’ha presa 55 giorni fa. Apertaneeds confirmation needs maintainer action Server
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/php-sdk#398 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/php-sdk#370 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 Mezza giornata Idoneità per principianti 60/100
modelcontextprotocol/php-sdk#586 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
modelcontextprotocol/php-sdk#583 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di modelcontextprotocol/php-sdk
Issue simili
-
FrameworkBundle SecurityBundle
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
symfony/symfony-docs#23277 ·
I maintainer di solito rispondono entro 3 giorni
-
[Sync EN] hard link does not need special permissionsForse già presa @lacatoire l’ha presa oggi. Apertasync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
I maintainer di solito rispondono entro 4 giorni
-
feature-request
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
omegaup/omegaup#10323 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
bug mod:appointments
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
3pontos-tech/gil-benefits#303 ·