Skip to main content

mcp_tool

Attribute Macro mcp_tool 

Source
#[mcp_tool]
Available on crate feature macros only.
Expand description

Marks a method as an MCP tool.

Parameter descriptions are extracted from doc comments on parameters.

§Example

#[mcp_tool(description = "Store a value in memory")]
pub fn memory_write(
    &self,
    /// The scope/namespace for the memory
    scope: String,
    /// The key to store the value under
    key: String,
    /// The value to store
    value: Value,
) -> ToolResult<String> {
    self.store.write(&scope, &key, value)
}