Transform SyllabusMCP to Distributed Microservices Architecture#5
Open
Transform SyllabusMCP to Distributed Microservices Architecture#5
Conversation
- Add FastAPI, httpx, uvicorn dependencies to pyproject.toml - Create services/shared/models.py with Pydantic versions of dataclass models - Set up infrastructure for microservices architecture - Prepare for HTTP-based service communication
- Create FastAPI service at services/syllabus_service/app.py - Add /parse-syllabus and /answer-question endpoints - Configure 5min timeout for parsing, 2min for questions - Create HTTP client wrapper at mcp_wrappers/syllabus/mcp_service.py - Maintain existing MCP tool signatures while routing to HTTP service - Add comprehensive test suite with mock service testing - Handle long LLM operations with appropriate timeouts
- Create FastAPI service at services/academic_planner_service/app.py - Add /create-plan and /assignment-summary endpoints - Configure 5min timeout for plan creation, 30sec for summaries - Create HTTP client wrapper at mcp_wrappers/academic_planner/mcp_service.py - Handle AI-powered academic planning with extended timeouts - Maintain compatibility with existing academic planner functionality - Add Docker containerization support
- Create FastAPI service at services/productivity_service/app.py - Implement 8 endpoints: calendar/reminder CRUD + bulk operations - Add fast 30-second timeouts optimized for CRUD operations - Create HTTP client wrapper at mcp_wrappers/productivity/mcp_service.py - Support both individual and bulk operations for events/reminders - Include formatted display endpoints for rich console output - Maintain in-memory storage with structured data models - Add Docker containerization with health checks
- Implement mcp_gateway/server.py as single entry point for all tools - Import raw functions from all HTTP wrappers and re-register with FastMCP - Provide unified interface with 14 tools across 3 distributed services - Add service status and tool discovery functionality - Enable clean orchestrator integration: single import gives access to all tools - Maintain backward compatibility with existing MCP interfaces - Support both development and production deployment patterns
- Create docker-compose.yml with 3 services and proper networking - Configure health checks for all services with /health endpoints - Add .env.example for environment variable configuration - Create .dockerignore for optimized Docker builds - Add comprehensive DOCKER_DEPLOYMENT.md guide - Enable production-ready containerized deployment - Support service scaling and health monitoring - Include security best practices in Dockerfiles
- Create orchestrator/shared.py to eliminate code duplication - Update registry to route all services through unified MCP Gateway - Modify orchestrator/run.py to use async MCP Gateway functions - Update orchestrator/run_agent.py for shared module integration - Maintain full backward compatibility with existing workflows - Enable orchestrator to work seamlessly with distributed architecture - Add proper async/await patterns throughout orchestrator - Complete the transformation: monolithic -> distributed architecture
- Completely rewrite README.md for distributed deployment focus - Add comprehensive Mermaid architecture diagram showing all layers - Update all examples to reflect Docker-first deployment approach - Emphasize production features: scaling, health checks, monitoring - Document microservices architecture with 14 available tools - Add educational context for CMU 17-625 API Design course - Include deployment options and production considerations - Complete transformation: monolithic documentation -> distributed system guide
9b37a73 to
7573c57
Compare
- Add support for sending PDF content as base64 in API requests - Allows Docker services to process PDFs without filesystem access - Falls back to URL/path handling for remote PDFs - Implement answer_question_about_syllabi tool for comparing multiple syllabi - New FastAPI endpoint for multi-syllabus questions - MCP wrapper function for cross-syllabus comparisons - Add extract_pdf_pages_from_content() for in-memory PDF processing Fixes file not found errors when orchestrator communicates with syllabus service running in Docker container.
- Import and expose answer_question_about_syllabi tool in MCP gateway - Add tool to registry service mapping under syllabus_server - Update orchestrator prompt to guide LLM to use multi-syllabus tool for comparison/consolidation questions - Add tool to gateway's list_available_tools output This enables the orchestrator to efficiently answer questions that compare or consolidate information across multiple syllabi using a single LLM call instead of separate calls per syllabus.
Load environment variables from .env file in orchestrator/shared.py to support local development configuration.
- Rename 'Client Layer' to 'Orchestration Layer' for clarity - Remove Infrastructure subgraph (Docker Compose and Health Monitoring) - Clean up diagram to focus on application architecture layers - Update class definitions to match renamed layer
- Added new 'exec' subcommand to run_agent CLI that allows executing specific MCP tools directly - Supports tools with or without arguments (JSON format via --args flag) - Useful for quickly testing tools like show_reminders and show_calendar_events - Updated README with examples of using the exec command
- Updated README.md architecture diagram with new endpoint paths - Updated README.md service descriptions and curl examples - Updated DOCKER_DEPLOYMENT.md with new endpoint documentation - Updated DISTRIBUTED_IMPLEMENTATION_PLAN.md with current endpoint structure - Updated test_syllabus_service.py to test new endpoints - Updated services/syllabus_service/mock_app.py with new routes All documentation now consistent with the REST API changes: - Syllabus: /syllabus:parse, /syllabus/qa, /syllabi/qa - Academic Planner: /academics/plan, /academics/assignments - Productivity: /calendar/event, /reminders/reminder, etc.
- Replace sync OpenAI client with AsyncOpenAI in all services - Enables true parallel processing of LLM requests - Prevents serialization bottleneck when multiple requests arrive - Services affected: syllabus, academic_planner, productivity
- Configure uvicorn with --workers 4 flag in Dockerfile - Allows handling 4 simultaneous PDF parsing requests - Prevents request queuing when parsing multiple syllabi in parallel
- Replace httpx.Client with requests library for better asyncio.to_thread() compatibility - Add detailed timing logs to track request flow and identify bottlenecks - Increase academic planner timeout from 300s to 600s - Fixes timeout issues when running parallel HTTP requests from asyncio threads This resolves the issue where only some requests would complete when 4 PDFs were parsed in parallel, as httpx had event loop conflicts when used inside asyncio.to_thread().
* Expose MCP wrapper instances for registry discovery Co-Authored-By: Warp <agent@warp.dev> * Load MCP servers dynamically from wrapper modules Co-Authored-By: Warp <agent@warp.dev> * Split syllabus parsing into extract and structure stages Co-Authored-By: Warp <agent@warp.dev> * Skip PDF extract test when fixture file is missing Co-Authored-By: Warp <agent@warp.dev> --------- Co-authored-by: Warp <agent@warp.dev>
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.
Convert SyllabusMCP to Distributed Microservices Architecture
Problem Statement
The current SyllabusMCP system uses FastMCP to provide all services through a single interface. We need to convert this to a distributed microservices architecture where:
Current Architecture
The system currently has three main service components:
parse_syllabus()andanswer_syllabus_question()tools via FastMCPcreate_academic_plan()andshow_assignment_summary()tools via FastMCPAll services currently use FastMCP decorators and run as MCP servers.
Proposed Architecture
Service Layer (REST APIs)
Each service becomes an independent FastAPI-based REST service:
MCP Interface Layer
New MCP wrapper services that maintain the existing tool signatures:
Container Infrastructure
Docker containers for each service:
Implementation Progress
✅ Phase 1: Create REST Service Framework
services/syllabus_service/directoryservices/academic_planner_service/directoryservices/productivity_service/directoryservices/shared/models.py) to ensure consistent data structures across services✅ Phase 2: Convert Syllabus Server
services/syllabus_service/app.py):syllabus_server/server.pyPOST /parse-syllabus(accepts{"pdf_path_or_url": str}, returnsParsedSyllabus)POST /answer-question(accepts{"syllabus_data": ParsedSyllabus, "question": str}, returns{"answer": str})mcp/syllabus/mcp_service.py):parse_syllabus()andanswer_syllabus_question()with identical signatureshttpxto make REST calls to the syllabus service with extended timeouts (5min parse, 2min questions)ParsedSyllabusobjects✅ TESTING COMPLETED:
✅ Phase 3: Convert Academic Planner Service
services/academic_planner_service/app.py):academic_planner/server.pyPOST /create-plan(accepts{"syllabi": list[ParsedSyllabus]}, returnsPlan)POST /show-assignment-summary(accepts{"plan": Plan}, returns{"summary": str})mcp_wrappers/academic_planner/mcp_service.py):create_academic_plan()andshow_assignment_summary()with identical signatureshttpxto make REST calls with extended timeouts (5min create, 30sec summary)Planobjects✅ Phase 4: Convert Productivity Service
services/productivity_service/app.py):productivity_server/server.pymcp_wrappers/productivity/mcp_service.py):httpxwith standard 30-second timeouts (fast operations)CalendarEventandReminderobjects✅ Phase 5: Create MCP Gateway
mcp_gateway/server.py):✅ Phase 6: Docker Compose & Configuration
🔄 Phase 7: Update Orchestrator
Key Design Decisions
Data Serialization
Service Communication
httpxfor HTTP client calls from MCP wrappers to REST servicesBackward Compatibility
Service Independence
Files to Modify/Create
New Files
services/syllabus_service/app.pyservices/syllabus_service/mock_app.py(for testing)services/academic_planner_service/app.pyservices/productivity_service/app.pyservices/shared/models.pymcp_wrappers/syllabus/mcp_service.py(renamed to avoid conflicts)test_syllabus_service.py(comprehensive test suite)mcp_wrappers/academic_planner/mcp_service.pymcp_wrappers/productivity/mcp_service.pymcp_gateway/server.pydocker-compose.ymlservices/syllabus_service/Dockerfileservices/academic_planner_service/Dockerfileservices/productivity_service/Dockerfilemcp_gateway/Dockerfile.dockerignore.env.exampleDOCKER_DEPLOYMENT.mdFiles to Modify
pyproject.toml- Add FastAPI, httpx dependenciesLegend