Skip to main content

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
int
default:"10"
Timeout in seconds for MCP requests
max_retry_attempts
int
default:"3"
Maximum number of retry attempts for failed requests
cache_tools_list
bool
default:"true"
Whether to cache the list of available tools
api_key
str
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:
The context manager handles connection and cleanup automatically:
  • __aenter__: Connects to the MCP Hub and returns an MCPServerStreamableHttp instance
  • __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):
  1. Constructor parameter:
  2. Environment variable:
  3. Configuration file: The API key is read from celesto_config.api_key
If no API key is found, a 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 use CelestoMCPHub, it:
  1. Creates an MCPServerStreamableHttp instance with the Celesto AI MCP endpoint
  2. Connects to the hub during __aenter__
  3. Returns the connected MCP server instance for use as a tool
  4. Automatically cleans up the connection during __aexit__
The hub provides access to all tools registered across multiple MCP servers hosted by Celesto AI, allowing agents to use a wide range of capabilities through a single integration.

See Also

Last modified on May 5, 2026