@@ -2,6 +2,7 @@ import { BearerAuthMiddlewareOptions, requireBearerAuth } from "@modelcontextpro
2
2
import { AuthRouterOptions , getOAuthProtectedResourceMetadataUrl , mcpAuthRouter } from "@modelcontextprotocol/sdk/server/auth/router.js" ;
3
3
import cors from "cors" ;
4
4
import express from "express" ;
5
+ import rateLimit from "express-rate-limit" ;
5
6
import path from "path" ;
6
7
import { fileURLToPath } from "url" ;
7
8
import { EverythingAuthProvider } from "./auth/provider.js" ;
@@ -15,6 +16,13 @@ import { logger } from "./utils/logger.js";
15
16
16
17
const app = express ( ) ;
17
18
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
+ } ) ;
18
26
// Get the directory of the current module
19
27
const __filename = fileURLToPath ( import . meta. url ) ;
20
28
const __dirname = path . dirname ( __filename ) ;
@@ -168,7 +176,7 @@ app.get("/mcp-logo.png", (req, res) => {
168
176
} ) ;
169
177
170
178
// Splash page
171
- app . get ( "/" , ( req , res ) => {
179
+ app . get ( "/" , splashLimiter , ( req , res ) => {
172
180
const splashPath = path . join ( __dirname , "static" , "index.html" ) ;
173
181
res . sendFile ( splashPath ) ;
174
182
} ) ;
0 commit comments