pub struct ElicitationSchema {
pub type_: ObjectTypeConst,
pub title: Option<Cow<'static, str>>,
pub properties: BTreeMap<String, PrimitiveSchema>,
pub required: Option<Vec<String>>,
pub description: Option<Cow<'static, str>>,
}Expand description
Type-safe elicitation schema for requesting structured user input.
This enforces the MCP 2025-06-18 specification that elicitation schemas must be objects with primitive-typed properties.
§Example
use rmcp::model::*;
let schema = ElicitationSchema::builder()
.required_email("email")
.required_integer("age", 0, 150)
.optional_bool("newsletter", false)
.build();Fields§
§type_: ObjectTypeConstAlways “object” for elicitation schemas
title: Option<Cow<'static, str>>Optional title for the schema
properties: BTreeMap<String, PrimitiveSchema>Property definitions (must be primitive types)
required: Option<Vec<String>>List of required property names
description: Option<Cow<'static, str>>Optional description of what this schema represents
Implementations§
Source§impl ElicitationSchema
impl ElicitationSchema
Sourcepub fn new(properties: BTreeMap<String, PrimitiveSchema>) -> ElicitationSchema
pub fn new(properties: BTreeMap<String, PrimitiveSchema>) -> ElicitationSchema
Create a new elicitation schema with the given properties
Sourcepub fn from_json_schema(
schema: Map<String, Value>,
) -> Result<ElicitationSchema, Error>
pub fn from_json_schema( schema: Map<String, Value>, ) -> Result<ElicitationSchema, Error>
Convert from a JSON Schema object (typically generated by schemars)
This allows converting from JsonObject to ElicitationSchema, which is useful when working with automatically generated schemas from types.
§Example
use rmcp::model::*;
let json_schema = schema_for_type::<MyType>();
let elicitation_schema = ElicitationSchema::from_json_schema(json_schema)?;§Errors
Returns a serde_json::Error if the JSON object cannot be deserialized
into a valid ElicitationSchema.
Sourcepub fn with_required(self, required: Vec<String>) -> ElicitationSchema
pub fn with_required(self, required: Vec<String>) -> ElicitationSchema
Set the required fields
Sourcepub fn with_title(
self,
title: impl Into<Cow<'static, str>>,
) -> ElicitationSchema
pub fn with_title( self, title: impl Into<Cow<'static, str>>, ) -> ElicitationSchema
Set the title
Sourcepub fn with_description(
self,
description: impl Into<Cow<'static, str>>,
) -> ElicitationSchema
pub fn with_description( self, description: impl Into<Cow<'static, str>>, ) -> ElicitationSchema
Set the description
Sourcepub fn builder() -> ElicitationSchemaBuilder
pub fn builder() -> ElicitationSchemaBuilder
Create a builder for constructing elicitation schemas fluently
Trait Implementations§
Source§impl Clone for ElicitationSchema
impl Clone for ElicitationSchema
Source§fn clone(&self) -> ElicitationSchema
fn clone(&self) -> ElicitationSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more