Skip to main content
Glama

validate_expression

Validate mathematical expressions for syntax and symbol consistency, with optional dimensional analysis. Returns validity, issues, and warnings.

Instructions

    Validate a mathematical expression for correctness.

    Checks syntax, symbol consistency, and optionally dimensional consistency.

    Args:
        expression: Expression to validate
        expected_symbols: List of symbols that should appear
        check_dimensions: Whether to perform dimensional analysis
        units_map: Map of symbol to unit (e.g., {"v": "m/s", "m": "kg"})

    Returns:
        Validation result with:
        - valid: Whether expression is valid
        - issues: List of issues found
        - warnings: Non-critical warnings

    Examples:
        validate_expression("F = m*a", expected_symbols=["F", "m", "a"])
        → {"valid": True, ...}

        validate_expression("F = m*a + v", units_map={"F": "N", "m": "kg", "a": "m/s²", "v": "m/s"})
        → {"valid": False, "issues": ["Dimension mismatch: m*a (N) + v (m/s)"]}
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
units_mapNo
expressionYes
check_dimensionsNo
expected_symbolsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior4/5

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

With no annotations, the description carries the full burden and provides useful disclosure: it checks syntax and symbol consistency, optionally performs dimensional analysis, and returns a validation result with valid/issues/warnings. Examples illustrate behavior for both valid and invalid expressions. However, it does not clarify how check_dimensions and units_map interact (e.g., whether units_map implicitly triggers dimension checking), leaving a minor gap.

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 concise, well-structured with clear sections (Args, Returns, Examples), and every sentence adds value. Two examples illustrate both successful and failing cases without unnecessary detail.

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?

The description covers the main use case, parameters, return values, and examples. However, there is an ambiguity: the second example uses units_map without explicitly setting check_dimensions=True, yet reports a dimension mismatch, leaving the user unsure about when dimensional checking actually triggers. Output schema exists but the description still explains returns, so this is only a partial gap.

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?

Schema coverage is 0%, but the description adds thorough meaning: the Args section documents each parameter with its type and purpose, and examples show expected format (e.g., units_map as a dict mapping symbols to units, expected_symbols as a list). This fully compensates for the schema's lack of descriptive detail.

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 validates mathematical expressions, specifying it checks syntax, symbol consistency, and optionally dimensional consistency. This distinguishes it from sibling tools like parse_expression or check_dimensions by covering multiple validation aspects in one tool.

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

Usage Guidelines3/5

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

The description implies a general validation use case but does not explicitly state when to prefer this tool over alternatives such as parse_expression or check_dimensions. It gives no exclusions or comparisons, so usage guidance is only implied.

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/u9401066/nsforge-mcp'

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