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

Đang mở Phù hợp với người mới
#3,243 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
documentation

Hướng nghiên cứu

Đọc phần hướng dẫn HTTP tại https://ts.sdk.modelcontextprotocol.io/v2/serving/http#pass-authentication-through và ví dụ examples/scoped-tools để xác định các API xác thực hiện có và quy ước của các ví dụ. Thêm một ví dụ có thể chạy được, gồm hai backend giả lập và một map phía máy chủ ánh xạ ID tenant đã xác minh sang URL được phê duyệt; bao gồm các yêu cầu đồng thời và trường hợp thiếu tenant hoặc tenant không xác định. Hoàn tất khi ví dụ chạy được và các trường hợp đó đã được kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
13.8k
Fork
2.5k
Merge trung bình
6 ngày 23 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/typescript-sdk

Tất cả issue của modelcontextprotocol/typescript-sdk

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.