modelcontextprotocol / modelcontextprotocol/php-sdk

Builder::build() silently skips configured file-based discovery when symfony/finder is missing — should fail loudly

Offen Anfängerfreundlich
#398 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

needs confirmation needs maintainer action Server
Vorherrschende Sprache
PHP
Sterne
1.6k
Forks
173
Ø Merge
2 T. 49 Min.
Gemergte PRs (30 T.)
23

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, Builder::build() und die im Issue beschriebene Verarbeitung von setDiscovery() zu lokalisieren, und vergleiche dann dessen Zweig für das fehlende Finder mit Discoverer::__construct(). Füge einen fokussierten Test für einen konfigurierten Discovery-Pfad ohne symfony/finder hinzu oder aktualisiere ihn. Erledigt ist es, wenn build() die bestehende aussagekräftige RuntimeException auslöst, statt eine Warnung zu loggen und eine leere Tool-Liste zu erzeugen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
68/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.