[Client] `Builder::addRequestHandler()` rejects the SDK's own handlers under PHPStan

オープン 初心者向け
#768 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@xixi-box がすでに取り組んでいます。

2026年11月22日 から。

  • #770 @xixi-box による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php

調査の方向性

addRequestHandler() のシグネチャは src/Client/Builder.php:177-179 を、パラメータを不変にしている @template の宣言は src/Client/Handler/Request/RequestHandlerInterface.php:21 を読んでください。issue にあるようなコードを対象に PHPStan を最大レベルで実行して問題を再現し、その後 template に @template-covariant を付けるか、パラメータを RequestHandlerInterface<*> に変更してください。PHPStan が ElicitationRequestHandler などの SDK 独自のハンドラを受け入れ、既存のテストがすべて通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

Package: mcp/sdk 0.9.0; still present in v0.10.0 and main (src/Client/Builder.php:177-179,
src/Client/Handler/Request/RequestHandlerInterface.php:21)

Client::builder()->addRequestHandler(new ElicitationRequestHandler($callback));

Actual (PHPStan level max): Parameter #1 expects RequestHandlerInterface<mixed>, ElicitationRequestHandler given;
the template parameter is invariant.

Expected: accepted: declare the template covariant (@template-covariant) or type the parameter
RequestHandlerInterface<*>.

Found while building Leash for the Symfony AI & PHP MCP SDK hackathon.

主要言語
PHP
スター
1.7k
フォーク
206
平均マージ
1日 19時間
マージ済み PR(30日)
100

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/php-sdk のほかの issue

modelcontextprotocol/php-sdk の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。