Skip to main content

McpSchema

Struct McpSchema 

Source
pub struct McpSchema(/* private fields */);
Expand description

Typed JSON Schema value used by generated MCP tool metadata.

This wrapper keeps schema-producing APIs distinct from arbitrary tool-call JSON while still exposing the underlying serde_json::Value for tests, protocol handoff, and last-mile schema extension.

Implementations§

Source§

impl McpSchema

Source

pub fn new(schema: Value) -> Self

Source

pub fn any() -> Self

Source

pub fn impossible() -> Self

Source

pub fn typed(schema_type: McpSchemaType) -> Self

Source

pub fn null() -> Self

Source

pub fn boolean() -> Self

Source

pub fn integer() -> Self

Source

pub fn number() -> Self

Source

pub fn string() -> Self

Source

pub fn array(item_schema: McpSchema) -> Self

Source

pub fn object() -> Self

Source

pub fn any_of<I>(schemas: I) -> Self
where I: IntoIterator<Item = McpSchema>,

Source

pub fn one_of<I>(schemas: I) -> Self
where I: IntoIterator<Item = McpSchema>,

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Source

pub fn with_extension(self, key: impl Into<String>, value: Value) -> Self

Source

pub fn with_format(self, format: McpStringFormat) -> Self

Source

pub fn with_minimum(self, minimum: impl Into<McpSchemaNumber>) -> Self

Source

pub fn with_min_items(self, min_items: usize) -> Self

Source

pub fn with_max_items(self, max_items: usize) -> Self

Source

pub fn with_unique_items(self, unique_items: bool) -> Self

Source

pub fn with_default(self, value: impl Into<Value>) -> Self

Source

pub fn with_const(self, value: impl Into<Value>) -> Self

Source

pub fn with_enum_values<I, V>(self, values: I) -> Self
where I: IntoIterator<Item = V>, V: Into<Value>,

Source

pub fn with_items(self, item_schema: McpSchema) -> Self

Source

pub fn with_prefix_items<I>(self, item_schemas: I) -> Self
where I: IntoIterator<Item = McpSchema>,

Source

pub fn with_properties(self, properties: McpSchemaProperties) -> Self

Source

pub fn with_required<I, S>(self, required: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn with_additional_properties( self, additional_properties: impl Into<McpAdditionalProperties>, ) -> Self

Source

pub fn with_not(self, schema: McpSchema) -> Self

Source

pub fn set_description(&mut self, description: impl Into<String>)

Source

pub fn set_extension(&mut self, key: impl Into<String>, value: Value)

Source

pub fn set_format(&mut self, format: McpStringFormat)

Source

pub fn set_minimum(&mut self, minimum: impl Into<McpSchemaNumber>)

Source

pub fn set_min_items(&mut self, min_items: usize)

Source

pub fn set_max_items(&mut self, max_items: usize)

Source

pub fn set_unique_items(&mut self, unique_items: bool)

Source

pub fn set_default(&mut self, value: impl Into<Value>)

Source

pub fn set_const(&mut self, value: impl Into<Value>)

Source

pub fn set_enum_values<I, V>(&mut self, values: I)
where I: IntoIterator<Item = V>, V: Into<Value>,

Source

pub fn set_items(&mut self, item_schema: McpSchema)

Source

pub fn set_prefix_items<I>(&mut self, item_schemas: I)
where I: IntoIterator<Item = McpSchema>,

Source

pub fn set_properties(&mut self, properties: McpSchemaProperties)

Source

pub fn set_required<I, S>(&mut self, required: I)
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn set_additional_properties( &mut self, additional_properties: impl Into<McpAdditionalProperties>, )

Source

pub fn set_any_of<I>(&mut self, schemas: I)
where I: IntoIterator<Item = McpSchema>,

Source

pub fn set_one_of<I>(&mut self, schemas: I)
where I: IntoIterator<Item = McpSchema>,

Source

pub fn set_not(&mut self, schema: McpSchema)

Source

pub fn as_value(&self) -> &Value

Source

pub fn as_object_mut(&mut self) -> Option<&mut Map<String, Value>>

Source

pub fn into_value(self) -> Value

Trait Implementations§

Source§

impl Clone for McpSchema

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for McpSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for McpSchema

Source§

impl From<McpSchema> for McpAdditionalProperties

Source§

fn from(schema: McpSchema) -> Self

Converts to this type from the input type.
Source§

impl<I> Index<I> for McpSchema
where Value: Index<I>,

Source§

type Output = <Value as Index<I>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl PartialEq for McpSchema

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for McpSchema

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more