fix: rework lifecycle management to optimize cloud deployment#320
fix: rework lifecycle management to optimize cloud deployment#320phernandez merged 1 commit intomainfrom
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>
|
Claude finished @phernandez's task —— View job PR Review: Lifecycle Management OptimizationI've completed my review of this PR against our Basic Memory team checklist. This is a well-architected refactoring that successfully addresses the cloud deployment performance issues while maintaining proper initialization for different deployment modes. Review Checklist Results✅ Code Quality & Standards
|
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