Simple Calculator MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Simple Calculator MCP Serveradd 15 and 25"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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: Demo 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 SimpleCalculatorMCPServer2. Create a virtual environment
uv venv3. Activate the environment
Linux/macOS
source .venv/bin/activateWindows
.venv\Scripts\activate4. Install FastMCP
uv add fastmcpRunning the Server
Start the MCP server:
python main.pyor
uv run python main.pyThe server will start on:
http://localhost:8000Available 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
402. 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
27Available 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:
addTool:
random_numberResource:
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.
Related MCP Connectors
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA basic MCP server example that provides simple arithmetic tools (addition and subtraction) and personalized greeting resources. Serves as a foundation for learning MCP server implementation and development.-
- FlicenseNot gradedqualityDmaintenanceA simple MCP server that exposes a calculator tool (addition) and a dynamic greeting resource.16-
- FlicenseNot gradedqualityDmaintenanceBasic MCP server demonstrating tools for arithmetic operations (add, subtract) and a personalized greeting resource.1-
- AlicenseNot gradedqualityDmaintenanceA basic MCP server that provides arithmetic tools (add, subtract) and a greeting resource, demonstrating core MCP concepts.GPL 3.0