Skip to main content

ToolRegistry

Struct ToolRegistry 

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

Central registry mapping tool names to their trait-based handlers. Every tool is trait-based and resolved here; the earlier match-cascade dispatch has been fully retired.

Handlers are stored behind Arc (not Box) so the dispatch layer can hand an owned, 'static handle to tokio::task::spawn_blocking. That lets a blocking handler run on the dedicated blocking pool under a watchdog deadline instead of pinning a scarce core worker via block_in_place (#271 — a hung handler must never swallow the JSON-RPC response).

Implementations§

Source§

impl ToolRegistry

Source

pub fn new() -> Self

Source

pub fn register(&mut self, tool: Box<dyn McpTool>)

Source

pub fn get(&self, name: &str) -> Option<&dyn McpTool>

Source

pub fn get_arc(&self, name: &str) -> Option<Arc<dyn McpTool>>

Clone an owned, 'static handle to a registered tool.

Unlike get, the returned Arc can be moved into spawn_blocking, so the dispatch layer can execute the (synchronous) handler off the async core workers under a watchdog (#271).

Source

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

Source

pub fn static_name(&self, name: &str) -> Option<&'static str>

The registry’s own 'static key for name, if it is a registered tool. Telemetry counts per tool only under these keys, so a caller-supplied string never reaches a counter.

Source

pub fn tool_defs(&self) -> Vec<Tool>

Returns MCP Tool definitions in the official public surface.

Deprecated aliases and local-only collaboration compatibility tools remain callable through dispatch but are neither published nor counted as official tools. Applies MCP ToolAnnotations (readOnlyHint, destructiveHint) so clients can make informed decisions about tool usage in restricted contexts.

Source

pub fn registered_tool_defs(&self) -> Vec<Tool>

Returns MCP Tool definitions for every registered tool, including deprecated aliases and local-only compatibility substrate. Used by callability and schema checks that cover the full registry.

Source

pub fn active_tool_defs(&self) -> Vec<Tool>

Returns tool definitions filtered by the dynamic tool state. Only includes tools whose category is currently active.

Source

pub fn profile_tool_defs(&self, profile: &ToolProfile) -> Vec<Tool>

Returns tool definitions filtered by a tool profile. Only includes tools whose name is enabled by the given profile.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn names(&self) -> Vec<&'static str>

Trait Implementations§

Source§

impl Default for ToolRegistry

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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<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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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