[Server] Expose request-level metadata (e.g., securitySchema) to tool handlers
まだ誰も着手していません。
評価
調査の方向性
まず、サーバーのツールディスパッチ層と、受信したリクエストエンベロープがどのようにツールハンドラーへ到達するかを追跡します。この issue では具体的なファイルやテストは指定されていません。CallToolRequest を注入する場合と meta セクションを注入する場合を比較し、その後、ハンドラーが securitySchema を読み取れること、および既存のパラメーターのみを使用するハンドラーが引き続き動作することを示すカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem? Please describe.
Tool handlers currently receive only the parameters defined for the tool call.
Metadata included in the request envelope (for example a securitySchema) is not available inside the handler.
This makes it impossible to perform logic that depends on contextual information from the request itself.
Describe the solution you’d like
A way for tool handlers to access the metadata from the incoming request envelope.
This could be done by injecting either the full request object or just the meta section into the handler method.
Having this information available would allow tools to perform authorization checks, tenant selection, and similar context-dependent actions.
Describe alternatives you’ve considered
The only workaround at the moment is extracting envelope metadata before the request reaches the tool dispatching layer and storing it somewhere manually.
Once inside the handler, that information can no longer be accessed in a clean or reliable way.
Additional context
A common use case is reading a securitySchema sent by the client.
This information is part of the envelope, not part of the tool parameters, and is therefore currently inaccessible inside tool logic.
What tool handlers currently look like
use MCP\Server\Attributes\McpTool;
final class ExampleTools
{
#[McpTool(name: 'example_action')]
public function exampleAction(string $input): array
{
// Only defined parameters are available.
// Envelope metadata (e.g., securitySchema) cannot be accessed here.
return ['result' => 'ok'];
}
}
Proposed Option A — Inject full request object
use MCP\Server\Attributes\McpTool;
use MCP\Types\CallToolRequest;
final class ExampleTools
{
#[McpTool(name: 'example_action')]
public function exampleAction(
string $input,
CallToolRequest $request,
): array {
$meta = $request->meta ?? null;
$schema = $meta['securitySchema'] ?? null;
return [
'result' => 'ok',
'securitySchema' => $schema,
];
}
}
Proposed Option B — Inject only the meta section
use MCP\Server\Attributes\McpTool;
final class ExampleTools
{
#[McpTool(name: 'example_action')]
public function exampleAction(
string $input,
array $meta = [],
): array {
$schema = $meta['securitySchema'] ?? null;
return [
'result' => 'ok',
'securitySchema' => $schema,
];
}
}
- 主要言語
- PHP
- スター
- 1.6k
- フォーク
- 173
- 平均マージ
- 2日 49分
- マージ済み PR(30日)
- 23
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/php-sdk のほかの issue
-
[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan オープンServer
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
modelcontextprotocol/php-sdk#468 · コメント 2 件 ·
-
needs confirmation needs maintainer action Server
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/php-sdk#398 · リアクション 1 件 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/php-sdk#370 ·
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
modelcontextprotocol/php-sdk#510 · コメント 1 件 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
modelcontextprotocol/php-sdk#504 ·
modelcontextprotocol/php-sdk の issue をすべて見る
似ている issue
-
jira-created
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
nunomaduro/phpinsights#745 ·
-
status/awaiting_triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
WordPress/plugin-check#1486 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
az-digital/az_quickstart#6019 ·