
SageMath
io.github.XBP-Europe由 GitHub 帳號 XBP-Europe 發布v0.10.1更新於 Nov 11, 2026
Stateful SageMath MCP server with 40 tools and a sandboxed Sage session per client.
發布方自己的服務:Math.Tools MCP Server
概覽
執行具沙箱、可保留狀態的 SageMath 工作階段,讓助理進行符號運算、線性代數、微分方程、數論與繪圖。
- 可以做什麼
- 在持續存在的工作階段中執行 Sage 程式碼,支援串流輸出、重設、中斷、取消與具名工作區
- 透過證明階梯複核給定結論,回傳 proved、refuted、supported 或 undecided
- 微分、積分、求極限、級數展開、解方程式與化簡、因式分解與展開、符號求和
- 處理矩陣、常微分方程、數論、組合數學、圖論、群論、橢圓曲線、編碼理論、多項式、布林代數、幾何、統計與機率分布
- 繪製二維與三維圖形、數值求根、向量微積分,並檢查服務健康狀態或查詢 Sage 文件
- 適用情境
- 適合需要助理真正計算並驗證數學結果而非近似作答的情境:符號微積分、精確代數、微分方程、數論或圖論與群論問題,尤其是變數需在多次呼叫間保留的多步驟推導。
- 執行需求
- 在 macOS 或 Linux 上以本機程序執行(Windows 僅能透過容器或 WSL)。需要 Python 3.12 與 SageMath 執行環境:passagemath 附加套件、PATH 中既有的 sage、conda-forge,或容器映像。uvx 方式需要 uv,首次啟動約下載 1 GB 的 Sage 元件。不需驗證或 API 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 SageMath,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
SageMath MCP Server
[CI] [CodeQL] [Dependency audit] [Fuzz] [Release] [PyPI] [conda-forge] [GHCR] [License] [Python] [MCP] [FastMCP] [SageMath] [Ruff] [Typed] [Coverage] [Sage doctests] [Downloads] [MCP Registry] [Glama] [Signed] [Provenance] [PyPI attestations] [OpenSSF Scorecard] [DOI] [Dependabot] [Last commit]
A Model Context Protocol server that gives an
LLM a sandboxed mathematical subset of SageMath —
symbolic calculus, number theory, linear algebra, ODEs, plotting, combinatorics,
graphs, groups, elliptic curves, and more. Each MCP session gets a dedicated Sage
worker process, so variables, functions, and assumptions persist across tool
calls. It ships 40 MCP tools, one of which — verify_claim — re-checks a
stated result through a proof ladder and answers proved / refuted /
supported / undecided with its evidence.
Caller code is deny-by-default: the full breadth of Sage mathematics is reachable, but imports, the external CAS interfaces, and the file / display / persistence primitives are not. The policy accepts 98.9% of SageMath's own 438,124 documented doctest examples (4,259 in-scope refusals, every one attributed to a named rule; 98.9% of 433,687 on the passagemath runtime) while refusing the rest — measured on every CI run (see Security).
Full manual: USAGE.md — the tools and their parameters, how code is interpreted, and the security model in depth.
Install & run
Recommended — pip, with the passagemath Sage runtime:
or, with uv and nothing installed permanently,
uvx --python 3.12 --from "sagemath-mcp[passagemath]" sagemath-mcp. This is the
route every client install below takes.
Use Python 3.12 for this extra; the uvx line asks for it, and uv downloads it
when the machine has none. 3.12 is the version CI tests it on, and the newest
for which every dependency ships a wheel: on 3.13 and later memory-allocator
is compiled from source, which needs a C compiler. Without --python, uv picks
its own newest Python (3.15 at the time of writing), and the install fails there.
passagemath is a pip-installable, modularized SageMath. from sage.all import *
and the worker run unmodified; the server detects the runtime at import and
loads the matching security artifacts, so the deny-by-default policy is
equivalent on both. It is pinned exactly (passagemath-standard==10.8.13) and
exercised by its own CI lane — the whole suite plus the doctest-corpus sweep
against the pin — so a pin bump is verified end to end before it ships, and the
last two releases passed that gate on first try
(docs/passagemath_evaluation.md).
macOS and Linux; native Windows support is partial, so on Windows use the
container or WSL.
A pip install runs with your own privileges. The security policy refuses code that reaches outside mathematics, but it is not an operating-system boundary (SECURITY.md). That suits your own client on your own machine. For untrusted input, a shared host or multi-tenant use, run the container.
For isolation — the container image (SageMath is baked in):
Those flags are the hardening the server expects; the port is published on
loopback deliberately — the server executes code and authenticates nobody.
docker compose up --build applies the same hardening from one reviewed file.
Released images are signed with Cosign and carry SLSA provenance and an SPDX
SBOM as registry attestations; the PyPI files carry PEP 740 attestations.
DISTRIBUTION.md
shows how to verify each.
On arm64 (Apple silicon, Graviton): the passagemath image. The monolithic
image above is published for linux/amd64 only, so on arm64 it runs under
emulation. The same server on the passagemath runtime ships as a native
linux/amd64 + linux/arm64 image, with the same hardening flags, UID and
security policy:
Every release tag has a -passagemath twin (vX.Y.Z-passagemath), each
architecture is smoke-tested natively before it is published, and the index is
signed and attested like the primary image. It is the optional image on amd64,
where the monolithic one stays primary.
One click in a desktop MCP host (Claude Desktop and friends): download
sagemath-mcp-<version>.mcpb from the
latest release and
open it. The bundle is about 27 KB; your host installs the server and
a Sage runtime with uv on first launch, which is roughly a 1 GB download once.
macOS and Linux — native Windows is excluded because passagemath's Windows
support is partial. A bundle is a local install with your own privileges; for
untrusted or multi-tenant use run the container instead.
With a Sage you already have (PyPI):
This needs a working SageMath on the host: sage on your PATH, or in the same
environment as the server. A Sage inside a container is out of reach of a server
on the host; without a Sage of your own, use the [passagemath] extra above.
From conda-forge (Linux and macOS, next to conda-forge's Sage):
The version floor matters: earlier releases cannot start a worker on
conda-forge's sage unless its environment is activated, which an MCP client
does not do, and without the floor the solver may pick one. That sage is
10.10, the release the security artifacts are generated from.
Source install, Docker Compose, and the Kubernetes Helm chart are in USAGE.md.
Connect an MCP client
One command or one click each. Every route below installs a Sage runtime alongside the server, so there is nothing else to set up.
[Install in VS Code] [Install in Cursor]
Claude Desktop — download sagemath-mcp-<version>.mcpb from the
latest release and
open it. One click, no config file.
Claude Code — as a plugin from this repository's marketplace, inside a session:
or as a plain MCP server:
Gemini CLI — the repository is itself an extension:
Codex CLI
Then ask for some mathematics — the examples below are a good start.
Three things worth knowing. These need uv on your
PATH, and the first launch downloads about 1 GB of Sage wheels, cached
afterwards. Already have sage? Drop [passagemath] from the specification and
it will use yours. Installed from conda-forge? Register the environment's own
executable, for example claude mcp add sagemath -- ~/miniforge3/envs/sage/bin/sagemath-mcp;
it finds the sage beside it without the environment being activated. And an install of any of these runs with your own privileges;
for untrusted or shared use, run the container and point the client at it.
Pinning a release, HTTP transport and the full client reference are in USAGE.md.
Try it
Prompts a client can run once the server is connected:
- Damped harmonic oscillator — "Solve
x'' + 2·x' + 5·x = 0withx(0)=1,x'(0)=0, then verify the solution satisfies the ODE." - General relativity — "On the hyperbolic upper half-plane with metric
(dx² + dy²)/y², compute the Ricci scalar and confirm it is a constant negative curvature." - Coupled two-tank system — "Solve the linear ODE system for two mixing tanks, then take the long-term limit of each concentration."
Each builds an object once and explores it across calls — the case for
evaluate_sage and its persistent session.
The 40 tools
The math tools use SageMath as the backend; parameters and examples for the most-used ones are in USAGE.md.
Plus HTTP /health and /ready endpoints and 3 MCP resources (session
snapshots, monitoring metrics, doc links). Prefer interrupt_sage_session over
cancel_sage_session — it stops a computation while keeping the session's
variables.
How it works
Request flow: MCP client → a tool in tools/ →
SageSessionManager.get() → SageSession.evaluate() → JSON request to
the _sage_worker.py subprocess → AST validation → exec() in the persistent
namespace → JSON response.
- Process isolation — each session runs Sage in its own subprocess; a crash or timeout in one cannot affect another.
- Stateful sessions — variables, functions, and assumptions persist across calls, enabling multi-step workflows.
- Deny-by-default — a name is refused unless the generated allowlist offers it or the caller's own code bound it. A helper a future SageMath adds is refused until someone reviews it, rather than reachable the day it lands.
Security
The AST validator is defence in depth against accidents and casual misuse — it
is not a boundary against determined adversarial code. The container is the
security boundary. The server has no authentication, so every default is
loopback: --host defaults to 127.0.0.1, the default transport is stdio, and
Compose / Helm keep the endpoint off the network. Put something that
authenticates in front of it before exposing it.
What the policy enforces: an allowlist (caller code may read only a name the
server offers or the caller itself bound); no imports by default; eval /
exec / compile and runtime string evaluation blocked; dunder access blocked;
the external CAS interfaces and every file / network / persistence primitive
removed from the namespace, by provenance rather than by name; and the sage
package tree closed to caller code, so a helper is reached by its own name or
not at all. The container adds
a read-only root, dropped capabilities, no-new-privileges, the default
seccomp profile, and memory ceilings. Compose adds a fork (PID) ceiling;
Kubernetes has no per-pod equivalent in the pod spec, so on the chart that is
the node's podPidsLimit rather than something the chart can set.
Full threat model and the complete blocked / allowed tables: SECURITY.md and USAGE.md § Security model.
Docs & more
- USAGE.md — the full manual: every tool, how code is interpreted, deployment, and the security model.
- docs/mcp_quickstart.md — a first-session walk-through.
- CHANGELOG.md · ROADMAP.md · CONTRIBUTING.md · SECURITY.md · SUPPORT.md — what "supported" means, release cadence, where to ask. PRIVACY.md — what the server keeps (nothing leaves the machine it runs on).
Requirements
Python 3.12+ and a SageMath runtime (the container image bundles SageMath 10.10;
otherwise sage on PATH, or the [passagemath] extra). Built on
FastMCP 4.x.
Contributing
Issues and pull requests welcome — see CONTRIBUTING.md. Run
make lint, make typecheck and make test before pushing
(git config core.hooksPath .githooks wires the pre-push check). Roadmap and open work: ROADMAP.md.
Questions go to GitHub Discussions;
SUPPORT.md says what to expect.
Citing
If this server is part of published work, cite it via CITATION.cff — GitHub renders it as Cite this repository in the sidebar, with APA and BibTeX. Cite SageMath itself as well; it does the mathematics.
License
MIT — see LICENSE. SageMath itself is GPL-2.0-or-later and is used as a separate runtime; no SageMath source is redistributed in this repository.
來源:README.md,提交 f099ad4
工具
0版本歷史
14- v0.10.1最新Nov 11, 2026
- v0.9.7Oct 26, 2026
- v0.9.6Oct 25, 2026
- v0.9.5Oct 13, 2026
- v0.9.4Oct 10, 2026
- v0.9.3Oct 5, 2026
- v0.9.2Sep 28, 2026
- v0.9.1Sep 24, 2026
- v0.9.0Sep 24, 2026
- v0.8.4Sep 22, 2026
- v0.8.3Sep 20, 2026
- v0.8.2Sep 18, 2026
- v0.8.1Sep 17, 2026
- v0.8.0Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
其他 Math 整合
Math.Tools MCP Server
tools.math官方發布者
遠端 math.tools 服務,讓助理進行數論檢查、數字與進位轉換、圓周率位數、數字拼寫以及公式圖片算繪。

Rate Setting Math Tracker
由 GitHub 帳號 mrfentmen 發布
本機 MCP 伺服器,對自由工作者費率計算進行 JSON 分析,提供 25 個工具且無付費牆。

Rate Setting Math Simulator
由 GitHub 帳號 mrfentmen 發布
一個本機 MCP 伺服器,依 JSON 資料計算自由工作者的費率設定數學,提供 25 個工具且沒有付費牆。

Rate Setting Math Planner
由 GitHub 帳號 mrfentmen 發布
一個本機 stdio MCP 伺服器,依本機 JSON 資料分析自由工作者的定價與費率計算,提供 25 個工具且沒有付費牆。

Rate Setting Math Archive
由 GitHub 帳號 mrfentmen 發布
本機 MCP 伺服器,依據內附 JSON 資料分析自由工作者費率設定的數學計算,提供 25 個工具且沒有付費牆。