local-mcp-server-calculator

Sourav04/local-mcp-server-calculator

3.1

If you are the rightful owner of local-mcp-server-calculator and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This project is a simple MCP server using fastmcp that provides basic calculation tools: add, subtract, multiply, and divide.

Tools
4
Resources
0
Prompts
0

MCP Calculator Server

This project is a simple MCP server using fastmcp that provides basic calculation tools: add, subtract, multiply, and divide.

Setup

  1. Install dependencies

    Ensure you have Python 3.10+ installed.

    and Install fasmcp using uv or pip

  2. Run the server

    python server.py
    

    The server will start at http://127.0.0.1:8000/mcp (if using HTTP transport). (use this only for testing as the client tool will be running the server as well during testing)

Tools

  • add(a: float, b: float) -> float
  • subtract(a: float, b: float) -> float
  • multiply(a: float, b: float) -> float
  • divide(a: float, b: float) -> float (raises error if b == 0)

You can connect to this server using a fastmcp client or extend it with more tools as needed.


Using the Test Client (via stdio)

A sample client is provided in test_client.py to demonstrate how to interact with the MCP server using stdio transport.

How to Run the Client

  1. Make sure you are in the mcp directory:
    cd mcp
    
  2. Run the client:
    python3 test_client.py
    

The client will automatically start the server and print the results of the calculator tools:

add(5, 3) = 8.0
subtract(10, 4) = 6.0
multiply(6, 7) = 42.0
divide(20, 5) = 4.0

You do not need to start the server separately when using stdio transport with the client.

Snapshot Screenshot 2025-07-26 at 12 36 40 PM