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 摘要。