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
int
default:"10"
Timeout in seconds for MCP requests
int
default:"3"
Accepted for backwards compatibility. The MCP client does not retry, so this has no effect.
bool
default:"true"
Accepted for backwards compatibility. Tools are listed once per connection, so this has no effect.
str
Celesto AI API key. If not provided, reads from the
CELESTO_API_KEY environment variable. Raises ValueError when neither is set.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 anMCPServerinstance__aexit__: Cleans up the connection when exiting the context
Connect and exit on the same event loop — put the whole
async with block inside one asyncio.run().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
MCPServerpointed at{CELESTO_BASE_URL}/mcpwith a bearer token header - Connects to the hub during
__aenter__ - Returns the 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
