mcpField
E
Euclid

Euclid

远程服务
github.com/euclidtools科研与教育230 周前更新
代码仓库

关于 Euclid

Euclid 是面向 AI Agent 的托管 MCP 服务,用确定性计算取代数值猜测。工具涵盖计算、单位换算、统计、金融、日期、编码、验证、颜色、正则表达式和地理空间操作。

主要功能

  1. 01确定性表达式计算
  2. 02单位换算与统计
  3. 03日期和金融计算
  4. 04编码、哈希和 JWT 检查
  5. 05正则表达式、验证、颜色及地理空间工具

适用场景

  1. 01计算算术和三角表达式
  2. 02换算单位或计算统计结果
  3. 03执行金融和日期计算
  4. 04验证格式或安全执行正则表达式

MCP 相关

Euclid 是通过 HTTP 接入的托管 MCP 服务,并使用 OAuth 2.1 进行身份验证。它向已连接的 Agent 提供确定性计算工具。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址https://mcp.euclidtools.com
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

工具

详细介绍

Euclid

“未经证明的断言,可以未经证明地驳回;而经证明的结论,历久弥坚。” 秉承亚历山大城的 Euclid 的精神

二十三个世纪前,亚历山大城的 Euclid 看到当时的数学深陷民间传说、直觉和“相信我”的泥沼,于是说:到此为止。他从头开始,基于公理和证明建立了几何学。如果某件事是真的,你就可以_证明_它是真的。不再含糊其辞,也不再靠猜测。

大模型面临着 Euclid 同时代的人们遇到的同一个问题。它们不会计算,只会_预测_。当你问一个大模型“247 × 389 是多少?”时,它会根据训练数据进行模式匹配,猜测答案可能是什么样子。有时正确,有时错误,而你永远无法分辨。

为 AI Agent 提供确定性计算工具。

Euclid 是一个托管的 MCP 服务,让任何 AI Agent 都能使用真正的确定性计算引擎。显而易见的事情不该靠猜,而算术就是最显而易见的事情之一。


快速开始

Claude Code
claude mcp add euclid --transport http https://mcp.euclidtools.com
Claude Desktop

将以下内容添加到 ~/Library/Application Support/Claude/claude_desktop_config.json(macOS)或 %APPDATA%\Claude\claude_desktop_config.json(Windows):

{
  "mcpServers": {
    "euclid": {
      "url": "https://mcp.euclidtools.com"
    }
  }
}
Cursor

将以下内容添加到项目根目录下的 .cursor/mcp.json(或全局配置文件 ~/.cursor/mcp.json):

{
  "mcpServers": {
    "euclid": {
      "url": "https://mcp.euclidtools.com"
    }
  }
}
Windsurf

将以下内容添加到 ~/.windsurf/mcp.json:

{
  "mcpServers": {
    "euclid": {
      "url": "https://mcp.euclidtools.com"
    }
  }
}
VS Code (Copilot)

将以下内容添加到项目中的 .vscode/mcp.json:

{
  "servers": {
    "euclid": {
      "type": "http",
      "url": "https://mcp.euclidtools.com"
    }
  }
}
其他 MCP 客户端

任何支持 HTTP 传输的 MCP 客户端都可以使用。将其指向:

https://mcp.euclidtools.com

身份验证通过 OAuth 2.1 自动完成。首次连接时,客户端会提示你登录。


验证是否正常工作

连接后,向你的 AI Agent 提问:

“247 乘以 389 等于多少?”

如果 Euclid 正常工作,Agent 会调用 calculate 工具,而不是预测答案。你会在回复中看到工具调用。正确答案是 96,083,与心算不同,它有保证。


问题所在

大模型具有非确定性。它们生成的每个词元都是一种_预测_,数学也不例外:

  • 247 × 389 → 模型_预测_为 96,083(有时会得到 96,183 或 95,983)
  • sin(47.3°) × cos(12.1°) → 模型_预测_出一个差不多的值
  • $8,472.50 的 15% → 模型_预测_出一个金额

有时预测正确,有时却会有细微错误。问题在于,你永远无法确定哪个是对的。

Euclid 让这不再成为问题。 AI Agent 可以使用 Euclid 时,会将表达式发送到真正的计算引擎,并返回计算结果。确定无误,每次都正确。

可以把它想成 grep 为 AI 代码搜索带来的改变:一种简单、经过验证的工具,为模型提供了它本质上缺乏的能力。


为什么不直接使用代码执行?

许多大模型环境都提供代码执行工具(Python 沙盒等),可以进行数学运算。区别如下:

