Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

convert_pressure

Convert pressure values between units like psi, bar, pascal, and atmosphere for engineering, scientific, or industrial applications.

Instructions

Convert pressure between units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesPressure value to convert
from_unitYesSource unit
to_unitYesTarget unit

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that implements the pressure unit conversion logic by converting to Pascals as intermediate unit.
    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]
  • MCP tool handler for 'convert_pressure', registers the tool and wraps the core logic with standardized response format.
    @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",
        }
  • Type schema defining the supported pressure units as a Literal union for input validation.
    from typing import Literal
    
    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",
    ]
  • Imports the convert_pressure_tool and PRESSURE_UNIT into the server for use in tool definitions.
    from .tools import (
        ANGLE_UNIT,
        AREA_UNIT,
        COMPUTER_DATA_UNIT,
        DENSITY_UNIT,
        ENERGY_UNIT,
        FORCE_UNIT,
        LENGTH_UNIT,
        MASS_UNIT,
        POWER_UNIT,
        PRESSURE_UNIT,
        SPEED_UNIT,
        TEMPERATURE_UNIT,
        TIME_UNIT,
        VOLUME_UNIT,
        convert_angle_tool,
        convert_area_tool,
        convert_batch_tool,
        convert_computer_data_tool,
        convert_density_tool,
        convert_energy_tool,
        convert_force_tool,
        convert_length_tool,
        convert_mass_tool,
        convert_power_tool,
        convert_pressure_tool,
        convert_speed_tool,
        convert_temperature_tool,
        convert_time_tool,
        convert_volume_tool,
    )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the basic function but doesn't describe important behavioral traits: whether the conversion is precise or approximate, what happens with invalid units, if there are rounding rules, rate limits, or authentication requirements. For a conversion tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise at just 4 words. It's front-loaded with the essential information and contains zero wasted words. Every element earns its place by clearly stating the tool's core function without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simple conversion function, 100% schema coverage, and the presence of an output schema (which means return values are documented elsewhere), the description is minimally adequate. However, for a tool with no annotations and multiple sibling conversion tools, it should provide more context about when to choose this specific pressure converter and what behavioral characteristics to expect.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description mentions 'between units' which implies the need for source and target units, but doesn't add meaningful semantics beyond what the schema already provides. With 100% schema description coverage and clear enum values for both units, the schema does the heavy lifting. The description doesn't explain unit relationships, conversion accuracy, or special considerations for specific unit pairs.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: converting pressure between units. It specifies the verb ('convert') and resource ('pressure'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'convert_temperature' or 'convert_length' beyond mentioning 'pressure' in the description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'convert_batch' for multiple conversions or 'list_supported_units' for discovering available units. There's no context about prerequisites, error conditions, or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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