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

Offen Anfängerfreundlich
#3,243 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
68/100
Issue-Typ
Dokumentation
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
documentation

Rechercherichtung

Lies den Abschnitt des HTTP-Leitfadens unter https://ts.sdk.modelcontextprotocol.io/v2/serving/http#pass-authentication-through und das Beispiel examples/scoped-tools, um die vorhandenen Auth-APIs und die Konventionen für Beispiele zu ermitteln. Füge ein ausführbares Beispiel mit zwei Mock-Backends und einer serverseitigen Zuordnung von verifizierten Tenant-IDs zu genehmigten URLs hinzu; berücksichtige gleichzeitige Anfragen sowie fehlende oder unbekannte Tenants. Fertig ist die Aufgabe, wenn das Beispiel läuft und diese Fälle getestet sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
13.8k
Forks
2.5k
Ø Merge
6 T. 23 Std.
Gemergte PRs (30 T.)
2

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/typescript-sdk

Alle Issues in modelcontextprotocol/typescript-sdk

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.