Skip to main content

tool_definition

Function tool_definition 

Source
pub fn tool_definition(
    name: impl Into<String>,
    title: Option<String>,
    description: Option<String>,
    input_schema: McpSchema,
    output_schema: Option<McpSchema>,
) -> Result<ToolDefinition, McpToolError>
Expand description

Build and validate an MCP tool definition.

Output schemas use JSON Schema Draft 2020-12 unless $schema selects a supported draft (4, 6, 7, 2019-09, or 2020-12). Formats are annotations. References must resolve within the supplied schema; external retrieval is disabled. Successful output must use the advertised names, without input alias or x-mcp* normalization.

ยงErrors

Returns McpToolError when the tool metadata is invalid or when the input schema is not an object-shaped MCP tool schema, or the output schema is not a valid, self-contained JSON Schema object.