fix(mcp): answer the discovery documents under the server address too

A client handed https://host/mcp as the server address looks for the
well-known documents below that path instead of asking the origin, and every
one of those probes fell through to the web app: 200 with an HTML body, which
reads to the client as "this server has no OAuth" (Open WebUI reports it as an
unexpected mimetype). The three documents are served under /mcp/.well-known
now, anything else there answers a JSON 404, and the RFC 8414 path-inserted
form /.well-known/oauth-authorization-server/mcp serves the metadata instead
of 404. The wiki says which redirect URI belongs to the client and that a
plain-HTTP APP_URL leaves the discovery document pointing at localhost.
This commit is contained in:
Maurice
2026-09-22 11:52:24 +02:00
parent a44df6cf11
commit da32eb8a3c
5 changed files with 102 additions and 5 deletions
@@ -103,6 +103,7 @@ export const PUBLIC_ROUTE_ALLOW_LIST: string[] = [
'ConfigController.getConfig',
// OAuth/OIDC discovery documents + the JSON 404 catchalls that keep
// /.well-known probes from ever seeing SPA HTML.
'DiscoveryController.authorizationServerForMcp',
'DiscoveryController.openidConfiguration',
'DiscoveryController.protectedResource',
'DiscoveryController.wellKnownFallback',
@@ -129,6 +130,12 @@ export const PUBLIC_ROUTE_ALLOW_LIST: string[] = [
'JourneyPublicController.legacyPhoto',
'JourneyPublicController.photo',
// The MCP transport — bearer tokens are verified inside the handler.
// The same documents under the resource URL, for clients that append the
// well-known path to the server address they were handed.
'McpResourceDiscoveryController.authorizationServer',
'McpResourceDiscoveryController.fallback',
'McpResourceDiscoveryController.openidConfiguration',
'McpResourceDiscoveryController.protectedResource',
'McpTransportController.delete',
'McpTransportController.get',
'McpTransportController.post',