Repository navigation
fix(mcp): rate-limit requests before token authentication - #782
Merged
Merged
Conversation
Register MCP routes in an encapsulated Fastify rate-limit scope with RATE_LIMIT_MAX_MCP (300 requests/minute by default). Preserve token/org limits and proxy trust, and document the coarse connecting-proxy bucket. Cover missing and invalid credentials, blocked token lookups, scope isolation, and disabled MCP behavior.
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.
Unauthenticated
/mcprequests previously bypassed all Fastify rate-limit scopes, allowing invalid read tokens to trigger unlimited database lookups. Wrap MCP routes in an encapsulated@fastify/rate-limitscope, following the existing app pattern, to address the CodeQLjs/missing-rate-limitingfinding.RATE_LIMIT_MAX_MCP: 300 requests/minute by default, 100,000 in tests unless explicitly overridden.Validation:
pnpm lint: passed (zero warnings).pnpm --filter api build: passed.DATABASE_URL=postgresql://postgres:pg@localhost:55432/ci RUN_DB_INTEGRATION_TESTS=true pnpm --filter api test: 157 files passed, 1 skipped; 1,261 tests passed, 8 skipped. All 35 MCP tests passed, including 3 new tests and 17 real-database integration tests.pnpm --filter api exec tsc --noEmit: 106 existing diagnostics; verified identical against unchanged HEAD.pnpm --filter dashboard exec tsc --noEmit: 6 existing diagnostics; verified identical against unchanged source with incremental caching disabled.git diff --check: passed. CodeQL must be confirmed by PR CI.No merge, release, deployment, production database access, or proxy-trust changes.