Builder::build() silently skips configured file-based discovery when symfony/finder is missing — should fail loudly
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
Direzione di ricerca
Inizia individuando Builder::build() e la gestione di setDiscovery() descritta nell’issue, quindi confronta il suo ramo in cui manca Finder con Discoverer::__construct(). Aggiungi o aggiorna un test mirato per un percorso di discovery configurato senza symfony/finder. Il lavoro è completato quando build() genera la RuntimeException esistente e utile per intervenire, invece di registrare un avviso e produrre un elenco di strumenti vuoto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Calling setDiscovery() is an explicit declaration that the server's tools come from attribute discovery. But since symfony/finder is only a suggested dependency, a host application can easily end up without it — and when that happens, build() does this:
if (null !== $this->discoveryBasePath) {
if (null !== $this->discoverer || class_exists(Finder::class)) {
// ... discovery runs
} else {
$logger->warning('File-based discovery requires symfony/finder...');
}
}
The result is the worst failure mode available: the server builds successfully, initialize succeeds, and tools/list returns an empty array. The operator sees a healthy server; the symptom surfaces far from the cause, as confused MCP clients with no tools. The only breadcrumb is a single warning log line.
This also contradicts the SDK's own Discoverer::__construct(), which already throws RuntimeException('File-based discovery requires symfony/finder. ...') for exactly this situation — the builder's class_exists pre-check just routes around that guard, downgrading a configured-but-impossible feature from an error to a whisper.
Proposal: when discoveryBasePath is set, no custom discoverer was supplied, and Finder is unavailable, build() should throw (the Discoverer's existing message is perfect) instead of warning-and-skipping. This costs nothing for explicit-registration users, client-only users, or anyone without setDiscovery() — it only converts a silent production mystery into an immediate, actionable boot error for people who asked for discovery and can't have it.
Observed on v0.7.0. Context: we hit this failure mode while integrating the SDK into a Symfony bundle (pimcore/data-hub-simple-rest#312) and worked around it by requiring symfony/finder in the bundle directly — which remains the right consumer-side fix, but doesn't help the next integrator who doesn't know about the silent path.
- 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 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
modelcontextprotocol/php-sdk#370 ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
modelcontextprotocol/php-sdk#510 · 1 commento ·
-
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
-
sync-en
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
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 ·