Skip to main content
Glama
BinCha1

Simple Calculator MCP Server

by BinCha1

Simple Calculator MCP Server

A simple Model Context Protocol (MCP) server built with FastMCP that demonstrates how to create MCP Tools and Resources. This project exposes basic arithmetic operations, random number generation, and server metadata over the HTTP transport.


Features

  • ➕ Add two integers

  • 🎲 Generate a random number within a specified range

  • 📄 Expose server information as an MCP Resource

  • 🌐 HTTP transport support


Related MCP server: API MCP Server

Project Structure

SimpleCalculatorMCPServer/
│
├── main.py
├── pyproject.toml
├── README.md
└── .venv/

Requirements

  • Python 3.10+

  • uv

  • FastMCP


Installation

1. Clone the repository

git clone <repository-url>
cd SimpleCalculatorMCPServer

2. Create a virtual environment

uv venv

3. Activate the environment

Linux/macOS

source .venv/bin/activate

Windows

.venv\Scripts\activate

4. Install FastMCP

uv add fastmcp

Running the Server

Start the MCP server:

python main.py

or

uv run python main.py

The server will start on:

http://localhost:8000

Available Tools

1. add

Adds two integers.

Parameters

Name

Type

Description

a

int

First integer

b

int

Second integer

Example

Input

{
  "a": 15,
  "b": 25
}

Output

40

2. random_number

Generates a random integer within a given range.

Parameters

Name

Type

Default

min_val

int

1

max_val

int

100

Example

Input

{
  "min_val": 10,
  "max_val": 50
}

Output

27

Available Resource

info://server

Returns metadata about the MCP server.

Example Response

{
  "name": "Simple Calculator Server",
  "Version": "1.0.0",
  "Description": "A basic MCP server with math tools and random number generation.",
  "tools": [
    "add",
    "random_number"
  ],
  "authors": "BinishaChapagain"
}

Transport

The server runs using the HTTP transport.

Configuration:

mcp.run(
    transport="http",
    host="0.0.0.0",
    port=8000
)

Testing

You can test the server using:

  • FastMCP Inspector

  • OpenCode

  • Any MCP-compatible client

Available endpoints:

  • Tool: add

  • Tool: random_number

  • Resource: info://server


Technologies Used

  • Python

  • FastMCP

  • Model Context Protocol (MCP)


Learning Objectives

This project demonstrates how to:

  • Create an MCP server using FastMCP.

  • Register MCP tools.

  • Register MCP resources.

  • Expose an MCP server over HTTP.

  • Interact with the server using an MCP client.

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

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/BinCha1/simple-calculator-mcp-server'

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