oce-math-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@oce-math-mcp risolvi 3x^2 - 5x + 2 = 0 e verifica le soluzioni"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
oce-math-mcp
Server MCP (Model Context Protocol) di matematica per modelli linguistici locali, pensato per addestrare e far lavorare Qwen3.6 su calcoli che un modello non sa fare a mente: aritmetica esatta, algebra simbolica, analisi, teoria dei numeri, calcolo numerico, verifica delle risposte, calendario italiano, geometria 3D per CAD/CNC e prove formali in Lean 4.
Stato: versione 0.1.0. 9 tool su 10 funzionano; eng_calc ha lo schema fissato e il codice
arriva in fase 2. Le operation implementate sono 112 su 137 (le altre 25 sono di eng_calc).
Perché
Il modello di base sbaglia quasi tutti i calcoli complessi: nel benchmark di partenza Qwen3.6-35B-A3B ha dato il risultato esatto in 1 problema su 12. Un modello non deve calcolare a mente: deve chiamare uno strumento deterministico e verificabile. Lo stesso server produce anche le risposte vere per il dataset di addestramento.
Related MCP server: Polymath MegaBlaster MCP
Tool
Tool | Cosa fa |
| aritmetica esatta (decimal, fraction, float), funzioni, statistica, finanza italiana, unità |
| algebra e analisi simbolica con SymPy (34 operation), con verifica delle soluzioni |
| primi, fattorizzazione, aritmetica modulare, equazioni diofantee (26 operation) |
| precisione arbitraria, somme e integrali numerici, ottimizzazione, ODE (10 operation) |
| controlla una risposta: equivalenza, sostituzione, derivate, disuguaglianze (6 operation) |
| programmi Python brevi in un interprete ristretto (conteggi, forza bruta, successioni) |
| verifica una dimostrazione in Lean 4 con Mathlib (limite 60 s) |
| calendario italiano |
| vettori, rotazioni, quaternioni, solidi, CNC, calcoli per il disegno 3D (24 operation) |
| formule di progetto meccanico: schema pronto, codice in fase 2 |
Il contratto completo (nomi, schemi JSON, esempi) è in docs/spec/SPEC_OCE_MATH_MCP_V3.md e in
docs/spec/oce_math_mcp_tools.json. Ogni risposta ha 9 campi fissi: ok, tool, operation,
result, units, formula_used, formatted_it, warnings, error.
Installazione
Serve Python 3.12 o più recente e uv.
uv sync --compile-bytecode--compile-bytecode serve una volta sola: senza, ogni processo di calcolo ricompila SymPy e SciPy
quando PYTHONDONTWRITEBYTECODE è attivo (avvio misurato 4,997 s contro 2,853 s, decisione D34).
Se la repo sta su un disco di rete, tieni l'ambiente Python su un disco locale (decisione D26):
$env:UV_PROJECT_ENVIRONMENT = "$HOME\.venvs\oce-math-mcp"; uv sync --compile-bytecodeAvvio
Transport stdio (quello che usano i client MCP):
uv run oce-math-mcpStreamable HTTP su http://127.0.0.1:8012/mcp:
uv run oce-math-mcp --http --port 8012Esempio di configurazione per un client MCP:
{
"mcpServers": {
"oce-math": { "command": "uv", "args": ["run", "--directory", "<percorso della repo>", "oce-math-mcp"] }
}
}Opzioni
Opzione | Effetto |
| streamable HTTP invece di stdio (predefiniti |
| processi di calcolo (predefinito: |
| calcolo nel processo del server, solo per prove: il timeout non può fermare il calcolo |
| stampa gli schemi dei 10 tool ed esce |
| misura avvio, latenza e ripartenza dei processi di calcolo (risultato in JSON) |
| con |
| esegue in |
| installa elan, Lean 4 e Mathlib dentro la repo (decisione D17) |
| copia il contratto nella spec e nelle copie esterne del progetto |
Variabile d'ambiente | Effetto |
| numero di processi di calcolo |
| cartella di elan (predefinita |
| progetto Lean con Mathlib (predefinito |
| destinazioni di |
Lean 4 e Mathlib
lean_check funziona solo dopo l'installazione:
uv run oce-math-mcp --install-leanIl comando scarica elan, installa la toolchain fissata in lean/lean-toolchain, scarica Mathlib
e i suoi file già compilati (lake exe cache get). Senza Lean, lean_check risponde con un errore
chiaro e gli altri tool funzionano. Servono circa 10 GB: misurati 3.287,2 MB per elan e
6.993,7 MB per Mathlib. Tempi misurati: docs/MISURE.md.
Se la repo sta su un disco di rete, installa Lean su un disco locale (proposta D37: sul disco di rete l'installazione è fallita 2 volte su 2). Le stesse variabili vanno date anche al server:
$env:OCE_MATH_ELAN_HOME = "$HOME\.oce-math-mcp\elan"; $env:OCE_MATH_LEAN_PROJECT = "$HOME\.oce-math-mcp\lean"; uv run oce-math-mcp --install-leanlean_check rifiuta il codice che può eseguire programmi o aggiungere assiomi (#eval, elab,
macro, run_cmd, axiom, native_decide e altri, decisione D36) e dichiara valida una
dimostrazione solo se usa gli assiomi standard (propext, Classical.choice, Quot.sound).
Sicurezza
Nessun
eval,exec,sympifyoparse_exprsul testo del modello: un parser AST a whitelist costruisce le espressioni SymPy (decisioni D5 e D31). Un test intercettaevaledexecdurante i calcoli e fallisce se il testo del modello arriva a uno dei due.python_sandboxè un interprete AST scritto qui, nonexec: moduli e funzioni da una lista ammessa, attributi pericolosi bloccati (D13, D28, D29). Accetta i costrutti tipici dei programmi TIR:from sympy import *,global,sympy.S,nsimplify(D38);classno.Limiti: espressione fino a 2.000 caratteri, esponente fino a 10.000, timeout di 5 secondi per chiamata. Il calcolo gira in processi separati: allo scadere il processo viene ucciso e sostituito (D32). Limite di memoria per processo (Job Object su Windows,
RLIMIT_ASsu Linux).Nessuna eccezione esce dal server: ogni errore ha
code,messageedexample.
Sviluppo
Le prove si lanciano sul PC o su un server di casa, non in GitHub Actions.
uv run ruff check src testsuv run ruff format --check src testsuv run basedpyrightuv run pytest -qLa suite comprende le prove reali del server in stdio e in HTTP. I test di lean_check si
saltano se Lean non è installato.
Documenti
docs/spec/SPEC_OCE_MATH_MCP_V3.md: contratto dei 10 tool (prevale sulla spec V2)docs/DECISIONI.md: registro delle decisionidocs/MISURE.md: tempi e spazio misuratidocs/DISCUSSIONE-2026-11-23.md: discussione di avvio e strategiaCHANGELOG.md: storia delle versioni
Licenza
Apache License 2.0, vedi LICENSE e NOTICE.
Available Tools
10 toolsdate_calcC
Dates and times in the Italian calendar (Europe/Rome): exact age (also in months and weeks), weekday, differences (days, business days, real elapsed hours across DST) and additions, relative dates, events with DST offsets and reminders, recurring events, time zone conversion, invoice due dates (DFFM), month calendar, Italian national holidays including Easter and Easter Monday.
Inputs: operation (required), nth, date, days, +18 more.
eng_calcC
Engineering design formulas: strength of materials (Hooke, beams, shafts, Von Mises/Tresca, Euler buckling, fatigue, pressure vessels, bolts, welds), machine design (dynamics, vibrations, gears, bearings L10, belts, CNC cutting), fluids and heat (pipes, drag/lift, heat transfer, heatsinks), electrical and control (AC/DC, RLC filters, Clarke/Park, second-order systems, PID, optics, acoustics), material properties.
Inputs: params (required), operation (required).
geom3d_calcC
3D geometry for CAD, CNC and robotics: vector operations, angles, rotations (Euler, axis-angle), 4x4 homogeneous transforms, quaternions, Denavit-Hartenberg forward kinematics, distances and intersections, cylindrical and spherical coordinates, bolt holes, solid and cross-section properties. For 3D drawing: 2D sketch profiles, circles through 3 points, fillets, triangle solving, curves as point lists (helix, involute, spline, parametric), CAD pick points on faces and edges, patterns, point clouds, mesh and composite part checks (volume, centroid, bounding box).
Inputs: operation (required), v1, v2, axis, +10 more.
lean_checkA
Check a formal proof in Lean 4 with Mathlib. Returns whether it compiles without errors, without sorry and with only the standard axioms, with Lean messages. Code that runs programs (#eval, run_cmd, elab, macro), new axioms and native_decide are rejected. 60 s limit.
Inputs: code (required), allow_sorry.
math_evalC
Exact arithmetic and scalar functions: Decimal/Fraction/float modes, logs, roots, trig in rad and deg, hyperbolic, combinatorics, statistics and distributions, Italian finance (VAT, withholding, loans, NPV, IRR, DCF), unit conversion.
Inputs: expr (required), precision, variables, exact_mode, +1 more.
math_numericC
Numerical math with mpmath, SciPy and NumPy: arbitrary precision evaluation (up to 1000 digits), infinite sums, numerical integrals, roots, constrained and global optimization, linear and integer programming, ODE initial value problems, polynomial roots, closed-form identification of constants, curve fitting.
Inputs: operation (required), x0, expr, bounds, +9 more.
math_solveC
Symbolic math with SymPy plus SciPy/NumPy: equations, systems, inequalities, derivatives, integrals (single, multiple, line, surface), limits, series, function study, vector calculus, Lagrange, ODE, Laplace, Fourier/FFT, Riccati LQR, linear algebra, sums, recurrences, polynomials, complex numbers. Results are self-verified.
Inputs: operation (required), ics, expr, time, +15 more.
math_verifyB
Check an answer before giving it: symbolic and random-point equivalence of two expressions, substitution of a solution into equations, derivative and antiderivative checks, numeric comparison with tolerance, counterexample search for inequalities.
Inputs: expr (required), operation (required), domain, samples, +4 more.
number_theoryB
Integer and modular arithmetic with exact big integers: primality, factorization, divisors, totient, Mobius, primes, gcd/lcm/extended gcd, modular power/inverse/square root/log, primitive roots, Legendre/Jacobi, CRT, Diophantine equations, continued fractions, partitions, digits.
Inputs: operation (required), k, m, n, +6 more.
python_sandboxA
Run a short Python program in a restricted interpreter for problems no other tool covers (counting, brute force, sequences, multi-step computations). Allowed imports: math, cmath, fractions, decimal, itertools, functools, collections, statistics, random, heapq, bisect, sympy, numpy, scipy, mpmath. No files, no network, 5 s limit. Returns printed output and the value of the last expression.
Inputs: code (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
The three computational cores (math_eval for exact/scalar, math_solve for symbolic, math_numeric for arbitrary-precision/numerical) are conceptually distinct but overlap in practice: roots, integrals and evaluation can plausibly be routed to any of them, and eng_calc/math_eval both cover engineering-finance formulas while date_calc also handles invoice due dates. The very long descriptions help an agent choose, but boundaries are decided by mode (exact vs symbolic vs numeric) rather than by resource, which invites misselection.
Half the tools use a clean math_* prefix family (math_eval, math_solve, math_numeric, math_verify) while the rest use domain-first or suffix conventions (geom3d_calc, date_calc, eng_calc, number_theory, python_sandbox, lean_check). There is a loose 'domain + action/noun' logic throughout, but no single predictable pattern, and geom3d_calc breaks the calc/verb scheme entirely.
Ten tools is squarely in the well-scoped range, and each corresponds to a recognizable subdomain (arithmetic, symbolic, numeric, number theory, geometry, verification, sandbox, proof, dates, engineering). No tool looks redundant at the count level, even though individual tools internally bundle very large surfaces.
The surface covers essentially the full lifecycle of a math problem: compute, solve, numerically approximate, verify, formally prove, and fall back to a sandbox, plus geometry, dates and engineering. Minor gaps remain — no plotting/visualization or matrix-oriented entry point and unit conversion is buried inside math_eval rather than exposed — but agents can work around these.
Maintenance
Related MCP Connectors
AI-callable calculators and engineering models with real formulas. No hallucinated math.
Exact arithmetic, algebra, calculus, physics, chemistry and finance with a checkable formula.
Deterministic signed verification of numeric & financial claims for AI agents & spreadsheets.
Verified physics and chemistry calculators for AI agents: search in plain English, run with units.
Related MCP Servers
- AlicenseAqualityDmaintenanceA secure mathematical computation sandbox that enables LLMs to perform symbolic math operations like algebra, calculus, and equation solving via SymPy. It features low-latency execution through pre-warmed process pools and provides standardized JSON outputs for reliable agent integration.12MIT
- AlicenseBqualityBmaintenanceEnables AI agents to perform accurate local computations including arbitrary-precision math, date handling, unit conversion, subnet calculations, encoding, hashing, and text analysis, all without network calls or API keys.27MIT
- AlicenseAqualityBmaintenanceProvides LLMs with deterministic math tools for sandboxed expression evaluation, descriptive statistics, primality testing, prime factorization, GCD/LCM, quadratic solving, and base conversion. Every operation runs real code rather than relying on the model's arithmetic, with expression parsing restricted to a whitelist of operators, constants, and functions.21MIT
- AlicenseAqualityBmaintenanceEnables language models and users to perform exact arithmetic, symbolic math, unit/date conversions, statistics, and read-only SQL queries over registered files, with every operation logged by a citable ID that humans can re-run.11MIT