{{ message }}
fix: rework lifecycle management to optimize cloud deployment - #320
Merged
Conversation
- MCP CLI initializes file sync then starts clean MCP server - Removed lifecycle complexity from MCP server to prevent recycling overhead - FastAPI app handles full lifecycle when running as web API - Fixes cloud performance issues where MCP recycling caused repeated initialization - Ensures FastAPI properly loads projects from config Performance impact: - Eliminates MCP request overhead in cloud proxy scenarios - Faster response times by removing per-request initialization - Proper project loading in FastAPI web context 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Contributor
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
This PR reworks the lifecycle management architecture to solve critical cloud deployment performance issues while maintaining proper initialization for different deployment modes.
Problems Solved
1. MCP Recycling Overhead in Cloud
Issue: In cloud deployments, MCP gets recycled for every request, causing the
app_lifespanto run repeatedlyinitialize_app()running on every requestSolution: Removed all lifecycle complexity from MCP server
2. FastAPI Not Loading Projects
Issue: FastAPI app wasn't properly calling
initialize_app()Solution: FastAPI explicitly handles full lifecycle
initialize_app(app_config)call in FastAPI lifespanArchitecture Changes
MCP CLI Command (
mcp.py)initialize_file_sync()to set up file watchingMCP Server (
server.py)app_lifespancompletelyFastAPI App (
app.py)initialize_app()call ensures project loadingDeployment Mode Optimization
MCP CLI Mode:
FastAPI Mode:
Cloud Proxy Mode:
Performance Impact
Testing
This change should resolve the cloud performance issues identified in recent deployments.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com