Skip to main content
Glama
liusicheng

MCP Weather Server

by liusicheng

temperature_convert

Convert temperatures between Celsius and Fahrenheit by providing a numeric value and the original unit (C or F).

Instructions

摄氏度与华氏度互相转换。

参数:
    value: 温度数值
    from_unit: 原始单位,C 表示摄氏度,F 表示华氏度

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYes
from_unitYes

Implementation Reference

  • The temperature_convert tool handler function that converts Celsius to Fahrenheit and vice versa. Registered via @mcp.tool() decorator on line 92. Accepts a float value and a from_unit string ('C' or 'F'), returns a dict with input/output strings or an error.
    @mcp.tool()
    def temperature_convert(value: float, from_unit: str) -> dict:
        """摄氏度与华氏度互相转换。
    
        参数:
            value: 温度数值
            from_unit: 原始单位,C 表示摄氏度,F 表示华氏度
        """
        if from_unit.upper() == "C":
            result = value * 9 / 5 + 32
            return {"input": f"{value}°C", "output": f"{result:.1f}°F"}
        elif from_unit.upper() == "F":
            result = (value - 32) * 5 / 9
            return {"input": f"{value}°F", "output": f"{result:.1f}°C"}
        else:
            return {"error": "from_unit 必须是 C 或 F"}
  • server.py:92-92 (registration)
    The @mcp.tool() decorator registers temperature_convert as an MCP tool on the FastMCP server instance.
    @mcp.tool()
  • Duplicate of temperature_convert in the remote/HTTP version of the server (server_remote.py). Same logic, registered via @mcp.tool() on line 90.
    @mcp.tool()
    def temperature_convert(value: float, from_unit: str) -> dict:
        """摄氏度与华氏度互相转换。
    
        参数:
            value: 温度数值
            from_unit: 原始单位,C 表示摄氏度,F 表示华氏度
        """
        if from_unit.upper() == "C":
            result = value * 9 / 5 + 32
            return {"input": f"{value}°C", "output": f"{result:.1f}°F"}
        elif from_unit.upper() == "F":
            result = (value - 32) * 5 / 9
            return {"input": f"{value}°F", "output": f"{result:.1f}°C"}
        else:
            return {"error": "from_unit 必须是 C 或 F"}
  • server_remote.py:90-90 (registration)
    The @mcp.tool() decorator registers temperature_convert in the remote HTTP-based server.
    @mcp.tool()
Behavior4/5

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

No annotations are provided, so the description must disclose behavioral traits. It correctly identifies a pure conversion function with no side effects. It does not mention any limitations (e.g., no time-related inputs), but the behavior is straightforward and well-described.

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: one sentence for purpose and a simple list for parameters. Every word adds value, and the structure is front-loaded with the core action.

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

Completeness5/5

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

Given the tool's simplicity (two parameters, no output schema, no nested objects), the description is fully complete. It explains what the tool does, what inputs are needed, and how to use them. No additional context is required.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It explains 'value' as numeric temperature and 'from_unit' as 'C' or 'F'. While it does not specify case sensitivity or exact valid values, it adds sufficient meaning beyond the raw JSON schema.

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

Purpose5/5

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

The description explicitly states '摄氏度与华氏度互相转换' (converts between Celsius and Fahrenheit), using a specific verb and resource. It clearly distinguishes from sibling tools like get_forecast and get_weather, which are weather data services.

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

Usage Guidelines4/5

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

The description provides clear parameter explanations but does not explicitly state when to use this tool versus alternatives. However, given the sibling tools are about weather forecasts, the conversion context is clear enough for an AI to infer appropriate usage.

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/liusicheng/mcp-weather'

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