Skip to main content

McpToolRegistry

Struct McpToolRegistry 

Source
pub struct McpToolRegistry<Counterpart: Role> { /* private fields */ }
Expand description

Runtime-neutral registry for MCP tools.

Implementations§

Source§

impl<Counterpart: Role> McpToolRegistry<Counterpart>

Source

pub fn set_instructions(&mut self, instructions: impl ToString)

Set the server instructions that are provided to the client.

Source

pub fn instructions(&self) -> Option<&str>

Server instructions provided to the client.

Source

pub fn register_tool(&mut self, tool: impl McpTool<Counterpart> + 'static)

Register a tool.

Source

pub fn tools(&self) -> impl Iterator<Item = &RegisteredMcpTool<Counterpart>>

Return all registered tools in registration order.

Source

pub fn enabled_tools( &self, ) -> impl Iterator<Item = &RegisteredMcpTool<Counterpart>>

Return enabled registered tools in registration order.

Source

pub fn tool(&self, name: &str) -> Option<&RegisteredMcpTool<Counterpart>>

Return a registered tool by name, even if it is disabled.

Source

pub fn enabled_tool( &self, name: &str, ) -> Option<&RegisteredMcpTool<Counterpart>>

Return an enabled tool by name.

Source

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

Check whether a tool is registered.

Source

pub fn disable_all_tools(&mut self)

Disable all tools. After calling this, only tools explicitly enabled with enable_tool will be available.

Source

pub fn enable_all_tools(&mut self)

Enable all tools. After calling this, all tools will be available except those explicitly disabled with disable_tool.

Source

pub fn disable_tool(&mut self, name: &str) -> Result<(), Error>

Disable a specific tool by name.

Returns an error if the tool is not registered.

Source

pub fn enable_tool(&mut self, name: &str) -> Result<(), Error>

Enable a specific tool by name.

Returns an error if the tool is not registered.

Trait Implementations§

Source§

impl<Counterpart: Debug + Role> Debug for McpToolRegistry<Counterpart>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Counterpart: Role> Default for McpToolRegistry<Counterpart>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Counterpart> Freeze for McpToolRegistry<Counterpart>

§

impl<Counterpart> !RefUnwindSafe for McpToolRegistry<Counterpart>

§

impl<Counterpart> Send for McpToolRegistry<Counterpart>

§

impl<Counterpart> Sync for McpToolRegistry<Counterpart>

§

impl<Counterpart> Unpin for McpToolRegistry<Counterpart>

§

impl<Counterpart> UnsafeUnpin for McpToolRegistry<Counterpart>

§

impl<Counterpart> !UnwindSafe for McpToolRegistry<Counterpart>

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

Source§

impl<T> IntoOption<T> for T

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