Simple Calculator MCP Server
A basic MCP server that provides arithmetic operations (add) and random number generation, with server metadata exposed as a resource.
README
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
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.
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.