core.server_context
Server Context - Dependency Injection Container Manages all server dependencies and eliminates global state
Classes
|
Centralized dependency injection container for the MCP server. |
- class core.server_context.ServerContext(config_manager=None)[source]
Bases:
objectCentralized dependency injection container for the MCP server.
This class manages all server dependencies including configuration, pipelines, and session management, eliminating global state.
- property config_manager: ConfigManager
Get the configuration manager, creating it if needed.
- property rag_pipeline: RAGPipeline | None
Get the RAG pipeline.
- property session_manager: ChatSessionManager
Get the session manager, creating it if needed.
- initialize()[source]
Initialize all server components in the correct dependency order.
This method implements a multi-phase initialization strategy: 1. Guard check: Prevent duplicate initialization 2. Core pipeline setup: Create document processing pipeline 3. Processor loading: Dynamically load and configure document processors 4. RAG pipeline setup: Initialize retrieval-augmented generation capabilities 5. Validation: Ensure all components are properly initialized
The initialization order is critical: - Document pipeline must exist before processors are loaded - Processors must be loaded before RAG pipeline initialization - RAG pipeline depends on document processing capabilities
This method should be called once during server startup to ensure all dependencies are properly configured and connected.
- Raises:
Exception – If any component fails to initialize properly