list_unit_conversions
Retrieve all supported unit categories and their units for physics calculations, including velocity, distance, mass, force, energy, power, temperature, angle, pressure, area, and volume.
Instructions
List all supported unit conversions.
Returns a dictionary mapping category names to lists of supported units.
Returns:
Dictionary with supported unit categories:
- velocity: Speed units
- distance: Length units
- mass: Weight units
- force: Force units
- energy: Energy units
- power: Power units
- temperature: Temperature scales
- angle: Angular units
- pressure: Pressure units
- area: Area units
- volume: Volume units
Example:
>>> list_unit_conversions()
{
"velocity": ["m/s", "km/h", "mph", "ft/s", "knots"],
"distance": ["m", "km", "mi", "ft", "yd", "in"],
"mass": ["kg", "g", "lb", "oz"],
...
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The 'list_unit_conversions' function that implements the tool logic. It is decorated with @tool(), calls get_supported_units() to get category data, adds example conversions, and returns a dict with 'categories', 'examples', and 'total_conversions'.
@tool() def list_unit_conversions() -> dict: """ List all supported unit conversions. Returns a dictionary mapping category names to lists of supported units. Returns: Dictionary with supported unit categories: - velocity: Speed units - distance: Length units - mass: Weight units - force: Force units - energy: Energy units - power: Power units - temperature: Temperature scales - angle: Angular units - pressure: Pressure units - area: Area units - volume: Volume units Example: >>> list_unit_conversions() { "velocity": ["m/s", "km/h", "mph", "ft/s", "knots"], "distance": ["m", "km", "mi", "ft", "yd", "in"], "mass": ["kg", "g", "lb", "oz"], ... } """ units = get_supported_units() # Add examples for each category examples = { "velocity": "100 m/s = 223.69 mph", "distance": "1 km = 0.621 mi", "mass": "1 kg = 2.205 lb", "force": "100 N = 22.48 lbf", "energy": "1000 J = 1 kJ = 0.239 kcal", "power": "1000 W = 1 kW = 1.341 hp", "temperature": "0 C = 32 F = 273.15 K", "angle": "180 deg = π rad", "pressure": "101325 Pa = 1 atm = 14.7 psi", "area": "1 acre = 4046.86 m²", "volume": "1 m³ = 1000 L = 264.17 gal", } return { "categories": units, "examples": examples, "total_conversions": sum(len(v) for v in units.values()), } - src/chuk_mcp_physics/tools/convert_units.py:3-4 (registration)The @tool() decorator from chuk_mcp_server that registers list_unit_conversions as an MCP tool. The tool module is imported in server.py (line 49) to register all @tool-decorated functions.
from chuk_mcp_server import tool from ..units import convert_units, get_supported_units - src/chuk_mcp_physics/server.py:39-50 (registration)The server imports the convert_units module (aliased as unit_conversion_tools) to trigger registration of all @tool-decorated functions, including list_unit_conversions.
from .tools import ( basic, rotational, oscillations, circular_motion, collisions, conservation, fluid as fluid_tools, kinematics_tools, statics, convert_units as unit_conversion_tools, ) - The get_supported_units() helper function called by list_unit_conversions to retrieve the dictionary of unit categories and their supported units.
def get_supported_units() -> dict[str, list[str]]: """ Get a dictionary of supported unit categories and their units. Returns: Dictionary mapping category names to lists of supported units """ return { "velocity": ["m/s", "km/h", "mph", "ft/s", "knots"], "distance": ["m", "km", "mi", "ft", "yd", "in"], "mass": ["kg", "g", "lb", "oz"], "force": ["N", "kN", "lbf"], "energy": ["J", "kJ", "cal", "BTU", "kWh"], "power": ["W", "kW", "hp"], "temperature": ["K", "C", "F"], "angle": ["rad", "deg"], "pressure": ["Pa", "kPa", "bar", "psi", "atm"], "area": ["m²", "km²", "ft²", "acre"], "volume": ["m³", "L", "gal", "ft³"], "time": ["s", "min", "hr", "day"], "acceleration": ["m/s²", "g", "ft/s²"], "torque": ["N·m", "lb·ft", "lb·in"], "frequency": ["Hz", "kHz", "MHz", "GHz"], "data_size": ["B", "KB", "MB", "GB"], } - tests/test_units.py:709-735 (helper)Test for list_unit_conversions that validates the returned dict has the expected keys and all 16 category entries.
def test_list_unit_conversions(self): from chuk_mcp_physics.tools.convert_units import list_unit_conversions result = list_unit_conversions() assert "categories" in result assert "examples" in result assert "total_conversions" in result # Check that all expected categories are present categories = result["categories"] assert "velocity" in categories assert "distance" in categories assert "mass" in categories assert "force" in categories assert "energy" in categories assert "power" in categories assert "temperature" in categories assert "angle" in categories assert "pressure" in categories assert "area" in categories assert "volume" in categories assert "time" in categories assert "acceleration" in categories assert "torque" in categories assert "frequency" in categories assert "data_size" in categories