modelcontextprotocol / modelcontextprotocol/csharp-sdk

Access to HttpContext within handler delegates like ListToolsHandler for authentication-aware logic

Offen
#520 6 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement needs confirmation
Vorherrschende Sprache
C#
Sterne
4.5k
Forks
814
Ø Merge
9 T. 19 Std.
Gemergte PRs (30 T.)
4

Beschreibung

Is your feature request related to a problem? Please describe.
I'm currently working with the Model Context Protocol in .NET and would like to dynamically filter the tools returned by the ListToolsHandler based on the current user's authentication context. However, it doesn't seem possible to access the current HTTP context inside the ListToolsHandler or similar delegate handlers. This limits the ability to tailor tool availability based on user identity or permissions.

Describe the solution you'd like
I would like to be able to access the current HttpContext (or any equivalent user context) from within handlers like ListToolsHandler, CallToolHandler, etc. This would allow implementing features like per-user tool availability or custom authorization logic.

Describe alternatives you've considered
I haven't found a clear alternative to accessing the HTTP context directly from these handlers. Most approaches seem like workarounds and don't offer a clean or reliable way to integrate authentication data.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, nachzuverfolgen, wie ListToolsHandler und CallToolHandler im C# SDK aufgerufen werden und wo der aktuelle Request-Kontext verfügbar ist. Vergleiche den angeforderten HttpContext oder einen gleichwertigen Benutzerkontext mit der bestehenden Handler-API. Die Umsetzung sollte eine dokumentierte, zuverlässige Möglichkeit schaffen, mit der Handler eine benutzerspezifische Authentifizierungs- oder Autorisierungslogik anwenden können.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
api, authentication
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

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