Skip to main content

tool

Attribute Macro tool 

Source
#[tool]
Expand description

Blessed preset: MCP tools with JSON Schema.

Combines #[mcp] + #[jsonschema] into a single attribute. JSON Schema is included when the feature is enabled, and gracefully omitted otherwise.

§Example

use server_less::tool;

struct FileTools;

#[tool(namespace = "file")]
impl FileTools {
    pub fn read_file(&self, path: String) -> String { String::new() }
    pub fn write_file(&self, path: String, content: String) -> bool { true }
}

§Options

  • namespace - MCP tool namespace prefix
  • jsonschema - Toggle JSON Schema generation (default: true)