@@ -2,6 +2,7 @@ import { BearerAuthMiddlewareOptions, requireBearerAuth } from "@modelcontextpro
22import { AuthRouterOptions , getOAuthProtectedResourceMetadataUrl , mcpAuthRouter } from "@modelcontextprotocol/sdk/server/auth/router.js" ;
33import cors from "cors" ;
44import express from "express" ;
5+ import rateLimit from "express-rate-limit" ;
56import path from "path" ;
67import { fileURLToPath } from "url" ;
78import { EverythingAuthProvider } from "./auth/provider.js" ;
@@ -15,6 +16,13 @@ import { logger } from "./utils/logger.js";
1516
1617const app = express ( ) ;
1718
19+ // Rate limiter for splash page
20+ const splashLimiter = rateLimit ( {
21+ windowMs : 15 * 60 * 1000 , // 15 minutes
22+ max : 100 , // limit each IP to 100 requests per windowMs
23+ standardHeaders : true , // Return rate limit info in the `RateLimit-*` headers
24+ legacyHeaders : false , // Disable the `X-RateLimit-*` headers
25+ } ) ;
1826// Get the directory of the current module
1927const __filename = fileURLToPath ( import . meta. url ) ;
2028const __dirname = path . dirname ( __filename ) ;
@@ -168,7 +176,7 @@ app.get("/mcp-logo.png", (req, res) => {
168176} ) ;
169177
170178// Splash page
171- app . get ( "/" , ( req , res ) => {
179+ app . get ( "/" , splashLimiter , ( req , res ) => {
172180 const splashPath = path . join ( __dirname , "static" , "index.html" ) ;
173181 res . sendFile ( splashPath ) ;
174182} ) ;
0 commit comments