diff --git a/packages/mcp-express/src/auth-wrapper.ts b/packages/mcp-express/src/auth-wrapper.ts new file mode 100644 index 0000000..f6695b4 --- /dev/null +++ b/packages/mcp-express/src/auth-wrapper.ts @@ -0,0 +1,35 @@ +/** + * 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 + * 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';