modelcontextprotocol / modelcontextprotocol/csharp-sdk
Not able to customize the url '.well-known/oauth-protected-resource' behind AKS/nginx ingress
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
Describe the bug
When we enable OAuth (using Entra) for the MCP server it produces the well known resource url through '/.well-known/oauth-protected-resource'.
.AddMcp(options =>
{
var metadata = new ModelContextProtocol.Authentication.ProtectedResourceMetadata()
{
Resource = new Uri(serverAddress + "api/mcp"),
AuthorizationServers = { new Uri($"{instance}/{tenantId}/v2.0") },
ScopesSupported = [$"{apiAppName}/Mcp.Access"],
};
options.ResourceMetadata = metadata;
});
...
...
app.MapMcp("/api/mcp").RequireAuthorization();
Now when we deploy this behind an ingress controller with path redirects, the MCP client doesn't have a way to know the modified resource url that it needs to connect.
E.g. if I deploy the server from this base route 'https://abc.azure.com/sanjayd' with ingress redirects, we can ideally reach the mcp server at 'https://abc.azure.com/sanjayd/api/mcp', and that will throw 401. But all clients including VS Code etc. now tries to connect to 'https://abc.azure.com/.well-known/oauth-protected-resource' to download the metadata. Ideally there should be a way to mention the base route for metadata while using ingress.
1st call from client: POST https://abc.azure.com/sanjayd/api/mcp -> returns 401 with 'www-authenticate' header like 'Bearer realm="McpAuth", resource_metadata="http://10.10.1.40/.well-known/oauth-protected-resource"'
2nd call from client: GET https://abc.azure.com/.well-known/oauth-protected-resource -> missing the 'sanjayd' part.
This works locally though as there is no ingress/re-route.
Any help is appreciated on how this will work with ingress.
Below are from a web client
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 mit der AddMcp ResourceMetadata-Konfiguration und den app.MapMcp("/api/mcp")-Einstiegspunkten und verfolge dann, wie die WWW-Authenticate resource_metadata-URL erzeugt wird, wenn die Anwendung hinter einem AKS/nginx-Ingress-Pfad bereitgestellt wird. Reproduziere den /sanjayd/api/mcp-Ablauf und überprüfe, dass Clients Metadaten mit beibehaltenem Basis-Pfad abrufen können.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- azure, csharp, kubernetes, nginx
- Bereich
- api, authentication, cloud
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100