@euclid-tools/euclid 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "euclid",
3
+ "displayName": "Euclid",
4
+ "description": "Deterministic math tools for LLMs — MCP server + skills that teach Claude to use calculate, convert, and statistics tools instead of mental math",
5
+ "version": "0.2.0",
6
+ "author": {
7
+ "name": "Angus"
8
+ },
9
+ "homepage": "https://github.com/euclidtools/euclid",
10
+ "repository": "https://github.com/euclidtools/euclid",
11
+ "license": "MIT",
12
+ "keywords": ["math", "calculator", "mcp", "deterministic", "mathjs"],
13
+ "skills": "./skills/",
14
+ "hooks": "./hooks/hooks.json"
15
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Euclid Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,338 @@
1
+ # Euclid
2
+
3
+ > _"What is asserted without proof can be dismissed without proof — but what is proved, endures."_
4
+ > — In the spirit of Euclid of Alexandria
5
+
6
+ Twenty-three centuries ago, Euclid of Alexandria looked at the mathematics of his time — a tangle of folklore, intuition, and "trust me" — and said: _no more_. He built geometry from the ground up on axioms and proofs. If something was true, you could _show_ it was true. No hand-waving. No guessing.
7
+
8
+ Large language models have the same problem Euclid's contemporaries did. They don't calculate — they _predict_. When you ask an LLM "what's 247 x 389?", it pattern-matches against its training data and guesses what the answer probably looks like. Sometimes right, sometimes wrong. You'd never know the difference.
9
+
10
+ **Deterministic math tools for LLMs.**
11
+
12
+ Euclid is an open source [MCP server](https://modelcontextprotocol.io) and [Claude Code plugin](https://docs.anthropic.com/en/docs/claude-code/plugins) that gives any LLM access to a real, deterministic math engine. What is self-evident should not be guessed — and arithmetic is about as self-evident as it gets.
13
+
14
+ ---
15
+
16
+ ## Installation
17
+
18
+ ### Claude Code (Recommended)
19
+
20
+ ```bash
21
+ claude plugin install euclidtools/euclid
22
+ ```
23
+
24
+ One command. This installs the skill (teaches Claude when to use Euclid) and auto-registers the MCP server.
25
+
26
+ ### Manual MCP Registration (Claude Code)
27
+
28
+ ```bash
29
+ claude mcp add euclid -- npx -y @euclid-tools/euclid
30
+ ```
31
+
32
+ ### Claude Desktop
33
+
34
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
35
+
36
+ <details>
37
+ <summary>macOS / Linux</summary>
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "euclid": {
43
+ "command": "npx",
44
+ "args": ["-y", "@euclid-tools/euclid"]
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ </details>
51
+
52
+ <details>
53
+ <summary>Windows</summary>
54
+
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "euclid": {
59
+ "command": "cmd",
60
+ "args": ["/c", "npx", "-y", "@euclid-tools/euclid"]
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ </details>
67
+
68
+ ### Cursor
69
+
70
+ Add to `~/.cursor/mcp.json`:
71
+
72
+ <details>
73
+ <summary>macOS / Linux</summary>
74
+
75
+ ```json
76
+ {
77
+ "mcpServers": {
78
+ "euclid": {
79
+ "command": "npx",
80
+ "args": ["-y", "@euclid-tools/euclid"]
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ </details>
87
+
88
+ <details>
89
+ <summary>Windows</summary>
90
+
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "euclid": {
95
+ "command": "cmd",
96
+ "args": ["/c", "npx", "-y", "@euclid-tools/euclid"]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ </details>
103
+
104
+ ### Windsurf
105
+
106
+ Add to `~/.windsurf/mcp.json`:
107
+
108
+ <details>
109
+ <summary>macOS / Linux</summary>
110
+
111
+ ```json
112
+ {
113
+ "mcpServers": {
114
+ "euclid": {
115
+ "command": "npx",
116
+ "args": ["-y", "@euclid-tools/euclid"]
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ </details>
123
+
124
+ <details>
125
+ <summary>Windows</summary>
126
+
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "euclid": {
131
+ "command": "cmd",
132
+ "args": ["/c", "npx", "-y", "@euclid-tools/euclid"]
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ </details>
139
+
140
+ ### Other MCP Clients
141
+
142
+ Any MCP client that supports stdio transport will work. Use `npx -y @euclid-tools/euclid` as the command (on Windows, run it through `cmd /c`).
143
+
144
+ ### npx (one-off)
145
+
146
+ ```bash
147
+ npx -y @euclid-tools/euclid
148
+ ```
149
+
150
+ ### npm (global install)
151
+
152
+ ```bash
153
+ npm install -g @euclid-tools/euclid
154
+ ```
155
+
156
+ ### Local Development
157
+
158
+ ```bash
159
+ git clone https://github.com/euclidtools/euclid.git
160
+ cd euclid
161
+ pnpm install
162
+ pnpm dev
163
+ ```
164
+
165
+ > **Why `cmd /c` on Windows?** On Windows, `npx` is a batch script (`npx.cmd`). MCP clients spawn processes directly, which can't execute `.cmd` files without a shell wrapper. Using `cmd /c` solves this. This affects all npx-based MCP servers, not just Euclid.
166
+
167
+ ---
168
+
169
+ ## The Problem
170
+
171
+ LLMs are non-deterministic. Every token they produce is a _prediction_ of what should come next — including math. This means:
172
+
173
+ - `247 × 389` → the model _predicts_ `96,083` (sometimes it gets `96,183` or `95,983`)
174
+ - `sin(47.3°) × cos(12.1°)` → the model _predicts_ something close-ish
175
+ - `17^4 + 3^7` → the model _predicts_ a number that looks right
176
+ - `15% of $8,472.50` → the model _predicts_ a dollar amount
177
+
178
+ Sometimes the predictions are correct. Sometimes they're subtly wrong. The problem is you can never be sure which is which.
179
+
180
+ **Euclid makes this a non-issue.** When an LLM has Euclid available, it sends expressions to a real math engine and returns the computed result. Deterministic. Correct. Every time.
181
+
182
+ Think of it like what `grep` did for AI code search — a simple, proven tool that gives the model a capability it fundamentally lacks.
183
+
184
+ ---
185
+
186
+ ## Tools
187
+
188
+ Euclid exposes multiple purpose-built tools, so the model can pick the right one for the job.
189
+
190
+ ### `calculate`
191
+
192
+ Evaluates mathematical expressions deterministically.
193
+
194
+ ```
195
+ "What's (245 × 389) + (12^3 / 7)?"
196
+ → calculate("(245 * 389) + (12^3 / 7)")
197
+ → 95,551.85714285714
198
+ ```
199
+
200
+ **Supports:** arithmetic, order of operations, exponents, roots, trigonometry, logarithms, factorials, constants (π, e, φ), complex numbers, and anything else [mathjs](https://mathjs.org) can parse.
201
+
202
+ ```
203
+ calculate("sqrt(144)") → 12
204
+ calculate("sin(45 deg)") → 0.7071067811865476
205
+ calculate("10!") → 3628800
206
+ calculate("log(1000, 10)") → 3
207
+ calculate("2^32") → 4294967296
208
+ calculate("e^(i * pi) + 1") → 0 (Euler's identity!)
209
+ ```
210
+
211
+ ### `convert`
212
+
213
+ Converts between units deterministically.
214
+
215
+ ```
216
+ convert(100, "fahrenheit", "celsius") → 37.778
217
+ convert(5, "km", "miles") → 3.10686
218
+ convert(1, "lb", "kg") → 0.45359
219
+ convert(1024, "bytes", "kB") → 1.024
220
+ ```
221
+
222
+ **Supports:** length, weight, volume, temperature, area, speed, time, data, and [100+ units](https://mathjs.org/docs/datatypes/units.html) via mathjs.
223
+
224
+ ### `statistics`
225
+
226
+ Statistical calculations on datasets.
227
+
228
+ ```
229
+ statistics("mean", [23, 45, 12, 67, 34]) → 36.2
230
+ statistics("std", [23, 45, 12, 67, 34]) → 21.159
231
+ statistics("percentile", [1, 2, 3, 4, 5], 90) → 4.6
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Why Not Just Use Code Execution?
237
+
238
+ Good question. Many LLM environments have code execution tools (Python sandboxes, etc.) that can do math. The difference:
239
+
240
+ | | Code Execution | Euclid |
241
+ | ------------------- | ---------------------------------- | ------------------------------------------ |
242
+ | **Overhead** | Spins up a sandbox/interpreter | Near-zero — evaluates an expression string |
243
+ | **Latency** | Hundreds of ms to seconds | Single-digit ms |
244
+ | **Availability** | Varies by client | Any MCP client |
245
+ | **Model behaviour** | Model writes _code_ that does math | Model writes a _math expression_ |
246
+ | **Failure modes** | Syntax errors, runtime exceptions | Clear error on invalid expression |
247
+ | **Token cost** | Code generation is verbose | Expression strings are minimal |
248
+
249
+ Euclid is to code execution what `grep` is to writing a Python script to search files. You _can_ solve it the heavy way, but why would you?
250
+
251
+ ---
252
+
253
+ ## How It Works
254
+
255
+ ```
256
+ ┌─────────────┐ MCP (stdio) ┌─────────────┐ evaluate() ┌─────────┐
257
+ │ LLM │ ──────────────────► │ Euclid │ ─────────────────► │ mathjs │
258
+ │ Client │ ◄────────────────── │ Server │ ◄───────────────── │ engine │
259
+ └─────────────┘ result └─────────────┘ number └─────────┘
260
+ ```
261
+
262
+ 1. The LLM encounters a calculation in conversation
263
+ 2. Instead of predicting the answer, it calls Euclid's `calculate` tool with the expression
264
+ 3. Euclid evaluates the expression using [mathjs](https://mathjs.org) — a battle-tested math library with 15,000+ GitHub stars
265
+ 4. The deterministic result is returned to the model
266
+ 5. The model presents the _computed_ answer to the user
267
+
268
+ The model doesn't need to be good at math. It just needs to know when to reach for the calculator.
269
+
270
+ ---
271
+
272
+ ## Security
273
+
274
+ Euclid runs entirely on your local machine via stdio. No network calls, no data sent anywhere.
275
+
276
+ Expression evaluation is sandboxed — `import`, `require`, `createUnit`, nested `evaluate`, and other potentially dangerous mathjs functions are disabled. Expressions are length-limited and time-bounded to prevent abuse.
277
+
278
+ ---
279
+
280
+ ## Tech Stack
281
+
282
+ - **TypeScript** — type-safe, well-documented
283
+ - **[@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk)** — official MCP TypeScript SDK
284
+ - **[mathjs](https://mathjs.org)** — the math engine (15k+ stars, 2.5M+ weekly npm downloads, 13 years of battle-testing)
285
+ - **[zod](https://github.com/colinhacks/zod)** — schema validation
286
+
287
+ ---
288
+
289
+ ## Roadmap
290
+
291
+ - [x] Core `calculate` tool — expression evaluation
292
+ - [x] `convert` tool — unit conversion
293
+ - [x] `statistics` tool — mean, median, std, percentile, etc.
294
+ - [x] Claude Code plugin — skills + auto-registration
295
+ - [ ] Financial calculations — compound interest, NPV, amortisation
296
+ - [ ] Date/time arithmetic — deterministic, not "about 3 months"
297
+ - [ ] LLM accuracy benchmarks — prove the difference with data
298
+ - [ ] Streamable HTTP transport — for remote/hosted deployments
299
+
300
+ ---
301
+
302
+ ## Contributing
303
+
304
+ Euclid is open source and contributions are welcome.
305
+
306
+ The most impactful contributions right now are:
307
+
308
+ - **Tool descriptions** — the prompt text that teaches models _when_ to use Euclid instead of guessing. This is harder than it sounds and has the biggest impact on real-world usefulness
309
+ - **Test cases** — especially edge cases where LLMs commonly hallucinate math (multi-step expressions, trig, large number arithmetic)
310
+ - **New calculation domains** — financial math, date arithmetic, or other areas where deterministic output matters
311
+ - **Benchmark data** — comparing raw LLM output vs Euclid-assisted output across different models
312
+
313
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
314
+
315
+ ---
316
+
317
+ ## Philosophy
318
+
319
+ LLMs are incredibly powerful, but they have a fundamental limitation: everything they produce is a prediction. For creative writing, reasoning, and conversation, that's a feature. For math, it's a bug.
320
+
321
+ The solution isn't to make models better at predicting math. It's to give them a calculator.
322
+
323
+ This is part of a broader principle: **wherever a model does something predictive that should be deterministic, give it a deterministic tool.** Math is the most obvious case, but the same logic applies to unit conversions, date arithmetic, regex evaluation, and more.
324
+
325
+ Euclid starts with math. Where it goes from there is up to the community.
326
+
327
+ ---
328
+
329
+ ## License
330
+
331
+ MIT
332
+
333
+ ---
334
+
335
+ <p align="center">
336
+ <i>Euclid of Alexandria formalised mathematical proof 2,300 years ago.<br>
337
+ We're just giving his tools to the machines.</i>
338
+ </p>