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: StringTool 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: ValueInput parameters schema - exposed to MCP clients as inputSchema
output_schema: Option<Value>Output schema - exposed to MCP clients as outputSchema
method: StringHTTP method (GET, POST, etc.) - internal only, not exposed to MCP
path: StringURL 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
impl ToolMetadata
Sourcepub fn requires_auth(&self) -> bool
pub fn requires_auth(&self) -> bool
Check if this tool requires authentication based on OpenAPI security definitions
Sourcepub fn generate_annotations(&self) -> Option<ToolAnnotations>
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 modificationdestructiveHint: false- Doesn’t alter existing resourcesidempotentHint: true- Multiple requests have same effectopenWorldHint: true- Interacts with external HTTP API
-
POST: Creates resources; not idempotent, not destructive
readOnlyHint: false- Modifies statedestructiveHint: false- Creates new resources (doesn’t destroy existing)idempotentHint: false- Multiple requests may create multiple resourcesopenWorldHint: true- Interacts with external HTTP API
-
PUT: Replaces/updates resources; idempotent but destructive
readOnlyHint: false- Modifies statedestructiveHint: true- Replaces existing resource stateidempotentHint: true- Multiple identical requests have same effectopenWorldHint: true- Interacts with external HTTP API
-
PATCH: Modifies resources; destructive and typically not idempotent
readOnlyHint: false- Modifies statedestructiveHint: true- Alters existing resource stateidempotentHint: false- Effect may vary based on current stateopenWorldHint: true- Interacts with external HTTP API
-
DELETE: Removes resources; idempotent but destructive
readOnlyHint: false- Modifies statedestructiveHint: true- Removes resourcesidempotentHint: true- Multiple deletions are no-ops after firstopenWorldHint: true- Interacts with external HTTP API
§Returns
Some(ToolAnnotations)for recognized HTTP methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)Nonefor unknown or unsupported HTTP methods
§Notes
- HTTP method comparison is case-insensitive
- The
titlefield in annotations is alwaysNone(title is handled viaTool.title) openWorldHintis alwaystruesince all OpenAPI tools interact with external HTTP APIs
Trait Implementations§
Source§impl Clone for ToolMetadata
impl Clone for ToolMetadata
Source§fn clone(&self) -> ToolMetadata
fn clone(&self) -> ToolMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolMetadata
impl Debug for ToolMetadata
Source§impl From<&ToolMetadata> for Tool
Converts internal ToolMetadata to MCP-compliant Tool.
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.