dummy proxy values

This commit is contained in:
Paul Carleton
2025-05-12 17:53:21 +01:00
parent 1356bdb15e
commit 4c7c44e75b

View File

@@ -1,3 +1,5 @@
import { ProxyOAuthServerProvider } from '@modelcontextprotocol/sdk/server/auth/providers/proxyProvider.js';
import { mcpAuthRouter } from '@modelcontextprotocol/sdk/server/auth/router.js';
import express, { Request, Response } from 'express'; import express, { Request, Response } from 'express';
export interface AuthConfig { export interface AuthConfig {
@@ -22,22 +24,32 @@ export function addAuthEndpoints(app: express.Application, config: AuthConfig):
return; return;
} }
// OAuth metadata endpoint // TODO: use github(?)
app.get('/.well-known/oauth-authorization-server', (req: Request, res: Response) => { const proxyProvider = new ProxyOAuthServerProvider({
const baseUrl = `${req.protocol}://${req.get('host')}`; endpoints: {
authorizationUrl: "https://auth.external.com/oauth2/v1/authorize",
const metadata: WellKnownOAuthMetadata = { tokenUrl: "https://auth.external.com/oauth2/v1/token",
issuer: baseUrl, revocationUrl: "https://auth.external.com/oauth2/v1/revoke",
authorization_endpoint: `${baseUrl}/oauth/authorize`, },
token_endpoint: `${baseUrl}/oauth/token`, verifyAccessToken: async (token) => {
jwks_uri: `${baseUrl}/.well-known/jwks.json`, return {
response_types_supported: ['code', 'token', 'id_token', 'code token', 'code id_token', 'token id_token', 'code token id_token'], token,
grant_types_supported: ['authorization_code', 'implicit', 'refresh_token', 'client_credentials'], clientId: "123",
subject_types_supported: ['public'], scopes: ["openid", "email", "profile"],
id_token_signing_alg_values_supported: ['RS256'], }
scopes_supported: ['openid', 'profile', 'email'] },
}; getClient: async (client_id) => {
return {
client_id,
redirect_uris: ["http://localhost:3000/callback"],
}
}
})
res.header('Content-Type', 'application/json').send(metadata); app.use(mcpAuthRouter({
}); provider: proxyProvider,
} issuerUrl: new URL("https://auth.external.com"),
baseUrl: new URL("https://mcp.example.com"),
serviceDocumentationUrl: new URL("https://docs.example.com/"),
}))
}