pub struct ToolSet { /* private fields */ }Expand description
Central registry and dispatcher.
Implementations§
Source§impl ToolSet
impl ToolSet
Sourcepub fn register_group(&self, config: GroupConfig) -> Result<()>
pub fn register_group(&self, config: GroupConfig) -> Result<()>
Register a group definition.
This registers the group configuration and auto activation tools.
Sourcepub fn register_exclusion(&self, groups: &[&str]) -> Result<()>
pub fn register_exclusion(&self, groups: &[&str]) -> Result<()>
Register a mutual exclusion set.
Sourcepub fn qualified_name(group: &str, base: &str) -> String
pub fn qualified_name(group: &str, base: &str) -> String
Construct a fully-qualified tool name from a group path and base name.
Sourcepub async fn activate_group(&self, name: &str, ctx: &ServerCtx) -> Result<bool>
pub async fn activate_group(&self, name: &str, ctx: &ServerCtx) -> Result<bool>
Activate a group and emit notifications/tools/list_changed if visibility changed.
Sourcepub async fn deactivate_group(
&self,
name: &str,
ctx: &ServerCtx,
) -> Result<bool>
pub async fn deactivate_group( &self, name: &str, ctx: &ServerCtx, ) -> Result<bool>
Deactivate a group and emit notifications/tools/list_changed if visibility changed.
Sourcepub fn is_group_active(&self, name: &str) -> bool
pub fn is_group_active(&self, name: &str) -> bool
Check if a group is currently active.
Sourcepub fn list_groups(&self) -> Vec<GroupInfo>
pub fn list_groups(&self) -> Vec<GroupInfo>
List all groups with their current state.
Sourcepub fn register<F>(&self, name: &str, tool: Tool, handler: F) -> Result<()>
pub fn register<F>(&self, name: &str, tool: Tool, handler: F) -> Result<()>
Register a tool into the root group (always visible).
Sourcepub fn register_with_visibility<F>(
&self,
name: &str,
tool: Tool,
visibility: Visibility,
handler: F,
) -> Result<()>
pub fn register_with_visibility<F>( &self, name: &str, tool: Tool, visibility: Visibility, handler: F, ) -> Result<()>
Register a tool with explicit visibility.
Sourcepub fn unregister(&self, name: &str) -> Option<Tool>
pub fn unregister(&self, name: &str) -> Option<Tool>
Remove a tool by name. Returns the tool definition if it existed.
Sourcepub fn notify_list_changed(&self, ctx: &ServerCtx) -> Result<()>
pub fn notify_list_changed(&self, ctx: &ServerCtx) -> Result<()>
Emit notifications/tools/list_changed explicitly.
Sourcepub fn list_tools(&self, cursor: Option<Cursor>) -> Result<ListToolsResult>
pub fn list_tools(&self, cursor: Option<Cursor>) -> Result<ListToolsResult>
List currently visible tools.
Tools are returned in deterministic name-sorted order (ascending); cursors are interpreted as offsets into that ordering.
Sourcepub async fn call_tool(
&self,
ctx: &ServerCtx,
name: &str,
arguments: Option<Arguments>,
) -> Result<CallToolResult>
pub async fn call_tool( &self, ctx: &ServerCtx, name: &str, arguments: Option<Arguments>, ) -> Result<CallToolResult>
Call a tool by name.
Returns ToolNotFound if the tool doesn’t exist or is not currently visible.
Sourcepub async fn call_tool_with<H, F>(
&self,
handler: &H,
ctx: &ServerCtx,
name: &str,
arguments: Option<Arguments>,
dispatch: F,
) -> Result<CallToolResult>
pub async fn call_tool_with<H, F>( &self, handler: &H, ctx: &ServerCtx, name: &str, arguments: Option<Arguments>, dispatch: F, ) -> Result<CallToolResult>
Call a tool, delegating to a handler method on the server.