Merged
Conversation
- Moved inline CSS to external stylesheet to comply with CSP - Added black background to logo area for visibility of white MCP logo - Updated specification link to point to dated version (2025-06-18) - Changed "MCP Everything Server" to "MCP Example Server" - Added route to serve styles.css file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Comment on lines
+170
to
+174
| app.get("/styles.css", (req, res) => { | ||
| const cssPath = path.join(__dirname, "static", "styles.css"); | ||
| res.setHeader('Content-Type', 'text/css'); | ||
| res.sendFile(cssPath); | ||
| }); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 7 months ago
To address the missing rate limiting in the /styles.css route handler at line 170, we should apply a rate-limiting middleware to restrict how frequently a client can request this resource. The simplest way is to use the popular express-rate-limit package, which is well maintained and purpose-built for this scenario. We'll need to:
- Import
express-rate-limit - Create a rate limiter instance, e.g., 100 requests per 15 minutes per IP (similar to the background example).
- Apply the rate limiter as middleware for the
/styles.cssroute (at line 170) before the handler.
Changes to make:
- Add a new import for
express-rate-limitat the top. - Define a rate limiting middleware before route handlers.
- Apply it directly to the
/styles.cssroute.
No other changes are needed, and we should not interfere with any existing functionality for other routes.
Suggested changeset
2
src/index.ts
| @@ -3,6 +3,7 @@ | ||
| import cors from "cors"; | ||
| import express from "express"; | ||
| import path from "path"; | ||
| import rateLimit from "express-rate-limit"; | ||
| import { fileURLToPath } from "url"; | ||
| import { EverythingAuthProvider } from "./auth/provider.js"; | ||
| import { BASE_URI, PORT } from "./config.js"; | ||
| @@ -15,6 +16,11 @@ | ||
|
|
||
| const app = express(); | ||
|
|
||
| // Set up rate limiter for static assets: max 100 requests per 15 minutes per IP | ||
| const staticAssetLimiter = rateLimit({ | ||
| windowMs: 15 * 60 * 1000, // 15 minutes | ||
| max: 100, // limit each IP to 100 requests per windowMs | ||
| }); | ||
| // Get the directory of the current module | ||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
| @@ -167,7 +173,7 @@ | ||
| res.sendFile(logoPath); | ||
| }); | ||
|
|
||
| app.get("/styles.css", (req, res) => { | ||
| app.get("/styles.css", staticAssetLimiter, (req, res) => { | ||
| const cssPath = path.join(__dirname, "static", "styles.css"); | ||
| res.setHeader('Content-Type', 'text/css'); | ||
| res.sendFile(cssPath); |
package.json
Outside changed files
| @@ -32,7 +32,8 @@ | ||
| "cors": "^2.8.5", | ||
| "dotenv": "^16.4.7", | ||
| "express": "^4.21.2", | ||
| "raw-body": "^3.0.0" | ||
| "raw-body": "^3.0.0", | ||
| "express-rate-limit": "^8.0.1" | ||
| }, | ||
| "overrides": { | ||
| "@types/express": "^5.0.0", |
This fix introduces these dependencies
| Package | Version | Security advisories |
| express-rate-limit (npm) | 8.0.1 | None |
Copilot is powered by AI and may make mistakes. Always verify output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
index.htmlto newstyles.cssfileindex.tsto serve the CSS file with proper content-type/specification/2025-06-18Test plan
npm run buildnpm start🤖 Generated with Claude Code