modelcontextprotocol / modelcontextprotocol/csharp-sdk
Not able to customize the url '.well-known/oauth-protected-resource' behind AKS/nginx ingress
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 4.5k
- Forks
- 814
- Merge medio
- 9 d 19 h
- PR fusionados (30 d)
- 4
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la configuración de AddMcp ResourceMetadata y los puntos de entrada app.MapMcp("/api/mcp"); después, sigue cómo se genera la URL resource_metadata de WWW-Authenticate cuando se despliega detrás de una ruta de ingreso de AKS/nginx. Reproduce el flujo /sanjayd/api/mcp y verifica que los clientes puedan recuperar los metadatos conservando la ruta base.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- azure, csharp, kubernetes, nginx
- Área
- api, authentication, cloud
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100