Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

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
NameRequiredDescriptionDefault
valueYesForce value to convert
from_unitYesSource unit
to_unitYesTarget 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", ]
  • 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", }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zazencodes/unit-converter-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server