pub struct InputRequired { /* private fields */ }Expand description
A handler’s request for input from the client (MCP 2026-07-28 multi
round-trip requests): the client answers each request and calls again,
the answers then in McpContext::input_response under the same keys,
and state in McpContext::request_state.
use rust_web_server::mcp::{InputRequired, McpContent, McpServer};
let server = McpServer::new("greeter", "1.0").tool_with_context("greet", "Greets you", "{}", |ctx, _args| {
match ctx.input_response("name") {
Some(answer) => Ok(McpContent::text(format!("Hello! (you said {answer})"))),
None => Ok(McpContent::input_required(InputRequired::new().elicit(
"name",
"What is your name?",
r#"{"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}"#,
))),
}
});Implementations§
Source§impl InputRequired
impl InputRequired
pub fn new() -> InputRequired
Sourcepub fn elicit(
self,
key: &str,
message: &str,
requested_schema: &str,
) -> InputRequired
pub fn elicit( self, key: &str, message: &str, requested_schema: &str, ) -> InputRequired
Ask the user to fill in a form: requested_schema is a JSON Schema
object of primitive properties (elicitation/create, form mode).
Needs the client’s elicitation capability.
Sourcepub fn sample(self, key: &str, request: &SamplingRequest) -> InputRequired
pub fn sample(self, key: &str, request: &SamplingRequest) -> InputRequired
Ask the client’s LLM (sampling/createMessage). Needs the client’s
sampling capability.
Sourcepub fn list_roots(self, key: &str) -> InputRequired
pub fn list_roots(self, key: &str) -> InputRequired
Ask for the client’s roots (roots/list). Needs the client’s
roots capability.
Sourcepub fn state(self, state: impl Into<String>) -> InputRequired
pub fn state(self, state: impl Into<String>) -> InputRequired
Opaque state for the retry, echoed back by the client: signed by the server, so the handler gets back exactly what it set.
Trait Implementations§
Source§impl Clone for InputRequired
impl Clone for InputRequired
Source§fn clone(&self) -> InputRequired
fn clone(&self) -> InputRequired
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InputRequired
impl Debug for InputRequired
Source§impl Default for InputRequired
impl Default for InputRequired
Source§fn default() -> InputRequired
fn default() -> InputRequired
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InputRequired
impl RefUnwindSafe for InputRequired
impl Send for InputRequired
impl Sync for InputRequired
impl Unpin for InputRequired
impl UnsafeUnpin for InputRequired
impl UnwindSafe for InputRequired
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
Mutably borrows from an owned value. Read more