Docs import a namespace that does not exist: Mcp\Server\Capability\Attribute\McpTool

Aperta Adatta ai principianti
#746 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
documentation

Direzione di ricerca

Aggiorna gli import in docs/get-started/first-server.md e README.md; inizia verificando gli esempi esistenti rispetto agli spazi dei nomi degli attributi della v0.9.0 elencati nell’issue. Il lavoro è completato quando entrambi gli esempi importano gli attributi da Mcp\Capability\Attribute\ in modo da corrispondere all’SDK. Il class_alias suggerito è facoltativo e richiederebbe una revisione separata dell’ambito.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What's wrong

The getting-started docs and the SDK README both tell you to import the tool attribute from a namespace that does not exist in v0.9.0.

docs/get-started/first-server.md:

use Mcp\Server\Capability\Attribute\McpResource;
use Mcp\Server\Capability\Attribute\McpTool;

README.md shows the same import.

What actually exists

Verified against mcp/sdk v0.9.0:

use Mcp\Capability\Attribute\McpTool;         // correct
use Mcp\Capability\Attribute\McpResource;     // correct
use Mcp\Capability\Attribute\McpPrompt;       // correct
use Mcp\Capability\Attribute\McpResourceTemplate; // correct
$ ls vendor/mcp/sdk/src/Server/Capability
ls: vendor/mcp/sdk/src/Server/Capability: No such file or directory

$ php -r 'require "vendor/autoload.php";
  var_dump(class_exists("Mcp\Server\Capability\Attribute\McpTool"));
  var_dump(class_exists("Mcp\Capability\Attribute\McpTool"));'
bool(false)
bool(true)

All five attribute classes live under Mcp\Capability\Attribute\. The Server\ segment was dropped at some point, and the docs were not updated with it.

Why it's worth fixing

Copying the quickstart verbatim is a fatal error on the very first file a new user writes. The error points at the use statement, so it reads like a typo the user made rather than an outdated doc, and the natural next step is to go looking for a typo instead of checking the installed version.

Suggested fix

Update the quickstart and README imports. If the flattening is recent, a class_alias shim for one release would let code written against the old docs keep working:

class_alias(\Mcp\Capability\Attribute\McpTool::class, \Mcp\Server\Capability\Attribute\McpTool::class);

Happy to open a PR for the docs if that's easier than doing it yourself.


Found while building a hackathon project against mcp/sdk v0.9.0 / symfony/mcp-bundle v1.0.0-BETA1 on PHP 8.5.8.

Lingua principale
PHP
Stelle
1.7k
Fork
206
Merge medio
1g 17h
PR unite (30g)
102

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/php-sdk

Tutte le issue di modelcontextprotocol/php-sdk

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.