pub struct McpToolRegistry<Counterpart: Role> { /* private fields */ }schemars only.Expand description
Runtime-neutral registry for MCP tools.
Implementations§
Source§impl<Counterpart: Role> McpToolRegistry<Counterpart>
impl<Counterpart: Role> McpToolRegistry<Counterpart>
Sourcepub fn set_instructions(&mut self, instructions: impl ToString)
pub fn set_instructions(&mut self, instructions: impl ToString)
Set the server instructions that are provided to the client.
Sourcepub fn instructions(&self) -> Option<&str>
pub fn instructions(&self) -> Option<&str>
Server instructions provided to the client.
Sourcepub fn register_tool(&mut self, tool: impl McpTool<Counterpart> + 'static)
pub fn register_tool(&mut self, tool: impl McpTool<Counterpart> + 'static)
Register a tool.
Sourcepub fn tools(&self) -> impl Iterator<Item = &RegisteredMcpTool<Counterpart>>
pub fn tools(&self) -> impl Iterator<Item = &RegisteredMcpTool<Counterpart>>
Return all registered tools in registration order.
Sourcepub fn enabled_tools(
&self,
) -> impl Iterator<Item = &RegisteredMcpTool<Counterpart>>
pub fn enabled_tools( &self, ) -> impl Iterator<Item = &RegisteredMcpTool<Counterpart>>
Return enabled registered tools in registration order.
Sourcepub fn tool(&self, name: &str) -> Option<&RegisteredMcpTool<Counterpart>>
pub fn tool(&self, name: &str) -> Option<&RegisteredMcpTool<Counterpart>>
Return a registered tool by name, even if it is disabled.
Sourcepub fn enabled_tool(
&self,
name: &str,
) -> Option<&RegisteredMcpTool<Counterpart>>
pub fn enabled_tool( &self, name: &str, ) -> Option<&RegisteredMcpTool<Counterpart>>
Return an enabled tool by name.
Sourcepub fn contains_tool(&self, name: &str) -> bool
pub fn contains_tool(&self, name: &str) -> bool
Check whether a tool is registered.
Sourcepub fn disable_all_tools(&mut self)
pub fn disable_all_tools(&mut self)
Disable all tools. After calling this, only tools explicitly enabled
with enable_tool will be available.
Sourcepub fn enable_all_tools(&mut self)
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.
Sourcepub fn disable_tool(&mut self, name: &str) -> Result<(), UnknownToolError>
pub fn disable_tool(&mut self, name: &str) -> Result<(), UnknownToolError>
Disable a specific tool by name.
§Errors
Returns UnknownToolError if no tool with this name is registered.
Sourcepub fn enable_tool(&mut self, name: &str) -> Result<(), UnknownToolError>
pub fn enable_tool(&mut self, name: &str) -> Result<(), UnknownToolError>
Enable a specific tool by name.
§Errors
Returns UnknownToolError if no tool with this name is registered.