Skip to main content

HubConnections

Struct HubConnections 

Source
pub struct HubConnections { /* private fields */ }
Expand description

Managed hub connections with shared infrastructure.

Implementations§

Source§

impl HubConnections

Source

pub fn new() -> Self

Create a new connection manager.

Source

pub async fn connect( &self, config: McpServerConnectionConfig, ) -> Result<Arc<ManagedConnection>, McpTransportError>

Establish a connection to a server.

Source

pub async fn establish_connection( &self, conn: &ManagedConnection, ) -> Result<(), McpTransportError>

Establish or re-establish a connection.

Source

pub fn get(&self, server_name: &str) -> Option<Arc<ManagedConnection>>

Get a connection by server name.

Source

pub fn remove(&self, server_name: &str) -> Option<Arc<ManagedConnection>>

Remove a connection.

Source

pub fn server_for_tool(&self, tool_name: &str) -> Option<String>

Get server name for a tool.

Source

pub fn get_tool_definition(&self, tool_name: &str) -> Option<McpToolDefinition>

Get tool definition by name.

Source

pub fn list_servers(&self) -> Vec<String>

List all server names.

Source

pub fn list_tools(&self) -> Vec<(String, McpToolDefinition)>

List all tools with their server names.

Source

pub fn list_tool_definitions(&self) -> Vec<McpToolDefinition>

List all tool definitions.

Source

pub fn is_connected(&self, server_name: &str) -> bool

Check if a server is connected.

Source

pub fn clear_tools_for_server(&self, server_name: &str)

Clear tool cache for a server.

Source

pub fn clear(&self)

Clear all connections and tool cache.

Source

pub fn iter( &self, ) -> impl Iterator<Item = (String, Arc<ManagedConnection>)> + '_

Iterate over all connections.

Source

pub async fn call_tool( &self, name: &str, args: Value, ) -> Result<Value, McpTransportError>

Call a tool with circuit breaker and failure handling.

Source

pub async fn discover_tools_parallel( &self, timeout: Duration, ) -> Result<Vec<(String, McpToolDefinition)>, McpTransportError>

Discover tools from all servers in parallel.

This is much faster than sequential discovery when connecting to many servers.

Source

pub async fn refresh_tools_parallel( &self, timeout: Duration, ) -> Result<(), McpTransportError>

Refresh tool cache from all servers in parallel.

Source

pub async fn health_check(&self) -> Vec<(String, bool)>

Get health status of all servers.

Source

pub fn circuit_breaker_stats( &self, server_name: &str, ) -> Option<CircuitBreakerStats>

Get circuit breaker statistics for a server.

Source

pub fn reset_circuit_breaker(&self, server_name: &str)

Reset circuit breaker for a server.

Trait Implementations§

Source§

impl Default for HubConnections

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more