tool

UDA marking a method as an MCP tool. Apply to a member function; the input schema is derived from the parameter types, and the return value is wrapped into a tool result.

@safe
struct tool {
string name;
string description;
}

Members

Variables

title
string title;

optional human-readable display name (empty = unset)

Examples

class Calc
{
    @tool("add", "Add two integers")
    int add(int a, int b) { return a + b; }
}

An optional human-readable title may be supplied for display purposes; it is independent of the programmatic name. To declare behavioral hints (readOnlyHint, destructiveHint, ...), attach the marker UDAs @readOnly, @destructive, @idempotent, @openWorld (and @hintTitle(...) for the annotation-level title) to the same method.