ToolMetadata

Struct ToolMetadata 

Source
pub struct ToolMetadata {
    pub name: String,
    pub title: Option<String>,
    pub description: Option<String>,
    pub parameters: Value,
    pub output_schema: Option<Value>,
    pub method: String,
    pub path: String,
    pub security: Option<Vec<String>>,
    pub parameter_mappings: HashMap<String, ParameterMapping>,
}
Expand description

Internal metadata for tools generated from OpenAPI operations.

This struct contains all the information needed to execute HTTP requests and is used internally by the OpenAPI server. It includes fields that are not part of the MCP specification but are necessary for HTTP execution.

For MCP compliance, this struct is converted to rmcp::model::Tool using the From trait implementation, which only includes MCP-compliant fields.

§MCP Tool Annotations

When converted to MCP tools, this metadata automatically generates appropriate annotation hints based on HTTP method semantics (see ToolMetadata::generate_annotations). These annotations help MCP clients understand the nature of each tool operation.

Fields§

§name: String

Tool name - exposed to MCP clients

§title: Option<String>

Tool title - human-readable display name exposed to MCP clients

§description: Option<String>

Tool description - exposed to MCP clients

§parameters: Value

Input parameters schema - exposed to MCP clients as inputSchema

§output_schema: Option<Value>

Output schema - exposed to MCP clients as outputSchema

§method: String

HTTP method (GET, POST, etc.) - internal only, not exposed to MCP

§path: String

URL path for the API endpoint - internal only, not exposed to MCP

§security: Option<Vec<String>>

Security requirements from OpenAPI spec - internal only, not exposed to MCP

§parameter_mappings: HashMap<String, ParameterMapping>

Parameter mappings for converting between MCP and OpenAPI parameters - internal only, not exposed to MCP

Implementations§

Source§

impl ToolMetadata

Source

pub fn requires_auth(&self) -> bool

Check if this tool requires authentication based on OpenAPI security definitions

Source

pub fn generate_annotations(&self) -> Option<ToolAnnotations>

Generate MCP annotations based on HTTP method semantics.

This method maps HTTP verbs to appropriate MCP tool annotation hints following the semantics defined in RFC 9110 (HTTP Semantics) and the Model Context Protocol specification.

§HTTP Method to Annotation Mapping
  • GET, HEAD, OPTIONS: Safe, idempotent read operations

    • readOnlyHint: true - No state modification
    • destructiveHint: false - Doesn’t alter existing resources
    • idempotentHint: true - Multiple requests have same effect
    • openWorldHint: true - Interacts with external HTTP API
  • POST: Creates resources; not idempotent, not destructive

    • readOnlyHint: false - Modifies state
    • destructiveHint: false - Creates new resources (doesn’t destroy existing)
    • idempotentHint: false - Multiple requests may create multiple resources
    • openWorldHint: true - Interacts with external HTTP API
  • PUT: Replaces/updates resources; idempotent but destructive

    • readOnlyHint: false - Modifies state
    • destructiveHint: true - Replaces existing resource state
    • idempotentHint: true - Multiple identical requests have same effect
    • openWorldHint: true - Interacts with external HTTP API
  • PATCH: Modifies resources; destructive and typically not idempotent

    • readOnlyHint: false - Modifies state
    • destructiveHint: true - Alters existing resource state
    • idempotentHint: false - Effect may vary based on current state
    • openWorldHint: true - Interacts with external HTTP API
  • DELETE: Removes resources; idempotent but destructive

    • readOnlyHint: false - Modifies state
    • destructiveHint: true - Removes resources
    • idempotentHint: true - Multiple deletions are no-ops after first
    • openWorldHint: true - Interacts with external HTTP API
§Returns
  • Some(ToolAnnotations) for recognized HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
  • None for unknown or unsupported HTTP methods
§Notes
  • HTTP method comparison is case-insensitive
  • The title field in annotations is always None (title is handled via Tool.title)
  • openWorldHint is always true since all OpenAPI tools interact with external HTTP APIs

Trait Implementations§

Source§

impl Clone for ToolMetadata

Source§

fn clone(&self) -> ToolMetadata

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ToolMetadata

Source§

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

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

impl From<&ToolMetadata> for Tool

Converts internal ToolMetadata to MCP-compliant Tool.

This implementation ensures that only MCP-compliant fields are exposed to clients. Internal fields like method and path are not included in the conversion.

Source§

fn from(metadata: &ToolMetadata) -> Self

Converts to this type from the input type.
Source§

impl Serialize for ToolMetadata

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,