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

未关闭 适合新手
#746 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
documentation

调研方向

更新 docs/get-started/first-server.md 和 README.md 中的导入;先根据 issue 中列出的 v0.9.0 属性命名空间检查现有示例。两个示例都从 Mcp\Capability\Attribute\ 导入属性并与 SDK 保持一致后,即表示完成。建议的 class_alias 是可选的,需要单独进行范围审查。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
PHP
星标
1.7k
派生
206
平均合并
1 天 17 小时
30 天内合并 PR
102

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/php-sdk 的其他 Issue

查看 modelcontextprotocol/php-sdk 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。