convert_force
Convert force measurements between units like newtons, pounds force, kips, and dynes for engineering or physics calculations.
Instructions
Convert force between units.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| value | Yes | Force value to convert | |
| from_unit | Yes | Source unit | |
| to_unit | Yes | Target unit |
Implementation Reference
- Core handler function that performs force unit conversion by converting input to Newtons as an intermediate unit and then to the target unit.def convert_force_tool( value: float, from_unit: FORCE_UNIT, to_unit: FORCE_UNIT, ) -> float: """Convert force between units.""" # Convert to newtons first to_newtons = { "dynes": 1e-05, "kilograms force": 9.80665, "kilonewtons": 1_000.0, "kips": 4_448.222, "meganewtons": 1_000_000.0, "newtons": 1.0, "pounds force": 4.44822161526, "tonnes force": 9_806.65, "long tons force": 9_964.01641818352, "short tons force": 8_896.443230521, } newtons = value * to_newtons[from_unit] return newtons / to_newtons[to_unit]
- Type definition for supported force units using Literal, used for input validation.FORCE_UNIT = Literal[ "dynes", "kilograms force", "kilonewtons", "kips", "meganewtons", "newtons", "pounds force", "tonnes force", "long tons force", "short tons force", ]
- src/unit_converter_mcp/server.py:130-144 (registration)MCP tool registration for 'convert_force' using FastMCP's @app.tool() decorator, which wraps the core handler and returns a formatted response dictionary.@app.tool() def convert_force( value: Annotated[float, Field(description="Force value to convert")], from_unit: Annotated[FORCE_UNIT, Field(description="Source unit")], to_unit: Annotated[FORCE_UNIT, Field(description="Target unit")], ) -> dict: """Convert force between units.""" converted_value = convert_force_tool(value, from_unit, to_unit) return { "original_value": value, "original_unit": from_unit, "converted_value": converted_value, "converted_unit": to_unit, "conversion_type": "force", }