Skip to main content

McpRegistry

Struct McpRegistry 

pub struct McpRegistry { /* private fields */ }
Expand description

Registry of all connected MCP servers, with a flat tool index.

Implementations§

Source§

impl McpRegistry

Source

pub async fn connect_all(configs: &[McpServerConfig]) -> Result<Self>

Connect to all configured servers. Non-fatal: failures are logged and skipped.

Source

pub fn server_handles(&self) -> Vec<(String, McpServer)>

Snapshot the live (server_name, McpServer) pairs registered in this registry. Returned pairs are sorted by server_name for deterministic ordering across ticks. Each McpServer is a cheap Arc clone of the registered handle — re-inserting it into another McpRegistry shares the underlying transport (no disconnect, no new stdio child).

Used by the daemon heartbeat’s additive reconciliation layer to preserve a healthy live connection across recovery ticks: when current has a healthy server whose identity still matches fresh, the daemon re-uses that handle instead of forcing connect_all to spawn a duplicate stdio child for the same endpoint.

Source

pub async fn from_servers(servers: Vec<McpServer>) -> Self

Build a new registry from a list of pre-existing McpServer handles. The handles are cheaply Arc-cloned; transports remain alive across the move. The internal tool_index and server_index are rebuilt from each handle’s advertised capabilities (synchronous tools() call).

Companion to Self::server_handles: callers wanting to carry a healthy live connection into a fresh registry (the additive recovery path) read the handle via server_handles and rebuild via from_servers.

Source

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

All prefixed tool names across all connected servers.

Source

pub async fn get_tool_def(&self, prefixed_name: &str) -> Option<McpToolDef>

Tool definition for a given prefixed name (cloned).

Source

pub async fn call_tool( &self, prefixed_name: &str, arguments: Value, ) -> Result<String>

Execute a tool by prefixed name.

Source

pub fn is_empty(&self) -> bool

Source

pub fn server_count(&self) -> usize

Source

pub fn tool_count(&self) -> usize

Source

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

Names of all connected servers.

Source

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

Check health of every connected server. Returns names of dead servers.

Source

pub async fn kill_dead_connections(&mut self) -> Vec<String>

Remove servers whose transport is dead. Returns the names of servers that were removed.

This is a no-op for the for_test_with_server_count registries used in unit tests — those have no-op transports that always report alive, so no server will ever be removed.

Source

pub fn split_prefixed(prefixed: &str) -> Option<(String, String)>

Split a <server>__<rest> prefixed name. Returns None if no prefix.

Source

pub async fn server_supports_resources(&self, name: &str) -> bool

Whether the named server advertised resource capability.

Source

pub async fn server_supports_prompts(&self, name: &str) -> bool

Whether the named server advertised prompt capability.

Source

pub async fn read_resource( &self, prefixed_uri: &str, ) -> Result<McpResourceContents>

Read a resource by prefixed uri (<server>__<uri>).

Source

pub async fn get_prompt( &self, prefixed_name: &str, arguments: Value, ) -> Result<McpGetPromptResult>

Get a prompt by prefixed name (<server>__<name>).

Source

pub async fn list_server_resources( &self, server: &str, cursor: Option<String>, ) -> Result<(Vec<McpResourceDef>, Option<String>)>

List one server’s resources with optional pagination cursor. Returns the prefixed defs and the server’s next_cursor (if any). The cursor is the opaque token from a prior page’s next_cursor for this same server.

Source

pub async fn list_server_prompts( &self, server: &str, cursor: Option<String>, ) -> Result<(Vec<McpPromptDef>, Option<String>)>

List one server’s prompts with optional pagination cursor. Returns the prefixed defs and the server’s next_cursor (if any).

Source

pub async fn list_all_resources(&self) -> Vec<(String, McpResourceDef)>

List resources across all servers that support them. Each entry’s uri is returned prefixed with <server>__. Per-server errors are skipped.

Source

pub async fn list_all_prompts(&self) -> Vec<(String, McpPromptDef)>

List prompts across all servers that support them, prefixed by server.

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,