[v2] Add a runnable example for routing requests to tenant-specific APIs

未关闭 适合新手
#3,243 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
documentation

调研方向

阅读 HTTP 指南中 https://ts.sdk.modelcontextprotocol.io/v2/serving/http#pass-authentication-through 这一节和 examples/scoped-tools 示例,以确定现有的身份验证 API 和示例约定。添加一个可运行的示例,包含两个模拟后端,以及一个将已验证的租户 ID 映射到已批准 URL 的服务器端 map;涵盖并发请求以及租户缺失或未知的情况。示例能够运行且这些情况都经过测试后,即为完成。

由索引模型根据 Issue 内容生成。

描述

v2
What happened?

I'm building a single MCP endpoint that serves multiple tenants, each with its own backend API. The HTTP guide shows how createMcpHandler receives verified authInfo, and examples/scoped-tools shows per-tool authorization. I couldn't find a runnable example that takes the next step and uses that verified identity to select the tenant's backend.

I tried this locally on v2.4.0 with two fictional tenants. Concurrent requests resolved to different configured backend URLs, and a request without tenant context was rejected. This passed in both the legacy and 2026-07-28 protocol modes using fixture identities.

What did you expect?

Would you be open to a small runnable example using the existing SDK APIs? I can contribute an example with two mock backends, a server-side map from verified tenant IDs to approved URLs, and tests for concurrent requests and missing or unknown tenants. Would this fit alongside scoped-tools or in the HTTP guide?

Code to reproduce
https://ts.sdk.modelcontextprotocol.io/v2/serving/http#pass-authentication-through
SDK version

@modelcontextprotocol/[email protected], @modelcontextprotocol/[email protected]

Area

Documentation

主要语言
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 摘要。