Skip to main content
Glama
sdiehl
by sdiehl

convert_to_units

Convert quantities to specified units using sympy.physics.units. Supports SI, CGS, and compound units for precise unit transformations in symbolic algebra.

Instructions

Converts a quantity to the given target units using sympy.physics.units.convert_to.

Args:
    expr_key: The key of the expression (previously introduced) to convert.
    target_units: List of unit names as strings (e.g., ["meter", "1/second"]).
    unit_system: Optional unit system (from UnitSystem enum). Defaults to SI.

The following units are available by default:
    SI base units: meter, second, kilogram, ampere, kelvin, mole, candela
    Length: kilometer, millimeter
    Mass: gram
    Energy: joule
    Force: newton
    Pressure: pascal
    Power: watt
    Electric: coulomb, volt, ohm, farad, henry
    Constants: speed_of_light, gravitational_constant, planck

IMPORTANT: For compound units like meter/second, you must separate the numerator and
denominator into separate units in the list. For example:
- For meter/second: use ["meter", "1/second"]
- For newton*meter: use ["newton", "meter"]
- For kilogram*meter²/second²: use ["kilogram", "meter**2", "1/second**2"]

Example:
    # Convert speed of light to kilometers per hour
    expr_key = introduce_expression("speed_of_light")
    result = convert_to_units(expr_key, ["kilometer", "1/hour"])
    # Returns approximately 1.08e9 kilometer/hour

    # Convert gravitational constant to CGS units
    expr_key = introduce_expression("gravitational_constant")
    result = convert_to_units(expr_key, ["centimeter**3", "1/gram", "1/second**2"], UnitSystem.CGS)

SI prefixes (femto, pico, nano, micro, milli, centi, deci, deca, hecto, kilo, mega, giga, tera)
can be used directly with base units.

Returns:
    A key for the converted expression, or an error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expr_keyYes
target_unitsYes
unit_systemNo
Behavior4/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 does well by explaining the return behavior ('Returns: A key for the converted expression, or an error message'), listing available units, detailing compound unit formatting rules, and mentioning SI prefixes. It also references dependencies on other tools ('introduce_expression'). The main gap is lack of information about error conditions beyond the generic mention.

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

Conciseness4/5

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

The description is well-structured with clear sections (Args, unit listings, formatting rules, example, Returns). Most sentences earn their place by providing essential information. However, the unit listing section is quite lengthy and could potentially be summarized or referenced rather than enumerated, slightly affecting conciseness.

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 the complexity of unit conversion with formatting rules and dependencies on other tools, the description is quite complete. It covers parameters thoroughly, explains the workflow, provides examples, and describes return behavior. The main gap is the lack of output schema, but the description compensates by explaining the return value. Some edge cases around error conditions could be more explicit.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by providing detailed semantics for all 3 parameters. It explains 'expr_key' as referencing previously introduced expressions, 'target_units' with formatting rules and examples, and 'unit_system' with its optional nature and default. The description adds substantial value beyond the bare schema, including examples and unit listings.

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 clearly states the tool's purpose with specific verbs ('converts a quantity') and resources ('using sympy.physics.units.convert_to'). It distinguishes itself from sibling tools by focusing on unit conversion rather than mathematical operations like differentiation, integration, or solving equations. The description explicitly mentions the underlying library and conversion functionality.

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 context about when to use this tool by explaining it converts previously introduced expressions (referencing 'expr_key' from 'introduce_expression'). It includes an example showing the workflow with 'introduce_expression' first. However, it doesn't explicitly state when NOT to use this tool or mention alternatives among the siblings, though the distinct purpose makes alternatives less relevant.

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

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/sdiehl/sympy-mcp'

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