pub struct Ctx { /* private fields */ }Expand description
What an operation knows about its call besides its arguments.
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn space(&self) -> &Space
pub fn space(&self) -> &Space
The tenant, end user and project the call works on, as the identity seam resolved them.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether the caller cancelled the call. An operation checks this between steps and stops where its state is whole; the kit never stops it half way.
Sourcepub async fn cancelled(&self)
pub async fn cancelled(&self)
Completes when the caller cancels the call, for an operation that waits on something it can abandon.
Sourcepub fn ask<T: DeserializeOwned + JsonSchema + 'static>(
&self,
key: &str,
message: &str,
) -> Result<Option<T>, NeedsInput>
pub fn ask<T: DeserializeOwned + JsonSchema + 'static>( &self, key: &str, message: &str, ) -> Result<Option<T>, NeedsInput>
Asks the user a question, identified by key, whose answer has the
form of T (a struct of primitive fields, whose doc comments label
the form). Returns the answer once the user gave it, None when they
declined, and NeedsInput the first time: return that from the
operation, which runs again, from the start, with the answer. Ask
from the operation’s own task, not from one it spawns.
Sourcepub fn ask_url(
&self,
key: &str,
message: &str,
url: &str,
) -> Result<bool, NeedsInput>
pub fn ask_url( &self, key: &str, message: &str, url: &str, ) -> Result<bool, NeedsInput>
Asks the user to open url and do something there that must not
pass through the client, such as signing in elsewhere or paying, as
MCP’s URL elicitation has it. Returns whether they agreed to go;
what they did there reaches the module out of band, so the operation
checks it when it runs again and asks again if it is not done.
Sourcepub fn attach(&self, content: Content)
pub fn attach(&self, content: Content)
Returns content beside a tool’s structured result: an image, audio,
text, or a resource by link or carried along, in the order attached.
Resource reads and prompts return their own content instead.