find_units
Search a database of 3000+ units for any whose name or definition contains a keyword. Get details including dimension and base value to triage results.
Instructions
Search the GNU units database for units whose name or definition contains a keyword.
Basic substring search over the 3000+ unit GNU units database (TODO ยง14.1). A
hit is any unit whose name OR definition text contains query (case-insensitive);
prefixes are excluded. Results are returned in the database's native order and
capped at limit. Use this to discover the exact spelling of a unit before
calling a conversion tool.
Returns: query (echoed), count (number of results returned), and results,
a list of objects each carrying:
name: the unit's name.definition: its definition text (the source line with the leading name token removed, so the name is not repeated).kind: "unit" | "primitive" | "function" | "table".dimension: the unit reduced to base-unit signature, e.g. "kg m^2 / s^3" for power โ use it to check whether two units are conformable without a second call. Omitted for hits that do not reduce (functions, tables).base_value: the unit reduced to base/primitive units, coefficient included, e.g. "745.699 kg m^2 / s^3". Omitted alongsidedimensionwhen the hit does not reduce.
Enriching each hit lets you search AND triage in a single call instead of a follow-up lookup per unit. Example: find_units("horsepower") -> {"query":"horsepower","count":9,"results":[{"name":"horsepower", "definition":"550 foot pound force / sec","kind":"unit", "dimension":"kg m^2 / s^3","base_value":"745.7 kg m^2 / s^3"}, ...]}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of matches to return (results are in the database's native definition order; the scan stops once this many are found). | |
| query | Yes | Case-insensitive substring to search for. Matches against both the unit NAME and its DEFINITION text, so 'meter' finds the `meter` unit itself as well as units defined in terms of it (e.g. `micron`). Use a short keyword like 'byte', 'pressure', or 'newton'. |