Public hooks for pre-validation request inspection, extending server/discover and initialize _meta, and wrapping handler results

オープン
#3,253 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript

調査の方向性

Start by reading the public Server and toNodeHandler APIs, then inspect the private Server.connect, _ondiscover, _oninitialize, and _wrapHandler points named in the issue, along with the proposed interceptor in #2507. The issue requests maintainers to agree on a direction across four API seams, so completion criteria depend on that decision and would likely involve coordinated API and documentation changes.

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

説明

v2

@lushly-dev/afd-server (pinned @modelcontextprotocol/server ~2.4.0, @modelcontextprotocol/node ~2.1.2) patches a few private points of Server and depends on one internal shape. We keep guard tests on each, but we'd like to stop depending on private API. Each item below is a request for a public seam.

  1. Pre-validation request inspection. We wrap Server.connect and replace transport.onmessage to read tools/call arguments exactly as the transport delivered them. Schema validation rebuilds arguments and drops a member named __proto__, so a security-relevant key nested under one disappears instead of being refusable. Ask: a documented hook (for example ServerOptions.onRawRequest(message, extra)) that runs before schema validation and can answer with an error.
  2. Contributing _meta to server/discover and InitializeResult. We wrap the private Server._ondiscover() and Server._oninitialize() to add a _meta entry that advertises our server's contract. Ask: a public way to contribute _meta (or capability extensions) to both results.
  3. Wrapping handler results. We patch Server._wrapHandler so tools/call can return an MCP Tasks CreateTaskResult. Ask: a public result-wrapping or task hook. The interceptor proposed in #2507 might cover this if it can replace the result, but because it runs after input validation, it doesn't cover item 1.
  4. The request shape toNodeHandler reads. We pass toNodeHandler a re-created request whose body has already been read. Ask: document which IncomingMessage properties toNodeHandler reads, or accept a pre-read body.

We're happy to contribute a PR for any of these if the maintainers agree on a direction.

主要言語
TypeScript
スター
13.8k
フォーク
2.5k
平均マージ
6日 23時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

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

modelcontextprotocol/typescript-sdk のほかの issue

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

似ている issue

TypeScript の issue をもっと見る

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

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