Skip to main content
Glama

MCP Calculate Server

A mathematical calculation service based on MCP protocol and SymPy library, providing powerful symbolic computation capabilities.

Security

As of version 0.1.1, the server parses expressions through a restricted SymPy-only evaluator. It does not execute arbitrary Python code, and only a curated set of mathematical symbols, functions, and matrix methods are supported.

This release also adds validation for oversized expressions and large results to reduce denial-of-service risk from expensive symbolic computations.

Related MCP server: mcp-sympy

Key Features

  • Basic Operations: Addition, subtraction, multiplication, division, exponentiation

  • Algebraic Operations: Expression expansion, factorization, simplification

  • Calculus: Differentiation, integration (definite/indefinite), limit calculation

  • Equation Solving: Algebraic equations, systems of equations

  • Matrix Operations: Matrix inversion, eigenvalues/eigenvectors calculation

  • Series Expansion: Taylor series expansion

  • Special Functions: Trigonometric, logarithmic, exponential functions

Usage Examples

# Basic operations
"2 + 3*5" → 17

# Algebraic operations
"expand((x + 1)**2)" → x² + 2x + 1
"factor(x**2 - 2*x - 15)" → (x - 5)(x + 3)

# Calculus
"diff(sin(x), x)" → cos(x)
"integrate(exp(x), (x, 0, 1))" → E - 1
"integrate(exp(-x**2)*sin(x), (x, -oo, oo))" → 0
"limit(tan(x)/x, x, 0)" → 1

# Equation solving
"solve(x**2 - 4, x)" → [-2, 2]
"solve([x**2 + y**2 - 1, x + y - 1], [x, y])" → [(0, 1), (1, 0)]

# Matrix operations
"Matrix([[1, 2], [3, 4]]).inv()" → [[-2, 1], [3/2, -1/2]]
"Matrix([[1, 2, 3], [4, 5, 6]]).eigenvals()" → {9/2 - sqrt(33)/2: 1, 9/2 + sqrt(33)/2: 1}
"Sum(k, (k, 1, 10)).doit()" → 55
"series(cos(x), x, 0, 4)" → 1 - x²/2 + O(x⁴)

Installation

Installing via Smithery

To install Calculate Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @611711Dark/mcp_sympy_calculate_server --client claude

Local Installation

  1. Clone repository:

    git clone https://github.com/611711Dark/mcp_calculate_server.git
    cd mcp_calculate_server
  2. Create virtual environment and install dependencies:

    uv venv
    source .venv/bin/activate
    uv pip install -e .
  3. Configuration:

    "calculate_expression1": {
       "isActive": false,
       "command": "python",
       "args": [
         "server.py"
       ],
       "cwd": "/path/to/mcp_calculate_server"
     }

API Usage

Call calculate_expression tool via MCP protocol by passing a mathematical expression string. The parser accepts a restricted set of SymPy expressions such as arithmetic, expand, factor, simplify, diff, integrate, limit, series, solve, Matrix(...).det()/inv()/eigenvals()/eigenvects(), and Sum(...).doit().

Supported Names

  • Symbols: lowercase variables such as x, y, z, and k

  • Constants: pi, E, oo, I

  • Functions: Abs, sin, cos, tan, log, exp, sqrt, expand, factor, simplify, diff, integrate, limit, series, solve, Sum, Matrix

  • Matrix methods: .det(), .inv(), .eigenvals(), .eigenvects()

  • SymPy method: .doit() on supported objects such as Sum(...)

Validation Rules

Expressions that rely on arbitrary Python features, imports, filesystem access, or other non-mathematical constructs are intentionally rejected. Very large expansions, high-complexity solves, and oversized results may also be rejected to reduce denial-of-service risk. Keyword arguments, private attributes, unsupported matrix methods, malformed matrices, and unsupported names are rejected with an error message.

Dependencies

  • mcp>=1.5.0

  • sympy>=1.13.3

Acknowledgements

Thanks to this blog post for the introduction, and to Stefano for his help and responsible disclosure.

License

This project is licensed under MIT License. See LICENSE file.

中文版本

Available Tools

1 tool
calculate_expressionA

calculate mathematical expressions using the sympify function from sympy, parse and compute the input mathematical expression string, supports direct calls to SymPy functions (automatically recognizes x, y, z as symbolic variables) Parameters: expression (str): Mathematical expression, e.g., "223 - 344 * 6" or "sin(pi/2) + log(10)".Replace special symbols with approximate values, e.g., pi → 3.1415" Example expressions: "2 + 3*5" # Basic arithmetic → 17 "expand((x + 1)2)" # Expand → x² + 2x + 1 "diff(sin(x), x)" # Derivative → cos(x) "integrate(exp(x), (x, 0, 1))" # Definite integral → E - 1 "solve(x2 - 4, x)" # Solve equation → [-2, 2] "limit(tan(x)/x, x, 0)" # Limit → 1 "Sum(k, (k, 1, 10)).doit()" # Summation → 55 "Matrix([[1, 2], [3, 4]]).inv()" # Matrix inverse → [[-2, 1], [3/2, -1/2]] "simplify((x2 - 1)/(x + 1))" # Simplify → x - 1 "factor(x2 - 2*x - 15)" # Factorize → (x - 5)(x + 3) "series(cos(x), x, 0, 4)" # Taylor series → 1 - x²/2 + x⁴/24 + O(x⁴) "integrate(exp(-x*2)*sin(x), (x, -oo, oo))" # Complex integral "solve([x**2 + y*2 - 1, x + y - 1], [x, y])" # Solve system of equations "Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).eigenvals()" # Matrix eigenvalues Returns: str: Calculation result. If the expression cannot be parsed or computed, returns an error message (str).

Inputs: expression (required). Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of ambiguity or confusion between tools. The single tool 'calculate_expression' has a clearly defined purpose that cannot be mistaken for any other tool in this server.

    Naming Consistency5/5

    The single tool name 'calculate_expression' follows a clear verb_noun pattern. With only one tool, naming consistency is inherently perfect as there are no other tools to compare against or create inconsistencies with.

    Tool Count2/5

    A single tool server is generally too minimal for most practical purposes, even for a focused domain like mathematical calculation. While the tool is powerful, having only one tool feels thin and limiting for what appears to be a comprehensive mathematical computation server.

    Completeness3/5

    The single tool covers a wide range of mathematical operations through expression parsing, but there are notable gaps in the surface area. For a calculation server, one might expect separate tools for different mathematical domains (algebra, calculus, matrix operations) or at least tools for common specific operations beyond general expression evaluation.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      F
      maintenance
      A Mathematical Computation Protocol server providing 286 mathematical functions across multiple domains with flexible transport options (STDIO/HTTP) and streaming capabilities.
      100
      4
      Apache 2.0
    • A
      license
      C
      quality
      D
      maintenance
      An MCP server that provides access to SymPy's symbolic mathematics library for advanced algebraic computations. It enables users to perform complex tasks such as symbolic simplification, calculus, equation solving, matrix operations, and number theory.
      100
      58 PyPI
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      High-precision mathematics server for MCP clients, providing exact integer arithmetic, symbolic derivatives, and numerical calculus via LaTeX-style input.
      6
      8 npm
      2
      MIT