Skip to main content

McpToolSet

Struct McpToolSet 

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

Every MCP tool a task run can dispatch, plus why any server is missing.

Why: the lifecycle is per-RUN, not per-registry. A RegistryFactory builds a fresh registry for each delegation, and spawning the operator’s servers again on each of those would multiply child processes and startup latency for no gain. Loading once and sharing Arcs keeps the spawn off every hot path, and — because each tool holds its server’s client handle — keeps the children alive for exactly as long as something can call them. What: construct with McpToolSet::load, then hand it to register_configured_tools at each registry site. Test: tests::set_tests, mcp_loader_e2e::end_to_end_dispatch_echoes_through_the_registry.

Implementations§

Source§

impl McpToolSet

Source

pub async fn load(project_root: &Path) -> Self

Resolve, spawn and discover, against the live global config path.

Why: the production entry point. A home directory that does not resolve is a configuration problem, not a fatal one, so it becomes an empty set rather than an error a task run has to handle. What: delegates to McpToolSet::load_at with trusty_mcp::config::default_path(). Under a cargo test harness it loads NOTHING: this is the one path that reads the OPERATOR’s real servers.toml, and honouring it from a test run would spawn their actual daemons as a side effect of cargo test — the production-state mutation trusty_common::running_under_test_harness exists to refuse (#4255). A test that wants a real server injects its own config through McpToolSet::load_at. Test: tests::set_tests::the_live_path_loads_nothing_under_a_test_harness; mcp_loader_e2e::end_to_end_dispatch_echoes_through_the_registry covers the real transport through load_at.

Source

pub async fn load_at(global_path: &Path, project_root: &Path) -> Self

McpToolSet::load with both tier locations injected.

Why: every test points this at a tempdir, so no test run can read — or spawn anything named by — the developer’s real configuration. What: resolves both tiers, then attempts each usable server INDEPENDENTLY. A server that fails to connect downgrades its own status and contributes no tools; it never affects another server or the run. A tool whose composed name is already taken within this set, or whose schema is over the cap, is skipped with an issue rather than silently shadowing or bloating the surface. Test: tests::set_tests::a_failed_server_does_not_stop_the_others, mcp_loader_e2e::spawn_failure_isolates_the_healthy_server.

Source

pub async fn load_within( global_path: &Path, project_root: &Path, budget: Duration, ) -> Self

McpToolSet::load_at with the per-server startup bound supplied.

Why: budget is per SERVER, and the servers are connected CONCURRENTLY — sequentially, N wedged connectors would cost N × the bound at task startup, so the worst case grew with the operator’s config. Injecting the bound is what lets a test prove that in a second or two instead of waiting out two real timeouts. What: futures_util::future::join_all preserves its input’s order, so the results are applied in CONFIG order and statuses/tools stay deterministic regardless of which server answered first. Test: mcp_loader_e2e::a_hung_server_does_not_serialise_its_siblings, tests::set_tests::a_failed_server_does_not_stop_the_others.

Source

pub fn diagnostics(&self) -> &McpDiagnostics

What this run should say about its MCP configuration.

Source

pub fn is_empty(&self) -> bool

Whether any tool was loaded at all.

Trait Implementations§

Source§

impl Default for McpToolSet

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

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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 = !

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

fn try_from(value: U) -> Result<T, !>

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