Skip to main content
Glama
Math MCP Server

Math MCP Server

by avanishd-3

Math MCP Server

Overview

This is an MCP (Model Context Protocol) server that can do basic arithmetic in 64 bit precision, along with matrix multiplication.

Related MCP server: Calculator MCP Server

Features

  • Addition

  • Subtraction

  • Multiplication

  • Division

  • Matrix multiplication

Installation

Prerequisities

Ensure you have the following installed:

  • Python 3.13+

  • uv

Installing UV

See installation guide for all options.

Unix/MacOS
curl -LsSf https://astral.sh/uv/install.sh | sh

or

brew install uv
Windows
winget install --id=astral-sh.uv  -e

Clone the Repository

git clone https://github.com/avanishd-3/math-mcp.git
cd math-mcp-server
uv sync

Integration with Clients

Claude Code

fastmcp install claude-code src/math_server.py:math_mcp

Claude Desktop

fastmcp install claude-desktop src/math_server.py:math_mcp

Cursor

fastmcp install cursor src/math_server.py:math_mcp

VS Code

Add the following .vscode/mcp.json and use your actual path.

{
  "servers": {
    "Math MCP Server": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "fastmcp",
        "--with",
        "numpy",
        "fastmcp",
        "run",
        "/absolute/path/Desktop/to/math-mcp-server/src/math_server.py:math_mcp"
      ]
    }
  },
}

Contributing

  1. Fork the repository

  2. Create a new branch:

git checkout -b add-feature
  1. Make changes and commit (remember to add unit tests in test/ directory)

git commit -m "Added a new feature"
  1. Push to your fork

git push origin add-feature
  1. Open a pull request.

Project Structure

/
├── src
│   └── math_server.py
├── tests
│   ├── test_arithmetic.py
│   │   └── astro.svg
│   ├── test_linear_algebra.py
├── pytest.ini
├── pyproject.toml
└── uv.lock

Architecture

This MCP server uses Fast MCP 2.0, which provides many more features than Fast MCP 1.0, which is what the official Python SDK for MCP uses.

Also, the unit tests are written with Pytest, which is what Fast MCP 2.0 recommends.

Lastly, if you don't know, uv is a much faster version of pip that also provides a lockfile for project dependencies (this will be familiar if you've used npm or cargo before). The MCP Python SDK itself uses uv, and I use it for all new Python projects, because it's 10-100x faster than pip, and the lockfile makes dependency version management much simpler.

Available Tools

5 tools
addA

Adds a list of positive and/or negative numbers with 64 bit floating point precision and returns a 64 bit float. You need to provide them in the format of a list. For example, [1, 2, 3] would return 6.0. You can also use fractions if you want to, like [1/2, 1/3, 1/4].

Inputs: numbers (required). Returns: result

divideA

Divides two numbers with 64 bit floating point precision and returns a 64 bit float. For example, dividing 10 by 2 would return 5.0. You can also use fractions if you want to, like 1/2 for number_1 and 1/3 for number_2.

Inputs: number_1 (required), number_2 (required). Returns: result

matrix_multiplicationA

Multiplies two matrices with 64 bit floating point precision and returns the result as a matrix. You need to provide them in the format of nested lists. For example, [[1, 2], [3, 4]] would represent a 2x2 matrix. Each sub list represents a row in the matrix, and each element in the sub list represents a column. The matrices must be compatible for multiplication, meaning the number of columns in the first matrix must equal the number of rows in the second matrix. You can also use fractions for individual elements if you want to, like [1/2, 1/3, 1/4].

Inputs: matrix_1 (required), matrix_2 (required). Returns: result

multiplyA

Multiplies a list of positive and/or negative numbers with 64 bit floating point precision and returns a 64 bit float. You need to provide them in the format of a list. For example, [1, 2, 3] would return 6.0. You can also use fractions if you want to, like [1/2, 1/3, 1/4].

Inputs: numbers (required). Returns: result

subtractB

Subtracts two numbers with 64 bit floating point precision and returns a 64 bit float. For example, subtracting 5 from 10 would return 5.0. You can also use fractions if you want to, like 1/2 for number_1 and 1/3 for number_2.

Inputs: number_1 (required), number_2 (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct mathematical operation: addition, division, matrix multiplication, multiplication, and subtraction. There is no overlap in purpose—add and multiply handle lists for their respective operations, while divide and subtract handle two numbers, and matrix_multiplication is uniquely for matrices. An agent can easily tell them apart based on their specific functions.

    Naming Consistency5/5

    All tool names follow a consistent verb-based pattern (add, divide, matrix_multiplication, multiply, subtract) without mixing conventions. The naming is straightforward and predictable, using simple action words that directly describe the operation, with matrix_multiplication as a compound term that still fits the verb_noun style.

    Tool Count4/5

    With 5 tools, the count is reasonable for a math server covering basic arithmetic and matrix operations. It is well-scoped, but slightly under for a comprehensive math toolkit, as it lacks tools for operations like exponentiation, trigonometry, or advanced linear algebra, which might be expected in a broader math domain.

    Completeness3/5

    The tool set covers basic arithmetic (add, subtract, multiply, divide) and matrix multiplication, but there are notable gaps for a math server. Missing operations include exponentiation, square roots, trigonometric functions, and other matrix operations (e.g., inversion, determinant), which limits the surface for handling common mathematical tasks and could lead to agent workarounds.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides basic arithmetic operations and advanced mathematical functions through the Model Context Protocol (MCP), with features like calculation history tracking and expression evaluation.
      1
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A backend service that provides accurate arithmetic calculation capabilities to AI models via the Model Context Protocol, allowing LLMs to offload mathematical computations for numerical queries.
      1
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Provides mathematical computation capabilities including basic arithmetic operations (add, subtract, multiply, divide), advanced functions (square root, factorial, logarithm), and trigonometric functions (sin, cos, tan) through the Model Context Protocol.
      5
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides basic mathematical operations including addition, subtraction, multiplication, division, and power calculations through a Model Context Protocol interface.
      5
      1
      MIT