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
impl McpToolSet
Sourcepub async fn load(project_root: &Path) -> Self
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.
Sourcepub async fn load_at(global_path: &Path, project_root: &Path) -> Self
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.
Sourcepub async fn load_within(
global_path: &Path,
project_root: &Path,
budget: Duration,
) -> Self
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.
Sourcepub fn diagnostics(&self) -> &McpDiagnostics
pub fn diagnostics(&self) -> &McpDiagnostics
What this run should say about its MCP configuration.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for McpToolSet
impl !UnwindSafe for McpToolSet
impl Freeze for McpToolSet
impl Send for McpToolSet
impl Sync for McpToolSet
impl Unpin for McpToolSet
impl UnsafeUnpin for McpToolSet
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
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