Skip to main content
Glama
zazencodes

Unit Converter MCP

by zazencodes

convert_temperature

Convert temperature values between Celsius, Fahrenheit, and Kelvin units for accurate measurement translation.

Instructions

Convert temperature between units.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesTemperature value to convert
from_unitYesSource unit
to_unitYesTarget unit

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler registered with @app.tool() that executes the temperature conversion by calling the core tool function and formats the response dictionary.
    @app.tool()
    def convert_temperature(
        value: Annotated[float, Field(description="Temperature value to convert")],
        from_unit: Annotated[TEMPERATURE_UNIT, Field(description="Source unit")],
        to_unit: Annotated[TEMPERATURE_UNIT, Field(description="Target unit")],
    ) -> dict:
        """Convert temperature between units."""
        converted_value = convert_temperature_tool(value, from_unit, to_unit)
        return {
            "original_value": value,
            "original_unit": from_unit,
            "converted_value": converted_value,
            "converted_unit": to_unit,
            "conversion_type": "temperature",
        }
  • Literal type definition for supported temperature units, used in the tool schema for input validation.
    TEMPERATURE_UNIT = Literal["celsius", "fahrenheit", "kelvin"]
  • Core helper function implementing the temperature unit conversion logic via intermediate conversion to Celsius.
    def convert_temperature_tool(
        value: float,
        from_unit: TEMPERATURE_UNIT,
        to_unit: TEMPERATURE_UNIT,
    ) -> float:
        """Convert temperature between units."""
    
        # Dictionary mapping units to their conversion functions to Celsius
        to_celsius: dict[TEMPERATURE_UNIT, Callable[[float], float]] = {
            "fahrenheit": _fahrenheit_to_celsius,
            "kelvin": _kelvin_to_celsius,
            "celsius": lambda x: x,
        }
    
        # Dictionary mapping units to their conversion functions from Celsius
        from_celsius: dict[TEMPERATURE_UNIT, Callable[[float], float]] = {
            "fahrenheit": _celsius_to_fahrenheit,
            "kelvin": _celsius_to_kelvin,
            "celsius": lambda x: x,
        }
    
        # Convert to Celsius first
        celsius = to_celsius[from_unit](value)
    
        # Convert from Celsius to target unit
        return from_celsius[to_unit](celsius)
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 but provides minimal information. It doesn't mention whether this is a read-only operation, what happens with invalid inputs, whether there are precision limitations, or what the output format will be. While the existence of an output schema helps, the description itself offers almost no behavioral context beyond the basic conversion function.

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 extremely concise - a single sentence that directly states the tool's purpose without any wasted words. It's front-loaded with the essential information and contains no unnecessary elaboration. This is an excellent example of efficient communication for a straightforward tool.

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

Completeness4/5

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

Given that this is a simple conversion tool with complete schema coverage and an output schema, the minimal description is reasonably complete. The agent can understand what the tool does and has full parameter documentation. However, the lack of any behavioral context (error handling, precision, limitations) prevents a perfect score, especially since no annotations are provided to fill those gaps.

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 schema description coverage is 100%, with all parameters well-documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema - it doesn't explain unit conventions, precision considerations, or special cases. With complete schema coverage, the baseline score of 3 is appropriate since the schema does the heavy lifting.

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 as converting temperature between units, which is a specific verb+resource combination. It distinguishes itself from sibling tools by focusing on temperature conversion rather than other measurement types like angle, area, or length. However, it doesn't explicitly differentiate from the generic 'convert_batch' tool which might also handle temperature conversions.

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 when to use 'convert_temperature' versus 'convert_batch' (which might handle batch conversions of multiple units), nor does it provide any context about prerequisites, limitations, or typical use cases. The agent receives no usage direction beyond the basic purpose statement.

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