collectTools — gather decorated functions
Rust · crate toolnexus · SPEC §6
Sweep a module or class and collect every function marked as a tool.
What to use instead
Section titled “What to use instead”Build a Vec<Tool> with define_tool / define_typed_tool and pass it as ToolkitOptions.extra_tools (or Toolkit::register it later). A function that returns the vector is the Rust spelling of a collector:
fn math_tools() -> Vec<Tool> { vec![ define_tool("add", "Add a and b", None, |a, _c| async move { Ok::<_, String>((a["a"].as_f64().unwrap_or(0.0) + a["b"].as_f64().unwrap_or(0.0)).to_string()) }), define_tool("neg", "Negate n", None, |a, _c| async move { Ok::<_, String>((-a["n"].as_f64().unwrap_or(0.0)).to_string()) }), ]}See also
Section titled “See also”define_tool— Wrap a plain function with a name, description and schema — the shortest path from code you have to a tool the LLM can call.define_typed_tool— Derive the schema from the function signature or annotation instead of writing it by hand.