pub struct ToolHost { /* private fields */ }Expand description
A bound loopback MCP endpoint. Cheap to clone.
Implementations§
Source§impl ToolHost
impl ToolHost
Sourcepub async fn bind(config: ToolHostConfig) -> Result<Self, RunnerError>
pub async fn bind(config: ToolHostConfig) -> Result<Self, RunnerError>
Bind and start serving.
Returns only once the listener is accepting, so Self::local_addr is
valid the instant this returns — there is no window where a session’s
mcpServers entry names a port nothing answers on.
§Errors
Returns RunnerError when the bind fails.
Sourcepub fn local_addr(&self) -> SocketAddr
pub fn local_addr(&self) -> SocketAddr
The bound address, with the kernel-assigned port resolved.
Sourcepub fn open_session(&self, surface: Arc<dyn ToolSurface>) -> ToolSession
pub fn open_session(&self, surface: Arc<dyn ToolSurface>) -> ToolSession
Open a turn-scoped session served by surface.
The returned guard owns the session’s lifetime. Hold it for exactly as long as the turn may legitimately call tools.
Sourcepub fn open_sessions(&self) -> usize
pub fn open_sessions(&self) -> usize
Live sessions. A floor that keeps rising is a leaked guard.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolHost
impl RefUnwindSafe for ToolHost
impl Send for ToolHost
impl Sync for ToolHost
impl Unpin for ToolHost
impl UnsafeUnpin for ToolHost
impl UnwindSafe for ToolHost
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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> ⓘ
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