Skip to main content
Glama

MathServer

by ishu3022

๐Ÿ“ MathServer โ€“ MCP Project

MathServer is a simple Model Context Protocol (MCP) server built in Python that provides math operations (addition, subtraction, multiplication, division, etc.) through an API. It is designed to be connected with MCP-compatible clients like chatbots or automation tools.

This project demonstrates how to create a custom MCP server for handling computations.

๐ŸŒŸ Features

โœ… Supports basic math operations: addition, subtraction, multiplication, division

โœ… Written in pure Python

โœ… Easy to extend with new math functions (power, square root, modulo, etc.)

โœ… Works as a local MCP server that clients can connect to

โœ… Clean project structure with virtual environment setup

๐Ÿ“‚ Project Structure mathserver/ โ”œโ”€โ”€ server.py # Main MCP math server (math logic lives here) โ”œโ”€โ”€ requirements.txt # Dependencies (install with pip) โ”œโ”€โ”€ README.md # Documentation โ””โ”€โ”€ .gitignore # Ignore .env, venv, cache files

server.py โ†’ contains the Python code for math operations

requirements.txt โ†’ contains libraries to install before running

.gitignore โ†’ ignores virtual environments and secret files

๐Ÿ› ๏ธ Installation

  1. Clone the repository git clone https://github.com/your-username/mathserver.git cd mathserver

  2. Create a virtual environment python -m venv .venv

  3. Activate the virtual environment

Windows (Command Prompt):

.venv\Scripts\activate

Windows (PowerShell):

.venv\Scripts\Activate.ps1

Linux/Mac:

source .venv/bin/activate

  1. Install dependencies pip install -r requirements.txt

โ–ถ๏ธ Usage

Run the math server with:

python server.py

Once running, clients can send math requests.

Example Request { "operation": "add", "numbers": [5, 10] }

Example Response { "result": 15 }

Other Supported Operations

sub โ†’ subtraction

mul โ†’ multiplication

div โ†’ division (handles divide-by-zero safely)

๐Ÿงฉ Extending the Server

You can easily add more operations inside server.py. For example, to add power (^):

def power(a, b): return a ** b

Then update your request handler to support "operation": "power".

๐Ÿค Contributing

Contributions are welcome! ๐Ÿš€ If youโ€™d like to add new math operations, improve the server, or fix bugs:

Fork the repo

Create a feature branch (git checkout -b feature-new-operation)

Commit your changes (git commit -m "Add power operation")

Push to the branch (git push origin feature-new-operation)

Open a Pull Request

-
security - not tested
-
license - not tested
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Provides basic mathematical operations (addition, subtraction, multiplication, division) through a Model Context Protocol server. Enables MCP-compatible clients like chatbots to perform calculations by sending structured math requests.

Related MCP Servers

  • A
    security
    -
    license
    A
    quality
    A server that provides tools for performing basic arithmetic operations (addition, subtraction, multiplication, division) via the Model Context Protocol.
    Last updated -
    4
    • Apple
  • -
    security
    -
    license
    -
    quality
    A simple Model Context Protocol server that provides basic arithmetic operations (addition, subtraction, multiplication, division) as tools that can be called by Large Language Models.
  • -
    security
    -
    license
    -
    quality
    Provides basic arithmetic operations and advanced mathematical functions through the Model Context Protocol (MCP), with features like calculation history tracking and expression evaluation.
    Last updated -
  • A
    security
    -
    license
    A
    quality
    A numerical calculator based on Model Context Protocol (MCP) that provides simple arithmetic operations including addition, subtraction, multiplication, division, power, square root and integer factorial calculations.
    Last updated -
    7
    1

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ishu3022/MCP-mathserver'

If you have feedback or need assistance with the MCP directory API, please join our Discord server