|
|
ucon-tools |
Hostable interfaces for the ucon dimensional analysis engine.
Documentation · MCP Server Guide · Tool Reference
What is ucon-tools?
ucon is a unit-aware computation library for Python. ucon-tools packages it into interfaces that other systems can consume — MCP servers for AI agents, REST APIs for web services, CLIs for humans at a terminal.
Each interface lives under ucon.tools.<interface> and is installable as an optional extra:
| Interface | Package | Extra | Status |
|---|---|---|---|
| MCP server | ucon.tools.mcp |
ucon-tools[mcp] |
Available |
| REST API | ucon.tools.rest |
ucon-tools[rest] |
Planned |
| CLI | ucon.tools.cli |
ucon-tools[cli] |
Planned |
MCP Server
The MCP server gives AI agents (Claude, Cursor, and other MCP clients) dimensionally-verified unit conversion and computation.
Agent: "Convert 5 mcg/kg/min for an 80 kg patient to mL/h. Drug is 400 mg in 250 mL."
decompose → constraint solver places quantities, auto-bridges mcg→mg and min→h
compute → 5 × 80 kg × (60 min/h) × (1 mg/1000 mcg) × (250 mL/400 mg) = 15 mL/h
validate → result dimension matches expected unit ✓
Installation
pip install ucon-tools[mcp]
Requires Python 3.10+.
Configuration
Claude Desktop / Claude Code — add to your MCP configuration:
{
"mcpServers": {
"ucon": {
"command": "uvx",
"args": ["--from", "ucon-tools[mcp]", "ucon-mcp"]
}
}
}
Standalone:
ucon-mcp # stdio transport (default)
ucon-mcp --transport sse # SSE transport for remote clients
Tools
Core — conversion and computation:
| Tool | Description |
|---|---|
convert |
Convert a value between compatible units |
compute |
Multi-step factor-label calculation with dimensional tracking |
decompose |
Build a factor chain from natural-language or structured input |
check_dimensions |
Check if two units share the same dimension |
Discovery — explore the unit system:
| Tool | Description |
|---|---|
discover |
Unified discovery across topics: units, scales, dimensions, constants, formulas, quantity kinds, kind formulas, extended bases |
list_units |
Deprecated — use discover(topic="units"). List available units, optionally filtered by dimension |
list_scales |
Deprecated — use discover(topic="scales"). List SI decimal and binary prefixes |
list_dimensions |
Deprecated — use discover(topic="dimensions"). List available physical dimensions |
list_constants |
Deprecated — use discover(topic="constants"). List physical constants (CODATA 2022) |
list_formulas |
Deprecated — use discover(topic="formulas"). List registered domain formulas |
Runtime extension — add units and conversions per session:
| Tool | Description |
|---|---|
define |
Unified session definition: units, conversion edges, constants, quantity kinds, extended bases (kind="unit" | "conversion" | "constant" | "quantity_kind" | "basis") |
define_unit |
Deprecated — use define(kind="unit"). Register a custom unit for the session |
define_conversion |
Deprecated — use define(kind="conversion"). Add a conversion edge (linear or affine) |
define_constant |
Deprecated — use define(kind="constant"). Define a custom physical constant |
call_formula |
Call a registered dimensionally-typed formula |
reset_session |
Clear all session-defined units, conversions, and constants |
Kind-of-Quantity (KOQ) — semantic disambiguation:
| Tool | Description |
|---|---|
define_quantity_kind |
Deprecated — use define(kind="quantity_kind"). Register a quantity kind, optionally placed in the kind hierarchy |
declare_computation |
Deprecated — use validate_result(declared_kind=...). Declare expected quantity kind before computing |
validate_result |
Validate that a result matches the declared kind (dimension and kind) |
list_quantity_kinds |
Deprecated — use discover(topic="quantity_kinds"). List built-in and session-defined quantity kinds |
list_kind_formulas |
Deprecated — use discover(topic="kind_formulas"). List kind-arithmetic rules from the FormulaRegistry |
extend_basis |
Deprecated — use define(kind="basis"). Create an extended dimensional basis |
list_extended_bases |
Deprecated — use discover(topic="extended_bases"). List session-defined extended bases |
Unit systems — inspect and scope the active system:
| Tool | Description |
|---|---|
system |
Unified system operations: restrict, diff, compatibility check (action="restrict" | "diff" | "check_compatibility") |
restrict_system |
Deprecated — use system(action="restrict"). Restrict the active system to named units/dimensions |
diff_systems |
Deprecated — use system(action="diff"). Compare the session system against the process-base system |
check_compatibility |
Deprecated — use system(action="check_compatibility"). Check if the session system composes with the process-base without conflict |
All deprecated tools remain functional until v1.0.0 and return identical payloads to their replacements, leaving a ten-tool surface: convert, compute, decompose, check_dimensions, discover, define, system, call_formula, validate_result, reset_session. See ROADMAP.md for the migration table and what lands before then.
Architecture
The MCP server is embeddable: create_server(ServerConfig(...)) builds an independent server with your own base unit system, per-call instrumentation, and transport settings — see the embedding guide.
ucon-tools is an interface layer. It does not reimplement dimensional analysis — it delegates to ucon for all unit resolution, conversion, and dimensional algebra. What it adds is interface-specific logic: session state, protocol handling, error suggestions, and agent-oriented features like the decompose constraint solver and KOQ disambiguation.
┌───────────────────────────────────────────────────────┐
│ Clients │
│ MCP (Claude, Cursor) · HTTP · Terminal │
└──────────┬──────────────────┬──────────────┬──────────┘
│ │ │
┌──────────▼───┐ ┌──────────▼───┐ ┌───────▼──────┐
│ ucon.tools │ │ ucon.tools │ │ ucon.tools │
│ .mcp │ │ .rest │ │ .cli │
│ │ │ │ │ │
│ sessions │ │ (planned) │ │ (planned) │
│ decompose │ │ │ │ │
│ KOQ │ │ │ │ │
│ suggestions │ │ │ │ │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
└──────────────────┼─────────────────┘
│ Python imports
┌──────────▼──────────┐
│ ucon │
│ │
│ Units, Dimensions │
│ ConversionGraph │
│ Scales, Constants │
└─────────────────────┘
UnitSafe Benchmark
UnitSafe is a 500-problem metrological reasoning benchmark for evaluating how well AI models handle unit conversion, dimensional analysis, and kind-of-quantity discrimination. It ships with a runner that can evaluate any model with or without MCP tool augmentation.
pip install ucon-tools[benchmark]
# Bare evaluation (model solves from memory)
python benchmarks/unitsafe/run.py -m claude:claude-haiku-4-5-20251001
# Tool-augmented evaluation (model uses MCP tools)
python benchmarks/unitsafe/run.py -m claude:claude-haiku-4-5-20251001 \
--tools --mcp-url https://mcp.ucon.dev/mcp/<instance>/mcp
See benchmarks/unitsafe/ for the full dataset, runner, and evaluation protocol.
Development
make venv # Create virtual environment
source .ucon-tools-3.12/bin/activate # Activate
make test # Run tests
make test-all # Run across all supported Python versions
Running the MCP server locally
make mcp-server # Foreground (stdio)
make mcp-server-bg # Background
make mcp-server-stop # Stop background server
License
AGPL-3.0. See LICENSE.
Metadata
Release files for ucon-tools 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ucon_tools-0.13.0.tar.gz | 134.2 kB | Without provenance | Details for ucon_tools-0.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ucon_tools-0.13.0-py3-none-any.whl | Python 3 | none | any | Details for ucon_tools-0.13.0-py3-none-any.whl |
Total release size: 250.6 kB
Release files / ucon_tools-0.13.0.tar.gz
| Download URL | ucon_tools-0.13.0.tar.gz |
|---|---|
| Size | 134.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72a7b668aa23f3e170d4850242d6a8d7148cb7510cac6d024ff68d6ce7ba6fb1
|
|
BLAKE2b-256 checksum How to use checksums |
0b3dc8586e3adf018e021b4f260913729d8786390c39606704bcfcad6abb27f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / ucon_tools-0.13.0-py3-none-any.whl
| Download URL | ucon_tools-0.13.0-py3-none-any.whl |
|---|---|
| Size | 116.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
496bd5479884e465da2bb250bd6d23233e39b95b265ce75e202b60aef94e2124
|
|
BLAKE2b-256 checksum How to use checksums |
36f7c67d2b26e043fa7854c2cc8d9fe266800f1ee4aa097872cbca288baa256a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for ucon-tools 0.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.