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

未關閉
#3,253 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
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 小時
30 天內合併 PR
2

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

modelcontextprotocol/typescript-sdk 的其他 Issue

查看 modelcontextprotocol/typescript-sdk 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。