ucon-mcp
ucon-tools
用于 ucon 量纲分析引擎的可托管接口。
什么是 ucon-tools?
ucon 是一个用于 Python 的单位感知计算库。ucon-tools 将其封装为其他系统可以使用的接口——包括用于 AI 智能体的 MCP 服务器、用于 Web 服务的 REST API,以及用于终端用户的 CLI。
每个接口都位于 ucon.tools.<interface> 下,并可作为可选扩展进行安装:
接口 | 包 | 扩展 | 状态 |
MCP 服务器 |
|
| 可用 |
REST API |
|
| 计划中 |
CLI |
|
| 计划中 |
Related MCP server: Touchstone MCP Server
MCP 服务器
MCP 服务器为 AI 智能体(Claude、Cursor 和其他 MCP 客户端)提供经过量纲验证的单位换算和计算功能。
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 ✓安装
pip install ucon-tools[mcp]需要 Python 3.10+。
配置
Claude Desktop / Claude Code — 添加到您的 MCP 配置中:
{
"mcpServers": {
"ucon": {
"command": "uvx",
"args": ["--from", "ucon-tools[mcp]", "ucon-mcp"]
}
}
}独立运行:
ucon-mcp # stdio transport (default)
ucon-mcp --transport sse # SSE transport for remote clients工具
核心 — 换算与计算:
工具 | 描述 |
| 在兼容单位之间转换数值 |
| 带有量纲跟踪的多步因子标签计算 |
| 从自然语言或结构化输入构建因子链 |
| 检查两个单位是否具有相同的量纲 |
发现 — 探索单位系统:
工具 | 描述 |
| 列出可用单位,可选择按量纲过滤 |
| 列出 SI 十进制和二进制前缀 |
| 列出可用的物理量纲 |
| 列出物理常数 (CODATA 2022) |
| 列出已注册的领域公式 |
运行时扩展 — 按会话添加单位和换算:
工具 | 描述 |
| 为当前会话注册自定义单位 |
| 添加换算关系(线性或仿射) |
| 定义自定义物理常数 |
| 调用已注册的带量纲类型的公式 |
| 清除所有会话定义的单位、换算和常数 |
量纲种类 (KOQ) — 语义消歧:
工具 | 描述 |
| 注册用于消歧的量纲种类 |
| 在计算前声明预期的量纲种类 |
| 验证结果是否符合声明的种类 |
| 列出已注册的量纲种类 |
| 创建扩展量纲基底 |
| 列出会话定义的扩展基底 |
架构
ucon-tools 是一个接口层。它不会重新实现量纲分析,而是将所有单位解析、换算和量纲代数委托给 ucon。它增加的是特定于接口的逻辑:会话状态、协议处理、错误建议,以及面向智能体的功能,如 decompose 约束求解器和 KOQ 消歧。
┌───────────────────────────────────────────────────────┐
│ 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 基准测试
UnitSafe 是一个包含 500 个问题的计量推理基准测试,用于评估 AI 模型处理单位换算、量纲分析和量纲种类辨别的能力。它附带一个运行器,可以评估任何带有或不带有 MCP 工具增强的模型。
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请参阅 benchmarks/unitsafe/ 获取完整数据集、运行器和评估协议。
开发
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在本地运行 MCP 服务器
make mcp-server # Foreground (stdio)
make mcp-server-bg # Background
make mcp-server-stop # Stop background server许可证
AGPL-3.0。请参阅 LICENSE。
This server cannot be deployed
Maintenance
Related MCP Connectors
60+ units, live FX, timezones, and date arithmetic for AI agents.
Precision math engine for AI agents. 203 exact methods. Zero hallucination.
500+ deterministic tools for AI agents: math, conversion, validation, hashing, encoding, date/time.
AI-callable calculators and engineering models with real formulas. No hallucinated math.
Related MCP Servers
- AlicenseAqualityCmaintenanceUnit converter for AI agents, powered by the GNU units database — convert 3000+ units of measurement, evaluate compound unit expressions, reduce to SI base units, dimensional analysis. Offline, deterministic.61GPL 3.0
- AlicenseNot gradedqualityCmaintenanceProvides deterministic, verifiable text/code/measurement utilities for AI agents, enabling tasks like unit conversion, citation formatting, diffing, proofreading, readability scoring, and syntax checking with re-executable proof.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to convert between measurement units across length, weight, temperature, volume, speed, and data storage, with formulas included. Supports pay-per-call access via x402 micropayments without API keys or signup.MIT
- AlicenseNot gradedqualityAmaintenanceProvides exact, deterministic tools for math, dates, units, validation, and more to AI agents, returning precise answers with explicit assumptions and warnings instead of model guesses.MIT