From 0e8c0e00f4e80acf12cf704ccd4776ad2b2fa763 Mon Sep 17 00:00:00 2001 From: Sagara Gunathunga Date: Tue, 17 Mar 2026 21:30:08 +1300 Subject: [PATCH 1/2] Introduced configuredAuthServer that only requires .env BASE_URL entry --- packages/mcp-express/src/auth-wrapper.ts | 35 ++++++++++++++++++++++++ packages/mcp-express/src/public-api.ts | 1 + 2 files changed, 36 insertions(+) create mode 100644 packages/mcp-express/src/auth-wrapper.ts diff --git a/packages/mcp-express/src/auth-wrapper.ts b/packages/mcp-express/src/auth-wrapper.ts new file mode 100644 index 0000000..71366c9 --- /dev/null +++ b/packages/mcp-express/src/auth-wrapper.ts @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import {McpAuthServer} from './McpAuthServer.js'; + +const PORT: string = process.env[`PORT`] || '3000'; +const {BASE_URL} = process.env; +const MCP_RESOURCE: string = process.env['MCP_RESOURCE'] || `http://localhost:${PORT}/mcp`; + +if (!BASE_URL) { + throw new Error('BASE_URL is missing. Please set it in the .env file.'); +} + +const configuredAuthServer: McpAuthServer = new McpAuthServer({ + baseUrl: BASE_URL, + issuer: `${BASE_URL}/oauth2/token`, + resource: MCP_RESOURCE, +}); + +export {configuredAuthServer}; diff --git a/packages/mcp-express/src/public-api.ts b/packages/mcp-express/src/public-api.ts index 7c0cb58..e10b869 100644 --- a/packages/mcp-express/src/public-api.ts +++ b/packages/mcp-express/src/public-api.ts @@ -17,3 +17,4 @@ */ export {McpAuthServer} from './McpAuthServer'; +export {configuredAuthServer} from './auth-wrapper.js'; From 341b9135818aba05cc5e0d92aa4cad1819c49faf Mon Sep 17 00:00:00 2001 From: Brion Mario Date: Wed, 18 Mar 2026 09:53:29 +0530 Subject: [PATCH 2/2] Apply suggestion from @brionmario --- packages/mcp-express/src/auth-wrapper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mcp-express/src/auth-wrapper.ts b/packages/mcp-express/src/auth-wrapper.ts index 71366c9..f6695b4 100644 --- a/packages/mcp-express/src/auth-wrapper.ts +++ b/packages/mcp-express/src/auth-wrapper.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except