pub struct ToolDef { /* private fields */ }Expand description
A registered tool: its protocol description plus its entry point.
Implementations§
Source§impl ToolDef
impl ToolDef
Sourcepub fn new(tool: Tool, call: CallFn) -> Self
pub fn new(tool: Tool, call: CallFn) -> Self
Creates a definition from the protocol description and entry point.
Sourcepub fn ui(self, resource_uri: impl Into<String>) -> Self
pub fn ui(self, resource_uri: impl Into<String>) -> Self
Renders the tool’s results with an MCP Apps interface: the ui://
URI of a resource registered with
ResourceDef::app. The tool must still
return text content for hosts without MCP Apps.
Sourcepub fn visibility(
self,
visibility: impl IntoIterator<Item = Visibility>,
) -> Self
pub fn visibility( self, visibility: impl IntoIterator<Item = Visibility>, ) -> Self
Who may call the tool (MCP Apps): [Visibility::App] hides it from
the model and leaves it to the app’s interface. Default: both.
This is a hint for hosts, not access control: every client can list and call the tool, and hosts without MCP Apps show it to the model like any other. Protect sensitive tools with OAuth scopes.
Sourcepub fn ui_resource(&self) -> Option<&str>
pub fn ui_resource(&self) -> Option<&str>
The interface declared with ui.
Sourcepub fn scopes<I, S>(self, scopes: I) -> Self
pub fn scopes<I, S>(self, scopes: I) -> Self
Declares the OAuth scopes a caller needs (all of them). Enforced when
the HTTP transport requires OAuth; the client gets 403 with an
insufficient_scope challenge listing these scopes.
Sourcepub fn required_scopes(&self) -> &[String]
pub fn required_scopes(&self) -> &[String]
The OAuth scopes declared with scopes.
Sourcepub fn require_state<T: Send + Sync + 'static>(self) -> Self
pub fn require_state<T: Send + Sync + 'static>(self) -> Self
Declares that the tool needs shared state of type T.