File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed
examples/express-mcp-server/src Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change 11import express from 'express' ;
22import { config } from 'dotenv' ;
3- import { McpAuth , protectedRoute } from '@asgardeo/mcp-express' ;
3+ import { McpAuthServer } from '@asgardeo/mcp-express' ;
44import { protectedRoutes } from './routes/protected' ;
55import { publicRoutes } from './routes/public' ;
66
@@ -9,25 +9,18 @@ config();
99const app = express ( ) ;
1010const port = process . env . PORT || 3000 ;
1111
12- app . use ( express . json ( ) ) ;
12+ const mcpAuthServer = new McpAuthServer ( {
13+ baseUrl : process . env . BASE_URL as string ,
14+ } ) ;
1315
14- app . use (
15- McpAuth ( {
16- baseUrl : process . env . BASE_URL as string ,
17- } ) ,
18- ) ;
16+ app . use ( express . json ( ) ) ;
17+ app . use ( mcpAuthServer . router ( ) ) ;
1918
2019// Public routes
2120app . use ( '/api' , publicRoutes ) ;
2221
2322// Protected routes with MCP authentication
24- app . use (
25- '/api/protected' ,
26- protectedRoute ( {
27- baseUrl : process . env . BASE_URL as string ,
28- } ) ,
29- protectedRoutes ,
30- ) ;
23+ app . use ( '/api/protected' , mcpAuthServer . protect ( protectedRoutes ) ) ;
3124
3225// Error handling middleware
3326app . use ( ( err : Error , req : express . Request , res : express . Response , next : express . NextFunction ) => {
You can’t perform that action at this time.
0 commit comments