Skip to content

Commit dbd3e9a

Browse files
committed
Revert OAuth metadata change for backwards compatibility
Keep serving .well-known/oauth-authorization-server from MCP server in separate mode as some clients may expect to find it there
1 parent e393cb2 commit dbd3e9a

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

src/index.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { BearerAuthMiddlewareOptions, requireBearerAuth } from "@modelcontextprotocol/sdk/server/auth/middleware/bearerAuth.js";
2-
import { AuthRouterOptions, getOAuthProtectedResourceMetadataUrl, mcpAuthRouter } from "@modelcontextprotocol/sdk/server/auth/router.js";
2+
import { AuthRouterOptions, getOAuthProtectedResourceMetadataUrl, mcpAuthRouter, mcpAuthMetadataRouter } from "@modelcontextprotocol/sdk/server/auth/router.js";
33
import cors from "cors";
44
import rateLimit from "express-rate-limit";
55
import express from "express";
@@ -227,19 +227,15 @@ if (AUTH_MODE === 'integrated') {
227227
}
228228
}
229229

230-
// In separate mode, we serve minimal OAuth metadata that points to the auth server
231-
// This allows OAuth clients to discover the authorization endpoints
232-
233-
// Serve OAuth protected resource metadata endpoint
234-
app.get('/.well-known/oauth-protected-resource', (req, res) => {
235-
res.json({
236-
resource: BASE_URI,
237-
authorization_server: AUTH_SERVER_URL,
238-
bearer_methods_supported: ['header'],
239-
resource_documentation: `${BASE_URI}/docs`,
240-
resource_signing_alg_values_supported: ['HS256']
241-
});
242-
});
230+
// BACKWARDS COMPATIBILITY: We serve OAuth metadata from the MCP server even in separate mode
231+
// This is technically redundant since the auth server handles all OAuth operations,
232+
// but some clients may expect to find .well-known/oauth-authorization-server on the
233+
// resource server itself. The metadata points to the external auth server endpoints.
234+
app.use(mcpAuthMetadataRouter({
235+
oauthMetadata: authMetadata,
236+
resourceServerUrl: new URL(BASE_URI),
237+
resourceName: "MCP Everything Server"
238+
}));
243239

244240
// Configure bearer auth with external verifier
245241
const externalVerifier = new ExternalAuthVerifier(AUTH_SERVER_URL);

0 commit comments

Comments
 (0)