Calculator MCP server

Provides a secure mathematical expression evaluation service using Python's AST module for basic operations without relying on eval(), enabling quick calculations within conversations.
Back to servers
Provider
He Jie
Release date
Mar 20, 2025
Language
Python
Package
Stats
4.8K downloads
38 stars

This MCP server for calculations enables large language models to perform precise numerical calculations using a calculator tool. It provides a simple way to handle mathematical expressions without relying on the LLM's numerical abilities.

Installation Options

Using uv (Recommended)

With uv, no specific installation is needed as you can run the server directly using uvx:

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

Using PIP

You can install the package via pip:

pip install mcp-server-calculator

After installation with pip, run it as a script:

python -m mcp_server_calculator

Configuration Setup

To integrate the calculator with your MCP client, you'll need to update your settings.

Configuration with uv

Add this to your MCP client settings:

"mcpServers": {
  "calculator": {
    "command": "uvx",
    "args": ["mcp-server-calculator"]
  }
}

Configuration with PIP

If you installed using pip, use this configuration:

"mcpServers": {
  "calculator": {
    "command": "python",
    "args": ["-m", "mcp_server_calculator"]
  }
}

Available Tools

The server provides the following tool:

  • calculate: Evaluates mathematical expressions
    • Required parameter: expression (string) - The expression to calculate

Once configured, the LLM can use the calculator for precise numerical calculations by invoking the calculate tool with any mathematical expression.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later