feat: Optimize MCP Server Resource Usage (Phase 1)#79
Merged
mkczarkowski merged 1 commit intomasterfrom Oct 21, 2025
Merged
Conversation
|
✅ All checks have passed successfully!
Coverage reports have been uploaded as artifacts. |
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.
Problem Statement
The MCP server was consuming 90% of the daily Cloudflare Durable
Objects free tier limit (100,000 rows_written), primarily due to:
new Durable Object, triggering 3-4 storage writes during initialization
significant bot/crawler activity
reuse mechanisms
Traffic Stats (Last Month):
Solution - Phase 1 Quick Wins
This PR implements immediate fixes to reduce Durable Object writes by
60-80% through four key optimizations:
Implementation (src/index.ts:43-93):
Expected Impact: Reduce bot traffic by 40-50%
Implementation (src/index.ts:121-132):
Expected Impact: Reduce unnecessary DO creations by 20-30%
Implementation (src/index.ts:96-110, 154-164):
Expected Impact: Reduce malformed requests by 20-30%
Implementation (src/index.ts:166-186):
Documentation (README.md:123-146):
Expected Impact: Reduce new DO creation by 50-70% (for legitimate
clients)
Changes Summary
Modified Files:
validation, session reuse headers
documentation
Key Metrics:
Expected Outcomes
After Phase 1 Deployment:
Performance Improvements:
Testing Recommendations
Manual Testing:
Test health check (should not create DO)
curl https://10x-rules-mcp-server.przeprogramowani.workers.dev/health
Test rate limiting (11th request should fail)
for i in {1..12}; do
curl -s https://10x-rules-mcp-server.przeprogramowani.workers.dev/sse
done
Test request validation (should fail with 406)
curl -H "Accept: text/html"
https://10x-rules-mcp-server.przeprogramowani.workers.dev/sse
Test session reuse headers
curl -I https://10x-rules-mcp-server.przeprogramowani.workers.dev/sse