pub struct McpServerManager { /* private fields */ }Expand description
Manages the lifecycle of one or more MCP servers and their tools.
Call McpServerManager::register_all to spawn every configured server,
discover its tools, and register them into a ToolRegistry. The manager
keeps the underlying McpClients alive so they can handle tool calls.
Implementations§
Source§impl McpServerManager
impl McpServerManager
Sourcepub fn new(servers: Vec<McpServer>) -> Self
pub fn new(servers: Vec<McpServer>) -> Self
Create a new manager from a list of server configurations.
The servers are not spawned until register_all is called.
Sourcepub async fn register_all(
&self,
registry: &mut ToolRegistry,
) -> Result<Vec<(String, usize)>>
pub async fn register_all( &self, registry: &mut ToolRegistry, ) -> Result<Vec<(String, usize)>>
Spawn all configured servers, discover their tools, and register them
into the given ToolRegistry.
Returns a list of (server_name, tool_count) pairs for logging.
§Errors
Returns an error if any server fails to start or if tool discovery fails. Servers are started sequentially; a failure stops the process.
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Shut down all running MCP clients.
This drops the clients, which causes their background tasks (stdio reader/writer, SSE listener) to be cancelled.
Sourcepub async fn running_count(&self) -> usize
pub async fn running_count(&self) -> usize
Return the number of currently running clients.
Auto Trait Implementations§
impl !Freeze for McpServerManager
impl !RefUnwindSafe for McpServerManager
impl !UnwindSafe for McpServerManager
impl Send for McpServerManager
impl Sync for McpServerManager
impl Unpin for McpServerManager
impl UnsafeUnpin for McpServerManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more