Skip to content

Commit cdf3614

Browse files
authored
Merge pull request #18 from sagara-gunathunga/main
Introduced configuredAuthServer that only requires .env BASE_URL entry
2 parents 9bbf536 + 341b913 commit cdf3614

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
import {McpAuthServer} from './McpAuthServer.js';
20+
21+
const PORT: string = process.env[`PORT`] || '3000';
22+
const {BASE_URL} = process.env;
23+
const MCP_RESOURCE: string = process.env['MCP_RESOURCE'] || `http://localhost:${PORT}/mcp`;
24+
25+
if (!BASE_URL) {
26+
throw new Error('BASE_URL is missing. Please set it in the .env file.');
27+
}
28+
29+
const configuredAuthServer: McpAuthServer = new McpAuthServer({
30+
baseUrl: BASE_URL,
31+
issuer: `${BASE_URL}/oauth2/token`,
32+
resource: MCP_RESOURCE,
33+
});
34+
35+
export {configuredAuthServer};

packages/mcp-express/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
*/
1818

1919
export {McpAuthServer} from './McpAuthServer';
20+
export {configuredAuthServer} from './auth-wrapper.js';

0 commit comments

Comments
 (0)