modelcontextprotocol / modelcontextprotocol/php-sdk
Builder::build() silently skips configured file-based discovery when symfony/finder is missing — should fail loudly
Personne n'a encore pris cette issue.
- Langage dominant
- PHP
- Étoiles
- 1.6k
- Forks
- 173
- Merge moyen
- 2 j 49 min
- PR mergées (30 j)
- 23
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par localiser Builder::build() et la gestion de setDiscovery() décrite dans l’issue, puis comparez sa branche où Finder est absent avec Discoverer::__construct(). Ajoutez ou mettez à jour un test ciblé pour un chemin de discovery configuré sans symfony/finder. C’est terminé lorsque build() lève la RuntimeException existante et exploitable au lieu de journaliser un avertissement et de produire une liste d’outils vide.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- php
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 68/100