Skip to content

Commit 7646bac

Browse files
Add issuer as an initialization parameter
1 parent d49388a commit 7646bac

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

examples/express-mcp-server/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const port = process.env.PORT || 3000;
1111

1212
const mcpAuthServer = new McpAuthServer({
1313
baseUrl: process.env.BASE_URL as string,
14+
issuer: process.env.ISSUER as string,
1415
});
1516

1617
app.use(express.json());

examples/express-mcp-vet-ai-assist-app/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const app: Express = express();
3131

3232
const mcpAuthServer: McpAuthServer = new McpAuthServer({
3333
baseUrl: process.env.BASE_URL as string,
34+
issuer: process.env.ISSUER as string,
3435
});
3536

3637
app.use(express.json());

packages/mcp-express/src/middlewares/bearerAuthMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function bearerAuthMiddleware(options: McpAuthOptions) {
6060
options: {
6161
audience: options?.audience,
6262
clockTolerance: 60,
63-
issuer: `${issuerBase}/oauth2/token`,
63+
issuer: `${options.issuer}`,
6464
},
6565
};
6666

packages/mcp-express/src/routes/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import {getProtectedResourceMetadata} from '../controllers/protected-resource';
2323

2424
export default function AuthRouter(options: McpAuthOptions): express.Router {
2525
const router: express.Router = express.Router();
26-
const {baseUrl} = options;
26+
const {baseUrl, issuer} = options;
2727
if (!baseUrl) {
2828
throw new Error('baseUrl must be provided');
2929
}
3030

3131
router.use(
3232
PROTECTED_RESOURCE_URL,
3333
getProtectedResourceMetadata({
34-
authorizationServers: [baseUrl],
34+
authorizationServers: [issuer],
3535
resource: 'https://api.example.com',
3636
}),
3737
);

packages/mcp-node/src/models/mcp-auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
export interface McpAuthOptions {
2020
audience?: string;
2121
baseUrl: string;
22+
issuer: string;
2223
}

0 commit comments

Comments
 (0)