Calculator MCP Server

Calculator MCP Server

A Python-based MCP server that provides a suite of basic arithmetic tools, including addition, square roots, and percentage calculations, for AI assistants. It enables models to perform precise mathematical operations through the Model Context Protocol.

Category
Visit Server

README

Calculator MCP Server

Python 3.10+ MCP License: MIT

A simple calculator MCP (Model Context Protocol) server that exposes arithmetic operations as tools for AI assistants like Claude.

What is MCP?

Model Context Protocol (MCP) is an open protocol that enables AI assistants to interact with external tools and data sources. This server demonstrates how to build MCP tools using Python.

Features

Tool Description Example
add Add two numbers add(5, 3)8
subtract Subtract numbers subtract(10, 4)6
multiply Multiply numbers multiply(6, 7)42
divide Divide with zero-check divide(15, 3)5.0
power Exponentiation power(2, 3)8.0
modulo Remainder operation modulo(17, 5)2
square_root Square root square_root(16)4.0
absolute Absolute value absolute(-5)5
percentage Calculate percentage percentage(200, 15)30.0

Installation

Prerequisites

  • Python 3.10 or higher
  • pip package manager

Install from source

git clone https://github.com/Sathiya-Moorthi/MCP.git
cd calculator-mcp
pip install -e .

Install dependencies only

pip install mcp

Usage

With Claude Desktop

Add to your Claude Desktop configuration file:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "calculator": {
      "command": "python",
      "args": ["/path/to/calculator-mcp/calculator_server.py"]
    }
  }
}

Restart Claude Desktop, then ask Claude to perform calculations!

With Cursor IDE

Add to your Cursor MCP configuration (~/.cursor/mcp.json):

{
  "mcpServers": {
    "calculator": {
      "command": "python",
      "args": ["/path/to/calculator-mcp/calculator_server.py"]
    }
  }
}

Standalone Testing

python calculator_server.py

The server communicates via stdio (standard input/output) using the MCP protocol.

Development

Setup development environment

# Clone the repository
git clone https://github.com/Sathiya-Moorthi/MCP.git
cd calculator-mcp

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e ".[dev]"

Run tests

pytest

Project Structure

calculator-mcp/
├── calculator_server.py    # Main MCP server implementation
├── pyproject.toml          # Project configuration
├── tests/
│   └── test_calculator.py  # Unit tests
├── .github/
│   └── workflows/
│       └── ci.yml          # GitHub Actions CI
├── README.md
├── LICENSE
└── .gitignore

How It Works

This server uses FastMCP, a high-level API from the official MCP Python SDK:

from mcp.server.fastmcp import FastMCP

mcp = FastMCP(name="calculator")

@mcp.tool()
def add(a: float, b: float) -> float:
    """Add two numbers together."""
    return a + b

if __name__ == "__main__":
    mcp.run()

Key concepts:

  • @mcp.tool() decorator - Registers functions as MCP tools
  • Type hints - Define parameter types for validation
  • Docstrings - Become tool descriptions visible to AI
  • mcp.run() - Starts the server with stdio transport

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Acknowledgments

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured