modelcontextprotocol / modelcontextprotocol/csharp-sdk
Resource-based authorization on tools
Dieses Issue hat noch niemand übernommen.
- 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.
Some tools require a resource-based authorization to authorize the tool use, while other tools do not. In a web API, we can use the [Authorize("some policy")] attribute, but it is not possible (the handler is not called) with [McpServerTool] methods, the same authorization is applied to the entire group.
Describe the solution you'd like
Allow to specify the authorization policy for specific tools. Since the resource is identified in the tool's parameters, an access to RequestContext<CallToolRequestParams> would be best.
Describe alternatives you've considered
The only alternative I could think of is to check the RequestUri for "/message", parse the body to create a RequestContext<CallToolRequestParams>
Additional context
tl;dr; offer resource-based authorization on tools
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die Autorisierung rund um die Methoden von McpServerTool nachzuverfolgen, und vergleiche sie mit dem erwähnten Verhalten der Authorize-Richtlinie in der Web-API. Untersuche, wie RequestContext Tool-Parameter verfügbar machen könnte, und verwende die /message-Alternative als Kontext. Als abgeschlossen gilt die Arbeit, wenn ein bestimmtes Tool eine ressourcenbasierte Richtlinie anwenden und auf seinen RequestContext zugreifen kann, ohne RequestUri zu parsen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- api, authorization
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100