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

Đang mở Phù hợp với người mới
#746 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Tài liệu
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
documentation

Hướng nghiên cứu

Cập nhật các lệnh import trong docs/get-started/first-server.md và README.md; bắt đầu bằng cách kiểm tra các ví dụ hiện có với các namespace thuộc tính của v0.9.0 được liệt kê trong issue. Công việc hoàn tất khi cả hai ví dụ đều import các thuộc tính từ Mcp\Capability\Attribute\ để khớp với SDK. class_alias được đề xuất là tùy chọn và cần được xem xét phạm vi riêng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
1.7k
Fork
206
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
102

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/php-sdk

Tất cả issue của modelcontextprotocol/php-sdk

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.