Skip to main content

calcbox

Backend-agnostic math compute kernel: symbolic, numeric, units, control — and every answer carries provenance (backend, engine version, assumptions, verification, input hash).

It knows nothing about teaching, documents or users. It is a calculator that can prove what it did.

from calcbox import compute

out = compute("x**2", "integrate")
# {'result': 'x**3/3', 'backend': 'sympy', 'engine_version': '1.13.1',
#  'verification': {'method': 'differentiate-back', 'passed': True}, ...}

Why another math tool

There are MCP servers that evaluate arithmetic and matrix operations. What they do not report is how the answer was produced: which backend, which engine version, which assumptions, and whether a second method agreed. For tutoring, for reproducible research notes, and for anything a human will quote, that provenance is the point.

{
  "result": "x**3/3",
  "latex": "\\frac{x^{3}}{3}",
  "backend": "sympy",
  "engine_version": "1.13.1",
  "assumptions": {"variable": "x", "domain": "complex"},
  "verification": {"method": "differentiate-back", "passed": true},
  "disputed": false,
  "sandbox": "audit-only",
  "input_sha256": "9f2c…",
  "elapsed_ms": 12.4
}

Install

pip install calcbox              # core, no backends
pip install "calcbox[symbolic]"  # sympy  (calculus, algebra, exact values)
pip install "calcbox[full]"      # sympy + scipy + pint + control
pip install "calcbox[mcp]"       # MCP server (stdio)
pip install "calcbox[api]"       # FastAPI router

Nothing is a hard dependency. A missing backend is reported as unavailable with a reason, never as a crash.

Use it

Python

compute("x**2", "integrate")            # indefinite
compute("x", "integrate", target="0,1") # definite
compute("x**3", "diff")
compute("2+3*4", "value")
compute("x**2-1", "solve")
compute("sin(x)/x", "limit", point="0")
compute("x**2", "simplify", backend="sympy")

CLI

calcbox "x**2" --op integrate
calcbox "sin(x)/x" --op limit --point 0 --json

HTTP (optional; no auth by design — that belongs to the host)

from fastapi import FastAPI
from calcbox.api import create_router

app = FastAPI()
app.include_router(create_router())
# GET  /v1/compute/backends
# POST /v1/compute {"expression": "x**2", "operation": "integrate"}

MCP

{
  "mcpServers": {
    "calcbox": {"command": "calcbox-mcp", "args": []}
  }
}

Tools: compute, backends.

Contract

Field Meaning
operation simplify, diff, integrate, solve, limit, value, latex, factor, expand, quad, minimize, root, convert, step, eval, check
backend auto infers from the operation; otherwise one of sympy/scipy/pint/control/wolfram/lean
verification method + passed; e.g. differentiate-back for integrals, substitute-back for solutions
disputed two backends disagreed (only when a cross-check runs)
sandbox always audit-only for in-process backends

Errors: ComputeError (bad request → 400) and BackendUnavailable (missing dependency or disabled external engine → 503).

Security

The sandbox is audit-only. It is a set of sys.audit hooks, not an OS jail. Read SECURITY.md before exposing this to untrusted input. External engines (Wolfram, Lean) are disabled unless CALCBOX_EXTERNAL=1.

Status

0.4.0 — all six backends wired: SymPy, SciPy, Pint, Control, and the external engines Wolfram and Lean (disabled unless CALCBOX_EXTERNAL=1; both fail with a reason when the binary is absent, never silently). The mcp extra now tracks mcp 2.x; the server keeps the compute / backends tools and their payloads.

15/15 parity with the implementation this was ported from, 37 tests.

Every local call runs in a killable subprocess worker (~0.2-1.2 s overhead); CALCBOX_WORKER=0 runs in-process for debugging. External engines run in-process because they are already separate processes.

Releasing

See RELEASING.md: PyPI Trusted Publishing, no tokens.

License

MIT.

Metadata

Release files for calcbox 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for calcbox 0.4.0
File Size Uploaded Provenance Actions
calcbox-0.4.0.tar.gz 19.5 kB With provenance Details for calcbox-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for calcbox 0.4.0
File Interpreter ABI Platform Actions
calcbox-0.4.0-py3-none-any.whl Python 3 none any Details for calcbox-0.4.0-py3-none-any.whl

Total release size: 37.5 kB

Release files / calcbox-0.4.0.tar.gz

Download URL calcbox-0.4.0.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1cd15ac2dd578f92cdb8326ec8a2185634523ada20c2fd5d53db52fe97565d7a
BLAKE2b-256 checksum
How to use checksums
825b81fbcaba1dd39afc0ede4e6159be913195c09aac3d7006e48051c85c4471
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / calcbox-0.4.0-py3-none-any.whl

Download URL calcbox-0.4.0-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76c64b396d7a74eb24620f431b69c9d89dcb7d01a131f8654a8c7567b11317ed
BLAKE2b-256 checksum
How to use checksums
fc64095204a89e0bcfd12eb52071b59756cf4b05b02e1ead93690ad578ccdc24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for calcbox 0.4.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for calcbox-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page