pub struct ToolAnnotations {
pub title: Option<String>,
pub read_only_hint: Option<bool>,
pub destructive_hint: Option<bool>,
pub idempotent_hint: Option<bool>,
pub open_world_hint: Option<bool>,
}Expand description
What calling a tool does to the world, as the Model Context Protocol’s
tool annotations state it, and spelled as they are on its wire
(readOnlyHint, …), so an MCP tool’s annotations read straight into
one. Each is a hint a tool’s author gives: a host’s policies read them
(approval, plan mode, which calls run side by side), never trusting a
tool it does not trust for them. A hint left unset takes the protocol’s
default, which the accessors apply: not read-only, destructive, not
idempotent, open world.
use rig_core::completion::ToolAnnotations;
let read = ToolAnnotations::default().with_read_only(true).with_open_world(false);
assert!(read.read_only() && !read.destructive() && !read.open_world());
let unknown = ToolAnnotations::default();
assert!(!unknown.read_only() && unknown.destructive() && unknown.open_world());
let mcp: ToolAnnotations = serde_json::from_value(serde_json::json!({"readOnlyHint": true}))?;
assert!(mcp.read_only());Fields§
§title: Option<String>A human-readable title for the tool.
read_only_hint: Option<bool>Whether the tool changes nothing in its environment.
destructive_hint: Option<bool>Whether a tool that changes things may also destroy or overwrite what was there (rather than only add). Meaningless for a read-only tool.
idempotent_hint: Option<bool>Whether calling the tool again with the same arguments has no further effect. Meaningless for a read-only tool.
open_world_hint: Option<bool>Whether the tool reaches beyond a closed set of things, such as the
web or a shell; false for one that works on a known store, such
as the project’s files.
Implementations§
Source§impl ToolAnnotations
impl ToolAnnotations
Sourcepub fn destructive(&self) -> bool
pub fn destructive(&self) -> bool
Whether the tool may destroy or overwrite something: never for a
read-only tool, else the hint, else true.
Sourcepub fn idempotent(&self) -> bool
pub fn idempotent(&self) -> bool
Whether repeating a call has no further effect: always for a
read-only tool, else the hint, else false.
Sourcepub fn open_world(&self) -> bool
pub fn open_world(&self) -> bool
Whether the tool reaches an open world: the hint, else true.
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
The same annotations with a title.
Sourcepub fn with_read_only(self, read_only: bool) -> Self
pub fn with_read_only(self, read_only: bool) -> Self
The same annotations stating whether the tool is read-only.
Sourcepub fn with_destructive(self, destructive: bool) -> Self
pub fn with_destructive(self, destructive: bool) -> Self
The same annotations stating whether the tool is destructive.
Sourcepub fn with_idempotent(self, idempotent: bool) -> Self
pub fn with_idempotent(self, idempotent: bool) -> Self
The same annotations stating whether the tool is idempotent.
Sourcepub fn with_open_world(self, open_world: bool) -> Self
pub fn with_open_world(self, open_world: bool) -> Self
The same annotations stating whether the tool reaches an open world.
Trait Implementations§
Source§impl Clone for ToolAnnotations
impl Clone for ToolAnnotations
Source§impl Debug for ToolAnnotations
impl Debug for ToolAnnotations
Source§impl Default for ToolAnnotations
impl Default for ToolAnnotations
Source§impl<'de> Deserialize<'de> for ToolAnnotations
impl<'de> Deserialize<'de> for ToolAnnotations
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ToolAnnotations
Source§impl Hash for ToolAnnotations
impl Hash for ToolAnnotations
Source§impl PartialEq for ToolAnnotations
impl PartialEq for ToolAnnotations
Source§impl Serialize for ToolAnnotations
impl Serialize for ToolAnnotations
impl StructuralPartialEq for ToolAnnotations
Auto Trait Implementations§
impl Freeze for ToolAnnotations
impl RefUnwindSafe for ToolAnnotations
impl Send for ToolAnnotations
impl Sync for ToolAnnotations
impl Unpin for ToolAnnotations
impl UnsafeUnpin for ToolAnnotations
impl UnwindSafe for ToolAnnotations
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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