Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

convert_pressure

Convert pressure values between units like pascals, atmospheres, psi, and more with precise calculations. Simplify unit transformations for accurate measurements.

Instructions

Convert pressure between units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_unitYesSource unit
to_unitYesTarget unit
valueYesPressure value to convert

Implementation Reference

  • MCP tool handler function for 'convert_pressure' decorated with @app.tool(). It validates inputs using PRESSURE_UNIT, calls the core convert_pressure_tool, and returns a formatted dictionary response.
    @app.tool() def convert_pressure( value: Annotated[float, Field(description="Pressure value to convert")], from_unit: Annotated[PRESSURE_UNIT, Field(description="Source unit")], to_unit: Annotated[PRESSURE_UNIT, Field(description="Target unit")], ) -> dict: """Convert pressure between units.""" converted_value = convert_pressure_tool(value, from_unit, to_unit) return { "original_value": value, "original_unit": from_unit, "converted_value": converted_value, "converted_unit": to_unit, "conversion_type": "pressure", }
  • Core conversion logic for pressure units. Converts input value from from_unit to pascals, then to to_unit using predefined conversion factors.
    def convert_pressure_tool( value: float, from_unit: PRESSURE_UNIT, to_unit: PRESSURE_UNIT, ) -> float: """Convert pressure between units.""" # Convert to pascals first to_pascals = { # SI units and simple multiples "pascal": 1.0, "hectopascal": 100.0, "kilopascal": 1_000.0, "megapascal": 1_000_000.0, # Reference pressures "bar": 100_000.0, # common in industry & diving "atmosphere": 101_325.0, # Water‑column units "centimeters of water": 98.0665, "inches of water": 249.08891, "feet of water": 2_989.06692, "meters of water": 9_806.65, # Mercury‑column units "millimeters of mercury": 133.322, "inches of mercury": 3_386.388, # Force per area "kilogram force per square centimeter": 98_066.5, "newtons per square centimeter": 10_000.0, "newtons per square millimeter": 1_000_000.0, # Widely‑recognised US customary symbols "psi": 6_894.757293168362, "psf": 47.880258980336, } pascals = value * to_pascals[from_unit] return pascals / to_pascals[to_unit]
  • Pydantic-compatible Literal type defining all supported pressure units for input validation in the tool schema.
    PRESSURE_UNIT = Literal[ "pascal", "hectopascal", "kilopascal", "megapascal", "bar", "atmosphere", "centimeters of water", "inches of water", "feet of water", "meters of water", "millimeters of mercury", "inches of mercury", "kilogram force per square centimeter", "newtons per square centimeter", "newtons per square millimeter", "psi", "psf", ]

Other Tools

Related Tools

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