pub struct ToolOutcome {
pub text: String,
pub structured: Option<Value>,
pub is_error: bool,
}Expand description
One tool call’s outcome, in MCP’s own shape.
Three states, not two. Result can say “it worked” or “it failed”, but a
tool that RAN and declined — a quota refusal, a guard saying no, a provider
that needs reconnecting — is neither: the model should read the reason and
adapt, exactly as it reads a success. Collapsing that into Err throws away
the text the model needed; collapsing it into Ok tells the model it
succeeded.
Fields§
§text: StringText handed to the model.
structured: Option<Value>Machine-readable payload mirrored into MCP structuredContent.
is_error: boolMCP isError. True for a refusal the model should adapt to.
Implementations§
Source§impl ToolOutcome
impl ToolOutcome
Sourcepub fn json(value: Value) -> Self
pub fn json(value: Value) -> Self
A successful call carrying JSON. The text is the compact encoding, which is what a model reads when a server sends no separate rendering.
Sourcepub fn refused(reason: impl Into<String>) -> Self
pub fn refused(reason: impl Into<String>) -> Self
The tool ran and declined. reason is for the model, not the operator.
Sourcepub fn with_structured(self, value: Value) -> Self
pub fn with_structured(self, value: Value) -> Self
Attach structured content to a refusal, so a caller can carry a machine -readable code alongside the prose.
Trait Implementations§
Source§impl Clone for ToolOutcome
impl Clone for ToolOutcome
Source§fn clone(&self) -> ToolOutcome
fn clone(&self) -> ToolOutcome
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ToolOutcome
impl RefUnwindSafe for ToolOutcome
impl Send for ToolOutcome
impl Sync for ToolOutcome
impl Unpin for ToolOutcome
impl UnsafeUnpin for ToolOutcome
impl UnwindSafe for ToolOutcome
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<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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