代码执行Euclid
开销启动沙盒/解释器几乎为零:直接计算表达式字符串
延迟数百毫秒到数秒个位数毫秒
可用性因客户端而异任何 MCP 客户端
模型行为模型编写进行数学运算的_代码_模型编写_数学表达式_
故障模式语法错误、运行时异常提供提示和示例的明确错误信息
词元成本生成代码较为冗长表达式字符串精简

强制使用确定性计算

安装 Euclid 后,你的 AI 就能使用计算器。但仅有访问权限还不够:你还需要指示 AI 使用它。没有明确的指令,模型默认仍会根据训练数据预测数学结果。

将以下内容添加到项目的 AI 指令文件中。预置版本位于 rules/ 目录:

文件适用对象
rules/CLAUDE.mdClaude Code
rules/AGENTS.mdOpenAI Codex
rules/.cursorrulesCursor
rules/.windsurfrulesWindsurf

这些文件的内容相同。将与你的 IDE 对应的文件复制到项目根目录,或将其追加到现有指令文件中。

预览指令内容
## Deterministic Computation (Euclid)

**NEVER predict, guess, or mentally compute numerical results.** LLMs produce answers by
pattern-matching against training data, sometimes right, sometimes subtly wrong, and
there is no way to tell which. Always use Euclid's MCP tools instead.

| Tool         | When to Use                                                                                                                            |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| `calculate`  | Arithmetic, percentages, margins, exponents, trig, logarithms, factorials. Any expression with a numerical answer                     |
| `convert`    | Unit conversions: m² to acres, km to miles, L/hr to gal/hr, °C to °F, bytes to kB, etc.                                               |
| `statistics` | Mean, median, mode, std deviation, variance, percentile, min, max, sum. Plus t-test, z-test, chi-squared, confidence intervals, correlation |
| `datetime`   | Date differences, add/subtract time, business days, age, day of week, quarter, leap year. Any calendar arithmetic                     |
| `encode`     | Base64, hex, URL, HTML encoding/decoding; SHA-256/512, SHA-1, MD5 hashing; HMAC signatures; JWT decoding                               |
| `finance`    | Loan payments, amortization, present/future value, NPV, IRR, CAGR, margin/markup, compound interest. Any financial formula             |
| `regex`      | Pattern testing, text extraction, match-all, replace, split. Execute patterns, never predict whether they match                        |
| `color`      | Color conversion (hex, RGB, HSL, etc.), contrast ratios, WCAG accessibility, lighten/darken, palette generation                        |
| `validate`   | Email, URL, UUID, credit card (Luhn check), IPv4, IPv6, IBAN. Structural validation with check digits                                  |
| `geo`        | Distances (Haversine/Vincenty), bearings, midpoints, destination points, polygon area, point-in-polygon, coordinate conversions        |

This applies everywhere, not just code. Analytics, business metrics, growth rates,
marketing numbers, cost calculations, date arithmetic, financial projections during
conversation. If there is a number to compute, a date to calculate, or data to
encode, hash, or validate, use Euclid. No exceptions.

**重要性:**大模型会自信地给出错误的算术结果,却不会表现出任何错误迹象。返回 247 × 389 = 96,183 的模型,看起来与返回正确结果 96,083 的模型一样自信。保证正确的唯一方法是进行计算,而不是预测。


工具

Euclid 提供 10 个工具。

calculate

确定性地计算数学表达式。

