Skip to content

Commit 4cf7988

Browse files
committed
Use resource metadata URL instead of path
1 parent e782784 commit 4cf7988

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/next/auth-wrapper.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@ export interface McpAuthOptions {
1717
requiredScopes?: string[];
1818

1919
/**
20-
* Optional, resource metadata path to include in WWW-Authenticate header.
20+
* Optional, resource metadata URL to include in WWW-Authenticate header.
2121
*/
22-
resourceMetadataPath?: string;
22+
resourceMetadataUrl?: string;
2323
}
2424

2525
export function withMcpAuth(
2626
handler: (req: Request) => Promise<Response>,
2727
verifyToken: (req: Request, token: string) => Promise<AuthInfo>,
28-
options: McpAuthOptions = {
29-
resourceMetadataPath: "/.well-known/oauth-protected-resource"
30-
}
28+
options?: McpAuthOptions
3129
) {
3230
return async (req: Request) => {
3331
try {
@@ -53,7 +51,7 @@ export function withMcpAuth(
5351
}
5452

5553
// Check if token has the required scopes (if any)
56-
if (options.requiredScopes?.length) {
54+
if (options?.requiredScopes?.length) {
5755
const hasAllScopes = options.requiredScopes.every(scope =>
5856
authInfo.scopes.includes(scope)
5957
);
@@ -74,7 +72,7 @@ export function withMcpAuth(
7472
return handler(req);
7573
} catch (error) {
7674
const origin = new URL(req.url).origin;
77-
const resourceMetadataUrl = options.resourceMetadataPath || `${origin}/.well-known/oauth-protected-resource`;
75+
const resourceMetadataUrl = options?.resourceMetadataUrl || `${origin}/.well-known/oauth-protected-resource`;
7876

7977
if (error instanceof InvalidTokenError) {
8078
return new Response(JSON.stringify(error.toResponseObject()), {

0 commit comments

Comments
 (0)