Skip to main content
Glama

Evaluate expression

eval_expression
Read-onlyIdempotent

Evaluate a single JSONata expression against a sample input document and return the computed value, or the exact compile/eval error. Write the expr exactly as in a derivation/constraint 'expr': bare dot-paths, no leading $ (e.g. "loan.amount * loan.annualRate / 1200"). Use this to verify an expression before putting it in a spec — it uses the same compiler the runtime validates against. If the expression calls a library function, pass the model's library definition as 'library' — without it every $myFn(...) call fails as undefined.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exprYesA single JSONata expression (bare dot-paths, no leading $).
inputNoSample document the expression runs against (full nested shape, e.g. {"loan": {"amount": 20000}}). Optional; defaults to {}.
libraryNoOptional JSONata library definition expression whose exports are bound while evaluating, e.g. "( $money := function($n){ $round($n,2) }; [\"money\"] )". Pass it when the expression calls $myFn(...).
constantsNoOptional constants bound as $const while evaluating (and while defining the library).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okNoTrue when the expression compiled and evaluated.
errorNo'compile' or 'evaluation' when ok is false.
messageNoThe compile/eval error message when ok is false.
undefinedNoTrue when the result is JSONata 'undefined' (no match).

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint=false, so the safety profile is covered. The description adds valuable behavioral context: it returns either the computed value or the exact error, warns that missing library causes undefined function calls, and explains the effect of constants. It does not contradict any annotation, and the added detail goes beyond what annotations provide.

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 well-structured and front-loaded with the core purpose, followed by crucial usage guidance. Each sentence serves a purpose: defining output, giving syntax examples, explaining when to use it, and handling library functions. No filler or redundancy, and it remains compact despite covering four parameters.

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?

The description is complete for a tool with four parameters. It covers expression syntax and formatting, default behavior for input, library handling and consequences, and constants binding. The output schema handles return value details, so the description does not need to. An agent can confidently invoke the tool correctly based on this description alone.

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 description coverage is 100%, so the baseline is 3, but the description significantly elevates it. It provides a concrete example for expr ('loan.amount * loan.annualRate / 1200'), explains the library syntax with a full example, and clarifies how constants are bound. These practical details add meaning beyond the schema's property descriptions, helping an agent construct correct inputs.

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 evaluates a JSONata expression against a sample document and returns the computed value or the exact compile/eval error. It also ties the behavior to the runtime compiler, making the purpose distinct and specific. The verb 'evaluate' and target resource 'expression' are unambiguous, and it stands apart from sibling tools like test_spec or validate_spec.

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 explicitly instructs when to use the tool: 'Use this to verify an expression before putting it in a spec' and explains why it is reliable ('uses the same compiler the runtime validates against'). It also gives guidance on when to pass the library parameter. It does not mention when not to use it or name alternatives, but the provided guidance is sufficient for the typical use case.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A3.9/5.0
Disambiguation4/5

Most tools have clearly distinct purposes, but get_audit explicitly subsumes get_history and explain, and get_state with paths overlaps get_field, creating minor selection ambiguity. The detailed descriptions help, but an agent could still reach for the wrong getter.

Naming Consistency4/5

Naming is overwhelmingly consistent: snake_case with verb_noun structure and coherent get_/create_/delete_ clusters. Minor deviations like bare verbs (mutate, explain, restore, snapshot) and eval instead of evaluate prevent a perfect score.

Tool Count3/5

27 tools is above the comfortable range and feels heavy, especially with several overlapping audit/state getters that could be consolidated. That said, the domain is broad enough that the count is defensible, so it is heavy but not chaotic.

Completeness4/5

The tool set covers the full model lifecycle well: create, validate, test, mutate, evolve, read, delete, plus snapshot/restore, audit, blobs, views, library, and expression evaluation. Minor gaps like explicit export/import or separate view-management tools are workable around.