calculate("(245 * 389) + (12^3 / 7)")  → 95,551.857...
calculate("sqrt(144)")                  → 12
calculate("sin(45 deg)")                → 0.707...
calculate("10!")                         → 3,628,800
calculate("e^(i * pi) + 1")            → 0  (Euler's identity)

支持:算术、运算顺序、指数、根、三角函数、对数、阶乘、常量(pi、e、phi)、复数、Unicode 数学符号(×、÷、√、π、²、³)。

convert

确定性地进行单位换算。

convert(100, "fahrenheit", "celsius")   → 37.778
convert(5, "km", "miles")              → 3.107
convert(1024, "bytes", "kB")           → 1.024
convert(60, "mph", "km/h")             → 96.561

支持:长度、质量、体积、温度、面积、速度、时间、数据,以及 100 多种单位。自然语言别名(例如“celsius”“miles per hour”)会自动规范化。

statistics

描述性和推断性统计计算。

statistics("mean", [23, 45, 12, 67, 34])          → 36.2
statistics("std", [23, 45, 12, 67, 34])            → 21.159
statistics("z_test_proportion", { ... })            → { significant: true, p_value: 0.023 }
statistics("confidence_interval", { data: [...] })  → { lower: 28.1, upper: 44.3 }

描述性统计:均值、中位数、众数、标准差、方差、最小值、最大值、总和、百分位数。 推断性统计:z 检验、t 检验、卡方检验、置信区间、相关性、正态分布累积分布函数/反函数。

datetime

确定性地进行日期和时间运算。

datetime("difference", { from: "2026-01-01", to: "2026-03-15", unit: "days" })  → 73
datetime("add", { date: "2026-01-01", amount: 90, unit: "days" })               → "2026-04-01"
datetime("age", { birthDate: "1990-06-15", asOf: "2026-03-21" })                → 35
datetime("business_days", { from: "2026-01-01", to: "2026-01-31" })             → 22

9 种操作:差值、加、减、工作日、月天数、年龄、季度、星期几、是否为闰年。

encode

确定性地进行编码、解码、哈希计算和 JWT 检查。

encode("base64_encode", { input: "hello world" })               → "aGVsbG8gd29ybGQ="
encode("sha256", { input: "hello world" })                      → "b94d27b9..."
encode("hmac", { input: "data", key: "secret", algorithm: "sha256" }) → "1b779..."
encode("jwt_decode", { input: "eyJhbGci..." })                  → { header, payload, signature }

16 种操作:base64、base64url、hex、url、html(编码/解码)、sha256、sha512、sha1、md5、hmac、jwt_decode。

finance

使用任意精度十进制算术进行金融计算。

finance("loan_payment", { principal: 350000, rate: 6.5, periods: 360 })   → $2,212.24/mo
finance("irr", { cashflows: [-100000, 30000, 35000, 40000, 45000] })      → 17.094%
finance("compound_growth", { start_value: 2.1M, end_value: 4.8M, periods: 4 }) → 22.958% CAGR

16 种操作:贷款还款额、摊销、现值、未来值、期数、利率、净现值、内部收益率、投资回报率、加价、利润率、折扣、百分比变化、复合增长、单利、复利。

color

颜色转换、无障碍检查和调色板生成。

color("convert", { color: "#FF6B35", to_space: "hsl" })
color("contrast_ratio", { foreground: "#FFFFFF", background: "#2563EB" })  → "4.62:1"
color("wcag_level", { foreground: "#FFFFFF", background: "#2563EB" })      → "AA"
color("analogous", { color: "#2563EB", count: 5 })

提供 14 种操作,涵盖转换、无障碍(WCAG)、调整和调色板生成。支持 8 种颜色空间:hex、rgb、hsl、hsv、cmyk、lab、oklab、oklch。

regex

安全地执行正则表达式(保证线性时间,不会遭受 ReDoS 攻击)。

regex("test", { pattern: "^\\d{3}-\\d{4}$", subject: "555-1234" })     → true
regex("matchAll", { pattern: "\\d+", subject: "abc 123 def 456" })     → ["123", "456"]
regex("replace", { pattern: "\\s+", subject: "a  b  c", replacement: " " }) → "a b c"

6 种操作:测试、匹配、匹配全部、替换、拆分、转义。

validate

使用校验位进行结构验证。

validate("email", { input: "[email protected]" })        → { valid: true }
validate("credit_card", { input: "4111111111111111" })   → { valid: true, type: "Visa" }
validate("iban", { input: "GB82WEST12345698765432" })    → { valid: true }

格式:电子邮件、url、uuid、信用卡(Luhn)、ipv4、ipv6、iban。

geo

地理空间计算。

geo("distance", { from: [lat, lon], to: [lat, lon] })        → km (Haversine or Vincenty)
geo("bearing", { from: [lat, lon], to: [lat, lon] })         → degrees
geo("point_in_polygon", { point: [lat, lon], polygon: [...] }) → true/false

距离、面积、中点、方位角、目标点、点是否在多边形内、坐标转换。


定价

每个账户初始均可免费调用工具 1,000 次。无需信用卡。

之后可在 app.euclidtools.com 充值额度。


理念

大模型生成的所有内容都是一种预测。对于创意写作和推理来说,这没问题。但对于数学来说,这就是个问题。

解决方案不是让模型更擅长预测数学结果,而是给它一个计算器。

这体现了一条更广泛的原则:凡是模型需要以预测方式完成、但结果本应确定的任务,都应该给它一个确定性工具。 数学是最明显的例子,但同样的道理也适用于单位换算、日期运算、正则表达式求值、编码等。


许可证

Euclid MCP 服务是专有软件。本仓库包含用于集成的连接说明、技能和文档。

保留所有权利。详情请参阅 LICENSE。


亚历山大的欧几里得在 2,300 年前将数学证明形式化。
我们只是把他的工具交给机器。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。