Skip to main content
Glama
abellmugano

quantity-engine

Quantity Engine — MCP Server

An MCP (Model Context Protocol) server that performs dimensional calculation and unit conversion with evidence and reproducibility.

Solves silent unit errors in LLM agent chains. 20 m/s × 3 h returns 216 km with evidence, not a plausible-looking wrong number.

MCP usage

The server exposes one MCP tool: quantity_execute. It runs over stdio and follows the MCP protocol via the official Python SDK (mcp).

Register with any MCP client.

Claude Desktop

claude_desktop_config.json:

{
  "mcpServers": {
    "quantity-engine": {
      "command": "python",
      "args": ["/absolute/path/to/mcp_server.py"]
    }
  }
}

Cursor / VS Code / Continue

Same shape — command, args, no env required.

Manual run

pip install -r requirements.txt
python mcp_server.py

The server listens on stdio. Ctrl+C to stop.

Related MCP server: SharkMath MCP

Tool contract

tool.json defines quantity_execute with input and output schemas. The MCP server registers this tool and forwards calls to the engine unchanged — no interpretation, no fallback.

Example call:

{
  "operations": [
    {"id": "s0", "op": "mul",
     "a": {"value": 20, "unit": "m/s"},
     "b": {"value": 3, "unit": "h"}},
    {"id": "s1", "op": "convert",
     "a": {"ref": "s0", "as": "km"}, "to": "km"}
  ]
}

Returns 216 km with exactness, error_bound if approximated, and full_evidence_hash for replay of the evidence.

What the engine does

  • Exact rational arithmetic (no float drift)

  • Explicit precision policy (EXACT vs APPROXIMATED with error_bound)

  • Provenance hash (full_evidence_hash) for replay of the evidence

  • Structured failure taxonomy (MISSING_UNIT_DECLARATION, NEEDS_CLARIFICATION, NEEDS_REFERENCE_DATA, DIMENSION_MISMATCH_UNBRIDGEABLE, ...)

  • Money as separate domain with temporal context (stub)

Evidence is not correctness. The hash proves what inputs, versions, and reference data were used, and allows the same operation to be replayed against the same evidence. Mathematical correctness rests on the dimensional model, the engine rules, and the test suite — not on the hash.

Layout

quantities.py      engine (zero external dependencies)
tool.json          MCP tool contract
mcp_server.py      MCP stdio transport (uses mcp, jsonschema)
requirements.txt   mcp, jsonschema — only needed for the MCP transport
Dockerfile         container for MCP deployment

Status

MVP. 8 tests passing (python quantities.py). Not production. FX rates are stub.

License

Apache 2.0.

Available Tools

1 tool
quantity_executeA

Execute dimensional calculation and unit conversion with audit evidence. Input: sequence of typed operations (mul, convert). Output: result value with unit, precision metadata, and reproducibility hash, or a structured failure.

ParametersJSON Schema
NameRequiredDescriptionDefault
precisionNo
operationsYes

TDQS

A3.5/5.0
Behavior4/5

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

With no annotations, the description carries the behavioral burden, and it does disclose important traits: input consists of typed operations, output includes a reproducibility hash and precision metadata, and failures are structured. It does not explicitly state that the operation is pure or side-effect-free, but the calculation/conversion framing strongly implies it.

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 two sentences with no wasted words. It front-loads the function, then gives compact input and output summaries. Every sentence contributes useful information.

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 gives a solid overview of behavior and output, but the tool has nested objects, a referenced $defs for operands, and no output schema. It omits details about constructing operations, interpreting precision metadata, and what 'structured failure' contains, leaving an agent without enough context for fully correct invocation in edge cases.

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

Parameters2/5

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

Schema description coverage is 0%, so the description needed to explain the parameters, but it only mentions a 'sequence of typed operations (mul, convert)' and 'precision metadata.' It does not explain the structure of each operation, the operand references, the meaning of 'to' or 'at', or how precision settings affect results. This is insufficient for a nested schema with two parameters.

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 states a specific function: execute dimensional calculation and unit conversion with audit evidence, and it also summarizes inputs and outputs. It is clear about what the tool does, though the verb 'execute' is generic and there are no sibling tools to differentiate from.

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 usage through its input/output specification, but it does not explicitly state when to choose this tool, when not to use it, or any prerequisites. With no sibling tools, the lack of alternatives is less damaging, but guidance still remains implicit rather than explicit.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev0.1.0
    • First observedquantity_execute

TDQS

A3.5/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of confusing it with another. The purpose of quantity_execute is singular and clearly described.

Naming Consistency4/5

There is no naming pattern to evaluate with a single tool, but the name quantity_execute follows a noun_verb structure that aligns with the server name and is not inconsistent with any convention.

Tool Count3/5

One tool is at the low end of acceptable for a focused utility. It feels thin for a general-purpose quantity engine, but the tool's multi-step operation input partially compensates for the lack of separate tools.

Completeness2/5

The tool only supports multiplication and conversion operations, leaving out common dimensional operations like addition, subtraction, and division. This is a significant gap for a quantity engine.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Verified unit conversion and dimensional analysis for AI agents. 190+ units, 31 domain formulas (clinical, physics, aerospace, SRE), physical constants with uncertainty propagation. Refuses invalid conversions structurally: the tool that won't convert mg to mL and knows the difference between torque and energy.
    AGPL 3.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server providing 150+ mathematical functions across arithmetic, trigonometry, statistics, unit conversions, and more, consolidated into 15 powerful tools for seamless integration with VS Code Copilot and other MCP-compatible clients.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    An MCP server that provides deterministic unit conversions backed by Pint, enabling exact unit conversions, compatibility checks, and parsing of quantities for LLMs.
    5
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A stdio MCP server that gives LLMs a safe scientific calculator with infix math, complex numbers, matrices, statistics, unit conversions, and more via tools that return JSON.
    33
    1
    MIT