
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
calc-mcp-server
Advanced tools
MCP server for exact arithmetic: a single safe calculator tool over an AST allowlist, with no unbounded dependencies.
An MCP server that does arithmetic, exactly — so an LLM does not have to do it mentally.
One tool, calculate, evaluating expressions against a hand-rolled AST allowlist. No eval(), no
sympy, no unbounded dependencies.
2 + 3 * (4 - 1) / 2 ** 2 -> 4.25
sqrt(16) + sin(pi/2) -> 5.0
123456789 * 987654321 -> 121932631112635269
The widely-used mcp-server-calculator package is abandoned (last commit May 2025) and declares
mcp>=1.4.1 with no upper bound. When the MCP Python SDK released v2 and removed
mcp.server.fastmcp, every uvx …@latest install of it started crashing on import — which took down
the entire MCP proxy hosting it, and every other server alongside it.
No maintained Python replacement exists. The one actively-maintained npm calculator computes in
float64, so 123456789 * 987654321 comes back as 121932631112635260 — off by 9. That is a poor
trait in a tool whose whole purpose is that the model should not be doing the arithmetic itself.
So this server:
mcp[cli]>=2,<3) — the failure above cannot recur here;Two problems, and most calculator servers only solve the first.
Code execution. Expressions are parsed with ast.parse and walked against an explicit allowlist of
node types. Attribute is not on it, so (1).__class__.__bases__ is rejected. A Call is only
evaluated when its target is a bare name in the function allowlist, so __import__('os').system(…) is
rejected before any argument is even evaluated.
Resource exhaustion. An allowlist alone still lets 9**9**9 occupy the process for minutes on
unbounded bignum exponentiation — the incumbent hangs for over five seconds on it. Four caps close
that: expression length (500 chars), nesting depth (32), result size (4300 digits, checked on the
operands before exponentiating), and factorial argument (1000).
Full detail in docs/tech/SAFE-EVALUATION.md.
uvx calc-mcp-server
Pin it. Do not add @latest — that is how the package this replaces broke.
As a stdio MCP server:
{
"mcpServers": {
"calculator": {
"command": "uvx",
"args": ["calc-mcp-server"]
}
}
}
calculate tool| Argument | Type | Description |
|---|---|---|
expression | str | The expression to evaluate |
Returns the result as a string, or a line starting with Error: explaining why the expression was
rejected. The tool never raises, so a bad expression is an answer the agent can read back rather than a
tool-call failure.
Operators — + - * / // % **, parentheses, unary +/-. ^ is accepted as a power
operator, and × · ÷ − are accepted as their ASCII equivalents (speech-to-text produces them).
Constants — pi, e, tau.
Functions — abs round min max sqrt exp log log2 log10 sin cos tan asin
acos atan atan2 degrees radians hypot floor ceil factorial gcd lcm.
Results — integer arithmetic returns an exact integer of any size. Floats are rendered at 12
significant digits, which removes IEEE-754 representation noise (0.1 + 0.2 reads 0.3, not
0.30000000000000004) while keeping far more precision than a calculator result is used at. A whole
float keeps its .0, so 8 / 2 reads 4.0 and stays distinct from the exact integer 4.
uv sync
uv run pytest tests/ -v
uv run ruff check .
uv run ruff format .
See AGENTS.md for the project guide and docs/ for the full documentation set.
MIT — see LICENSE.
FAQs
MCP server for exact arithmetic: a single safe calculator tool over an AST allowlist, with no unbounded dependencies.
We found that calc-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.