`createMcpHandler` is validation-free; bare fetch mounts can skip the Host/Origin guards the framework helpers install |
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- nodejs, typescript
调研方向
The issue is about adding Host/Origin validation to createMcpHandler in packages/server/src/server/createMcpHandler.ts. Start by reading the existing JSDoc and the docs/serving/http.md guide to understand the current validation-free behavior. Look at the hostHeaderValidationResponse and originValidationResponse utilities to see how validation is applied. The goal is to design an API option or wrapper that adds these guards, while keeping an escape hatch for reverse-proxy deployments. Test by mounting the handler in a fetch-native runtime like Workers or Deno.
由索引模型根据 Issue 内容生成。
描述
Static review of public source at commit 603217008710. No traffic was sent to any MCP environment.
createMcpHandler intentionally performs no Host/Origin (or token) checks — documented in the JSDoc and in docs/serving/http.md. Framework helpers (createMcpExpressApp / Hono / Fastify) arm those checks for loopback. The bare fetch entry does not:
packages/server/src/server/createMcpHandler.ts (doc comment on the export):
* When mounting bare on a fetch-native runtime,
* put Origin/Host validation in front of the handler — the entry itself is
* deliberately validation-free:
*
* const rejected =
* hostHeaderValidationResponse(request, localhostAllowedHostnames()) ??
* originValidationResponse(request, localhostAllowedOrigins());
* return rejected ?? handler.fetch(request);
On Workers / Deno / Bun, export default handler (as shown earlier in the same guide for “Mount it on your runtime”) is a one-liner that never installs those guards unless the reader continues to the later section. That is a footgun relative to the Express path, where loopback protection is automatic.
Suggested change:
- Offer
createMcpHandler(factory, { allowedHosts, allowedOrigins })(or awithLocalhostProtection(handler)wrapper) that applieshostHeaderValidationResponse/originValidationResponsebeforefetch. - Or make the quickstart
export defaultexample always show the validation wrapper first. - Keep a documented escape hatch for authenticated reverse-proxy deployments.
Severity: low–medium / API footgun and defense-in-depth (complements finding #1 on non-loopback Express/Hono binds). No proof-of-concept.
Happy to send a focused PR if useful.
- 主要语言
- TypeScript
- 星标
- 13.6k
- 派生
- 2.3k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 51
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/typescript-sdk 的其他 Issue
-
Stateless 405 response omits the Allow header可能已有人在做 @Hugo-DDT 于 1 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/typescript-sdk#2970 · 2 条评论 ·
维护者通常 1 天内回复
-
[v2] @modelcontextprotocol/server inlines fast-uri 3.1.0, which has 9 published advisories可能已有人在做 @Andiii208 于 4 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/typescript-sdk#2966 · 3 条评论 ·
维护者通常 1 天内回复
-
v1 v2
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/typescript-sdk#2946 · 4 条评论 ·
维护者通常 1 天内回复
-
[v2] URI template reserved expansions encode existing %HH sequences again可能已有人在做 @takagibit18 于 10 天前认领。 未关闭v1 v2
难度 2/5 1-3 小时 新手友好度 84/100
modelcontextprotocol/typescript-sdk#2920 · 1 条评论 ·
维护者通常 1 天内回复
-
[v2] URI template strict expansions leave !'()* unencoded可能已有人在做 @takagibit18 于 10 天前认领。 未关闭v1 v2
难度 2/5 1-3 小时 新手友好度 84/100
modelcontextprotocol/typescript-sdk#2919 · 1 条评论 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/typescript-sdk 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
-
area:cowork area:desktop documentation enhancement platform:macos
难度 2/5 1-3 小时 新手友好度 68/100
anthropics/claude-code#101720 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
apache/rocketmq-dashboard#6610 ·
维护者通常 3 天内回复
-
Add: MS NOW未关闭check:passed streams:add
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
Global update drops overrideAccess, so Local API updateGlobal fails filterOptions validation (3.90 regression)可能已有人在做 @PINYOPATTANAWASANPORN 今天认领。 未关闭area: core Bug
难度 2/5 1-3 小时 新手友好度 76/100
payloadcms/payload#18674 · 1 条评论 ·
维护者通常 1 天内回复