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() -> Self
Sourcepub fn elicit(self, key: &str, message: &str, requested_schema: &str) -> Self
pub fn elicit(self, key: &str, message: &str, requested_schema: &str) -> Self
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) -> Self
pub fn sample(self, key: &str, request: &SamplingRequest) -> Self
Ask the client’s LLM (sampling/createMessage). Needs the client’s
sampling capability.
Sourcepub fn list_roots(self, key: &str) -> Self
pub fn list_roots(self, key: &str) -> Self
Ask for the client’s roots (roots/list). Needs the client’s
roots capability.
Trait Implementations§
Source§impl Clone for InputRequired
impl Clone for InputRequired
Source§impl Debug for InputRequired
impl Debug for InputRequired
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