annaescalada/mcp-python-calculator
3.2
If you are the rightful owner of mcp-python-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 document provides a structured overview of a minimal Model Context Protocol (MCP) server implemented in Python, designed to perform basic arithmetic operations and provide personalized greetings.
Tools
1
Resources
0
Prompts
0
🧮 MCP Python Calculator
A minimal Model Context Protocol (MCP) server in Python. This server exposes:
- A tool
add(a, b)
to sum two integers. - A resource
greeting://{name}
that returns a personalized greeting.
Useful as a starting point to learn how to build MCP servers.
🚀 Setup
- Clone the repo and move into it:
git clone https://github.com/your-user/mcp-python-calculator.git
cd mcp-python-calculator
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows (PowerShell)
- Install dependencies:
pip install -r requirements.txt
▶️ Run the server
mcp run -t sse server.py
This starts the MCP server on:
http://127.0.0.1:8000/sse
🔎 Test with curl
Add two numbers
curl http://127.0.0.1:8000/sse
(you will see streaming events)
Greeting resource
# Example resource
python -c 'from server import get_greeting; print(get_greeting("Anna"))'
🛠 VS Code integration (optional)
Create .vscode/mcp.json
:
{
"servers": {
"calculator": {
"command": "/absolute/path/to/venv/bin/mcp",
"args": ["run", "-t", "sse", "server.py"],
"transport": "sse"
}
}
}
When MCP support is enabled in Copilot, it will detect this server and expose the add
tool.