# mathguard

> mathguard is an MCP server for education and exams. Check LLM maths with SymPy and Pint: identities, derivations, calculus and units. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Platforms:** CLI, API
- **Repository:** https://github.com/c0mae/mathguard
- **MCP Registry name:** io.github.C0MaE/mathguard
- **Categories:** [education and exams](https://ai-powered.com/categories/education-and-exams), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-18

## About

Language models set up calculations well but often slip when carrying them out. mathguard is a verification layer built on SymPy and Pint that checks a claim and, when it is wrong, gives a concrete counterexample. It can test a single identity, walk a derivation step by step and point at the faulty line, or grade a model's answer against a reference with unit conversion and rounding tolerance.

Results use deliberately honest statuses. Verified means a computer algebra system confirmed the claim; likely means many random points agreed without a proof; refuted, inconclusive and error cover the rest. The README notes that verified is not formal proof and points to Lean 4 for that.

A whole worked solution written in Markdown or LaTeX can be checked in one go, and the server also exists as a Python library and command-line tool (mathguard doc, mathguard grade). A browser demo is hosted on Hugging Face. It installs from PyPI.

## Features

- **Step-by-step derivation check:** Finds the first wrong step in a chain of rewritings.
- **Answer grading:** Compares formulas symbolically and numbers with unit conversion.
- **Calculus checks:** Verifies derivatives, antiderivatives, definite integrals and limits.
- **Solution set check:** Substitutes claims and flags missing solutions.
- **Dimensional analysis:** Detects unit mismatches with Pint.
- **Whole-document check:** Reads LaTeX or Markdown solutions and reports per step.

## Good for

- Verify a model's worked physics solution
- Grade LLM answers in an evaluation against reference results
- Confirm an integral or derivative claim
- Catch a missing root in a solved equation
- Detect inconsistent units in an equation

## Install

### Claude Code (Terminal)

```sh
claude mcp add mathguard -- uvx mathguard
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mathguard": {
      "command": "uvx",
      "args": [
        "mathguard"
      ]
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "mathguard": {
      "command": "uvx",
      "args": [
        "mathguard"
      ]
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "mathguard": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "mathguard"
      ]
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "mathguard": {
      "command": "uvx",
      "args": [
        "mathguard"
      ]
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "mathguard": {
      "command": "uvx",
      "args": [
        "mathguard"
      ]
    }
  }
}
```

## Tools

- `check_equal`: Tests whether two expressions are equal.
- `check_chain`: Checks each step of a derivation.
- `check_derivative`: Differentiates and compares.
- `check_antiderivative`: Differentiates a claimed antiderivative.
- `check_definite_integral`: Verifies a definite integral.
- `check_solutions`: Checks claimed solutions and missing ones.
- `check_value`: Evaluates a numeric claim to tolerance.
- `check_limit`: Checks a limit.
- `check_answer`: Grades final results against a reference.
- `check_document`: Checks a whole Markdown or LaTeX solution.
- `check_dimensions`: Dimensional analysis with units.

## FAQ

### Does verified mean proven?

No. It means a computer algebra system confirmed it; the README points to Lean 4 for machine-checked proofs.

### How do I install it?

pip install mathguard.

### What formats can it read?

Plain text, Markdown and LaTeX, including align and equation environments.

### Can I try it without installing?

Yes, there is a Hugging Face demo.

### How do I add mathguard to Claude Code?

Run this command in your terminal: claude mcp add mathguard -- uvx mathguard

### What are the best alternatives to mathguard?

The closest alternatives to mathguard are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/mathguard
