The MCP & API Gateway component serves as the primary interface for external communication, exposing agent capabilities and workflows via the Model Context Protocol (MCP) and managing connections to other MCP servers. It provides the necessary server-side infrastructure for remote access and interaction.This component is fundamental to the MCP & API Gateway subsystem because it collectively manages the entire lifecycle of external communication and capability exposure, aligning with the project’s ‘AI Agent Framework/Orchestration Platform’ nature.
The MCPAggregator is a core component responsible for discovering and consolidating capabilities (tools, prompts, and resources) from multiple MCP servers. It acts as a central point for an agent to access and invoke functionalities provided by various remote or local MCP services. It manages persistent connections to servers and provides methods for listing, reading, and calling these aggregated capabilities.Implementation Details:
The ServerRegistry is responsible for managing the configuration and initialization of MCP servers. It loads server configurations from a YAML file, registers initialization hooks, and provides methods to start and initialize server processes based on their defined transport (stdio, streamable HTTP, SSE, websocket). It acts as a directory of available MCP servers.Implementation Details:
The ServerContext provides the operational context for the MCP application server. It holds references to the FastMCP instance (the FastAPI application for MCP), manages active agents, and initializes the appropriate workflow registry (either InMemoryWorkflowRegistry for asyncio or TemporalWorkflowRegistry for Temporal.io). It also facilitates the registration of workflows and the creation of workflow-specific tools.Implementation Details:
The MCPConnectionManager is responsible for establishing, maintaining, and closing connections to various MCP servers. It handles the underlying communication protocols and ensures reliable data exchange between the MCPAggregator and the remote MCP services.Implementation Details:
MCPServerSettings defines the configuration parameters for individual MCP servers, including their transport type (e.g., stdio, http, websocket), host, port, and other connection-related details. It is a foundational data structure for setting up and connecting to MCP services.Implementation Details:
The MCP & API Gateway architecture provides several key benefits:
Unified Interface: The MCPAggregator consolidates capabilities from disparate MCP servers into a single, unified interface for agents, abstracting away connection complexities.
Multi-Transport Support: The ServerRegistry supports multiple transport protocols (stdio, HTTP, SSE, WebSocket), enabling flexible deployment and integration scenarios.
Scalable Architecture: The separation of concerns between configuration (MCPServerSettings), registry (ServerRegistry), connection management (MCPConnectionManager), and aggregation (MCPAggregator) enables scalable and maintainable architecture.
Runtime Flexibility: The ServerContext provides runtime environment management, supporting both asyncio and Temporal.io execution models.
External Integration: The component enables seamless integration with external MCP-compliant services, supporting the ‘Multi-Agent Coordination Mechanisms’ and ‘Tool Use Frameworks’ aspects of the platform.