Borrowing it
Nothing to install: this file belongs to XBP-Europe/sagemath-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/XBP-Europe/sagemath-mcp/main/CLAUDE.mdgit clone --depth 1 https://github.com/XBP-Europe/sagemath-mcpWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/xbp-europe/sagemath-mcp/claude-md)<a href="https://agentmods.dev/instructions/xbp-europe/sagemath-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/xbp-europe/sagemath-mcp/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/xbp-europe/sagemath-mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/xbp-europe/sagemath-mcp/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.02439 | $0.02439 |
| Opus 5 | $0.01220 | $0.01220 |
| Sonnet 5 | $0.00488 | $0.00488 |
| Haiku 4.5 | $0.00244 | $0.00244 |
Grade A, and why
sagemath-mcp CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 109 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project
SageMath MCP is a Model Context Protocol server exposing stateful SageMath computations to LLM clients via FastMCP. Each MCP session gets a dedicated Sage worker subprocess with persistent variable state across tool calls.
Commands
uv pip install -e .[dev] # Install with dev extras
make lint # uv run ruff check
make test # uv run pytest (pure Python, no Sage needed)
make integration-test # pytest inside Sage Docker container
make build # Build wheel + sdist via scripts/build_release.py
make sage-container # Bootstrap the Sage Docker container
uv run pytest tests/test_server.py -k "test_name" # Run a single test
Unit tests run with SAGEMATH_MCP_PURE_PYTHON=1 (uses Python math stdlib instead of Sage). Integration tests require docker exec sage-mcp and real Sage runtime.
Linting
Ruff with line-length 100, target Python 3.12. Rules: E, F, W, B, UP, ASYNC, RUF, I (import sorting). Run make lint before committing.
Testing
- All async tests use
@pytest.mark.asyncio(asyncio_mode is "auto") - Tests mirror source modules:
test_server.py,test_session.py,test_security.py,test_config.py, etc. test_integration.py,test_use_cases.pyand most oftest_math_coverage.pyrequire the Sage container- Key fixtures:
python_settings(injectsforce_python_worker=True),FakeContext(captures MCP context messages)
Architecture
Source lives in src/sagemath_mcp/:
server.py- Entry point: the/healthroute,main(), and the imports that register the tools. Re-exports the tool functions, sofrom sagemath_mcp import serverkeeps working.app.py- The FastMCP object, instructions, lifespan and middleware. Ownsmcpso tool modules can decorate against it without importing the module that imports them.runtime.py-SETTINGS,SESSION_MANAGERandresolve_session(). Read the manager through this module (neverfrom .runtime import SESSION_MANAGER) so tests can swap it.codegen.py- Building the Sage snippets: prelude, literal encoding, the validation gates and the numeric guards. Any caller string reaching a template must pass a gate — generated code runs undertrusted_policy(), which permitssage_eval.tools/- The 40 tools and 3 resources by domain:session,core,calculus,algebra,discrete,stats,plotting,diagnostics,verify. A module missing fromtools/__init__.pyregisters nothing.session.py-SageSessionManager(per-client session map with asyncio locks) andSageSession(spawns/manages_sage_worker.pysubprocess via JSON stdin/stdout protocol)._sage_worker.py- Subprocess worker that executes code in a persistent namespace. Handles execute/reset/shutdown commands. Validates AST before compilation.security.py- AST validator enforcingSecurityPolicy. Caller code is deny-by-default: a name is refused unless the allowlist offers it or the caller's own code bound it. On top of that it blocks imports outright,eval/exec, dunder access, string-path attribute primitives (attrgetterand friends, which defeat every AST attribute rule), forbidden modules and known code-executing Sage helpers. Configurable via env vars.allowlist.py- Generated, never hand-edited. The names caller code may read, produced from the installed Sage byscripts/generate_allowlist.py(make allowlist, which writes through a temp file because the generator imports the module it replaces). An integration test and a weekly job fail when it and the installed Sage disagree.star_exports.py- Generated, never hand-edited. The curatedfrom <module> import *exception to the import ban: internal SageMath modules whose public names are all ordinary mathematics, mapped to the exact names each star may bind. Produced byscripts/generate_star_exports.py, which screens each candidate module clean-as-a-whole with_star_export_screen(same danger basis as the namespace scrub).rewrite_permitted_importsexpands a vetted star into these names before validation; nothing is added to the allowlist.test_the_star_exports_match_this_sagefails when a Sage upgrade makes a listed module dirty.symbols.py-PREDEFINED_SYMBOLS, the one source of truth forx, y, z, t. Read by the worker, the generated prelude and the refusal message; a test asserts they agree, because them disagreeing is what made the tools andevaluate_sageaccept different mathematics.text.py- Strings shared between the tool modules and the app. They are part of the tool contract, so they live where both can reach them without a cycle.config.py-SageSettingsdataclass driven bySAGEMATH_MCP_*environment variables.models.py- Pydantic models for results (EvaluateResult,SessionSnapshot,MonitoringSnapshot).monitoring.py- Thread-safeEvaluationMetrics(counters, latency, error tracking).
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago Changed · +44 tokens per session f57e7e974654
- 11d ago First seen · 109 lines · 2,395 tokens per session scan A 284d662f1a5f
sagemath-mcp CLAUDE.md is an instructions file published in the GitHub repository XBP-Europe/sagemath-mcp (14 stars, last pushed 3d ago), licensed MIT. It adds 2,439 tokens to every session, about $0.0122 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other instructions, from other repositories
next.js AGENTS.md
AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
vscode buildNext.instructions.md
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
spec-kit AGENTS.md
AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.
langchain AGENTS.md
AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).