CelestoMCPHub
CelestoMCPHub is a context manager that provides access to Celesto AI’s MCP Hub, which aggregates multiple MCP servers and their tools into a single endpoint.
Class Definition
Constructor
Timeout in seconds for MCP requests
Maximum number of retry attempts for failed requests
Whether to cache the list of available tools
Celesto AI API key. If not provided, reads from environment variable or config.
Usage
CelestoMCPHub is designed to be used as an async context manager with the async with statement:
__aenter__: Connects to the MCP Hub and returns anMCPServerStreamableHttpinstance__aexit__: Cleans up the connection when exiting the context
Example Usage
Basic Usage with Agent
Custom Configuration
Multiple Agents with Shared Hub
Configuration
API Key
The API key can be provided in three ways (in order of precedence):-
Constructor parameter:
-
Environment variable:
-
Configuration file:
The API key is read from
celesto_config.api_key
ValueError is raised.
Connection Parameters
The hub connects to the Celesto AI MCP endpoint with the following settings:- URL:
{celesto_config.base_url}/mcp - Authentication: Bearer token using the provided API key
- Headers:
Authorization: Bearer {api_key}
Error Handling
Under the Hood
When you useCelestoMCPHub, it:
- Creates an
MCPServerStreamableHttpinstance with the Celesto AI MCP endpoint - Connects to the hub during
__aenter__ - Returns the connected MCP server instance for use as a tool
- Automatically cleans up the connection during
__aexit__
See Also
- LiteMCP - Create your own MCP server
- MCPAPIRouter - Router for MCP JSON-RPC methods
