MCP Calculator Server
A minimal Model Context Protocol server that provides basic arithmetic tools and a comprehensive meeting analysis prompt template for processing transcripts. It serves as a clean example for developers to learn how to build, test, and integrate MCP servers with Claude Desktop.
README
MCP Calculator Server
This repository provides a minimal Model Context Protocol (MCP) server that exposes simple calculator tools (add, subtract, multiply, divide). It's intended as a clean example you can publish to GitHub and use as a starting point for MCP work.
This README covers: setup, running, testing, and publishing the project.
Quick start (Windows PowerShell)
- Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
- Install the MCP SDK (inside the venv):
pip install "mcp[cli]"
- Run the server (stdio transport):
python calculator_server.py
- Run tests (if you use pytest):
python -m pytest
Requirements
- Python 3.11+ (3.10 may work but 3.11+ recommended)
mcppackage (install withpip install "mcp[cli]")
Running the server
Via stdio (standard input/output)
Default transport — recommended for local testing and Claude Desktop integration:
python calculator_server.py
This starts the server using stdio, which communicates via standard input/output streams. The server will wait for connections from MCP clients (e.g., Claude Desktop, MCP Inspector).
Via HTTP (streamable-http transport)
For local testing over HTTP:
python calculator_server.py --transport streamable-http --host 127.0.0.1 --port 8000
This binds the server to http://127.0.0.1:8000 (localhost only). You can then connect
MCP clients via HTTP to this address.
For external access (binding to all interfaces):
python calculator_server.py --transport streamable-http --host 0.0.0.0 --port 8080
⚠️ Warning: Binding to 0.0.0.0 or an explicit external IP will disable DNS rebinding
protection, allowing external clients to connect. This may expose the server to DNS rebinding
attacks. Only use external binding when you understand the security implications and trust
the clients connecting to it.
Custom host/port examples:
# Bind to a specific IP address
python calculator_server.py --transport streamable-http --host 192.168.1.100 --port 5000
# Bind to localhost with a different port
python calculator_server.py --transport streamable-http --host 127.0.0.1 --port 9000
Claude Desktop Configuration
To use the calculator server with Claude Desktop, add the following configuration to your
claude_desktop_config.json file (typically located at ~/.claude/claude_desktop_config.json
on macOS/Linux or %APPDATA%\Claude\claude_desktop_config.json on Windows).
Via stdio (recommended for Claude Desktop)
{
"mcpServers": {
"calculator": {
"command": "uv",
"args": [
"--directory",
"F:\\mcp2\\VSMCP\\VSMCP",
"run",
"python",
"calculator_server.py"
],
"env": {
"UV_PROJECT_ENVIRONMENT": ".venv"
}
}
}
}
Replace F:\\mcp2\\VSMCP\\VSMCP with the full path to your project directory.
After updating the config, restart Claude Desktop. The calculator tools will be available in your conversations.
Via HTTP streamable (localhost)
If you prefer to run the server over HTTP on localhost:
{
"mcpServers": {
"calculator": {
"command": "uv",
"args": [
"--directory",
"F:\\mcp2\\VSMCP\\VSMCP",
"run",
"python",
"calculator_server.py",
"--transport",
"streamable-http",
"--host",
"127.0.0.1",
"--port",
"8000"
],
"env": {
"UV_PROJECT_ENVIRONMENT": ".venv"
}
}
}
}
Replace F:\\mcp2\\VSMCP\\VSMCP with the full path to your project directory.
After updating the config, restart Claude Desktop.
Via HTTP streamable (external access)
If you want external clients to access the server over HTTP:
{
"mcpServers": {
"calculator": {
"command": "uv",
"args": [
"--directory",
"F:\\mcp2\\VSMCP\\VSMCP",
"run",
"python",
"calculator_server.py",
"--transport",
"streamable-http",
"--host",
"0.0.0.0",
"--port",
"8080"
],
"env": {
"UV_PROJECT_ENVIRONMENT": ".venv"
}
}
}
}
⚠️ Warning: Binding to 0.0.0.0 disables DNS rebinding protection. Only do this
if you understand the security implications.
Tests
- Run the included tests with:
python -m pytest
or, if you prefer the single-file runner:
python test_mcp.py
Files removed from repo
I removed the following build / artifact files from the repository because they are not needed in source control:
__pycache__/(Python bytecode caches)mcp_calculator_server.egg-info/(packaging metadata)nodejs.zip(archival artifact)
If you want any of these preserved, let me know and I can restore them.
Git / Publishing suggestions
- Add these entries to
.gitignore(this repo already contains a.gitignore):
.venv/
__pycache__/
*.py[cod]
*.egg-info/
node_modules/
- To publish to GitHub:
git init
git add .
git commit -m "Initial commit: MCP calculator server"
git branch -M main
git remote add origin https://github.com/<your-user>/<your-repo>.git
git push -u origin main
Next steps
- Add a
requirements.txtorpyproject.tomldependency specification if you want reproducible installs. - Add CI (GitHub Actions) to run tests on push.
If you want, I can:
- run the test suite locally and update this README with exact commands I used,
- add a
requirements.txtorpyproject.tomlsnippet, - create a simple GitHub Actions workflow to run tests on push.
calculator_server.py is the main entrypoint; see its docstring and code for details.
This launches a web-based UI where you can test your calculator tools.
-
In the inspector, connect to
stdioand select your running server -
Try calling a tool, for example:
- Tool:
add - Parameters:
{"a": 5, "b": 3} - Expected result:
8
- Tool:
-
Test other tools:
subtract:{"a": 10, "b": 4}→6multiply:{"a": 5, "b": 3}→15divide:{"a": 15, "b": 3}→5.0divide(error test):{"a": 10, "b": 0}→ Error: "Cannot divide by zero"
Using the Calculator Server with Claude
Option A: Claude Desktop Integration
To use the calculator server with Claude Desktop:
uv run mcp install calculator_server.py --name "Calculator"
This registers the server with Claude Desktop. Once installed, you can use the calculator tools in your Claude conversations by asking Claude to perform arithmetic operations.
Option B: Direct MCP Inspector Testing
uv run mcp dev calculator_server.py
This launches the MCP Inspector for interactive testing and development.
Server Capabilities
The MCP Calculator Server exposes three main types of MCP capabilities:
Tools (Calculator Functions)
The server provides the following arithmetic tools that can be called by MCP clients:
-
add: Add two numbers together
- Parameters:
a(float),b(float) - Returns: Sum of a and b
- Parameters:
-
subtract: Subtract b from a
- Parameters:
a(float),b(float) - Returns: Difference (a - b)
- Parameters:
-
multiply: Multiply two numbers
- Parameters:
a(float),b(float) - Returns: Product of a and b
- Parameters:
-
divide: Divide a by b
- Parameters:
a(float),b(float) - Returns: Quotient (a / b)
- Note: Returns an error if b is zero
- Parameters:
Resources
The server provides the following resources that clients can read:
- MCP TypeScript SDK Documentation (
resource://typescriptsdk)- MIME Type:
text/markdown - Contains: Complete TypeScript SDK documentation for building MCP clients
- MIME Type:
Prompts
The server provides pre-written prompt templates that help users accomplish specific tasks:
- Meeting Analysis Template (
meeting_analysis)- A comprehensive framework for analyzing meeting transcripts and generating executive summaries, detailed minutes, action items, and risk analysis
- See Meeting Analysis Prompt Template section below for details
Meeting Analysis Prompt Template
Overview
The MCP Calculator Server includes a powerful Meeting Analysis prompt template that helps analyze meeting transcripts with exceptional attention to detail. This prompt is designed for executive assistants and business professionals who need to transform raw meeting transcripts into structured, actionable insights.
How to Use the Meeting Analysis Prompt
When you call the meeting_analysis prompt with your meeting details, it will guide you through a comprehensive analysis framework with five key sections:
Parameters:
meeting_date(string): The date when the meeting took place (e.g., "January 30, 2026")meeting_title(string): The title or subject of the meeting (e.g., "Q1 Strategy Planning")transcript(string): The full transcript of the meeting
Example Usage in Claude Desktop:
Once the server is connected, you can request the prompt by saying something like:
"Please analyze this meeting using the meeting analysis template. The meeting was held on January 30, 2026, titled 'Strategic Planning Session', and here's the transcript: [paste transcript here]"
Analysis Output
The prompt will structure the analysis into five comprehensive sections:
- Executive Summary - Overview of meeting purpose, strategic decisions, and critical insights
- Detailed Minutes - Organized by topic with attendees, discussions, decisions, and action items
- Key Decisions & Action Items - Enumerated decisions with clear responsibility assignments and deadlines
- Risk Analysis - Identified risks, opportunities, and areas requiring further discussion
- Individual Contributions - Summary of key points by each participant and their commitments
Template Principles
The meeting analysis template follows these professional guidelines:
- Objective and Factual: Captures what was actually discussed without bias
- Comprehensive: Captures both explicit and implicit information from the meeting
- Professional: Maintains appropriate business language and tone
- Strategic: Highlights strategic implications and business impact
- Actionable: Includes clear follow-up requirements and next steps
Project Structure
After setup, your project folder should look like:
your-project-folder/
├── .venv/ # Virtual environment (created by uv venv)
│ ├── Scripts/ # Executable scripts (Windows)
│ ├── bin/ # Executable scripts (macOS/Linux)
│ └── lib/ # Python packages
├── calculator_server.py # The MCP server code (the file you created)
├── README.md # This file
└── .gitignore # (Optional) Git ignore file
Important folders:
.venv/- Virtual environment. Do NOT commit this to gitcalculator_server.py- Your MCP server implementation
Troubleshooting
Issue: Virtual environment won't activate
Solution: Ensure you're in the correct directory and the .venv folder exists.
# Check if .venv exists
ls .venv # macOS/Linux
dir .venv # Windows PowerShell
# If not, recreate it
uv venv
Issue: "mcp command not found"
Solution: Make sure the virtual environment is activated:
# Windows
.\.venv\Scripts\Activate.ps1
# macOS/Linux
source .venv/bin/activate
Then verify:
mcp --version
Issue: "Python not found"
Solution: Python isn't installed or not in PATH. Follow Step 1 to install Python and ensure "Add Python to PATH" is checked during installation (Windows).
Issue: "Permission denied" on macOS/Linux
Solution: You may need to make the script executable:
chmod +x calculator_server.py
Issue: Division by zero error
Solution: The server intentionally prevents division by zero. Use the divide tool with non-zero divisors.
Issue: "ModuleNotFoundError: No module named 'mcp'"
Solution: Make sure the virtual environment is activated and MCP is installed:
# Verify you're in the virtual environment
# Your prompt should show (.venv)
# Reinstall MCP if needed
uv pip install "mcp[cli]"
Issue: Port already in use (if using HTTP transport)
Solution: The default stdio transport doesn't use ports. If you modified the server to use HTTP, kill the process using that port:
Windows:
netstat -ano | findstr :8000
taskkill /PID <PID> /F
macOS/Linux:
lsof -i :8000
kill -9 <PID>
Deactivating the Virtual Environment
When you're done working on the project:
deactivate
Your prompt will return to normal (without the (.venv) prefix).
To work on the project again, simply activate the virtual environment using Step 5.
Next Steps
-
Explore the MCP Specification: Visit modelcontextprotocol.io for more information
-
Try the Meeting Analysis Prompt: Use the new
meeting_analysisprompt template to analyze meeting transcripts and generate professional summaries with structured insights -
Add More Tools: Extend
calculator_server.pywith additional mathematical functions like:- Power:
a ** b - Square root:
math.sqrt(a) - Logarithm:
math.log(a) - Trigonometric functions
- Power:
-
Create Custom Prompts: Add your own prompt templates for domain-specific tasks (e.g., code review, document analysis, customer support templates)
-
Build Complex Servers: Learn to add resources and advanced features to create specialized MCP servers
-
Use with Clients: Connect to Claude, ChatGPT, or other MCP-compatible clients
-
Deploy Your Server: Learn about different transport options (HTTP, SSE, stdio)
Important Notes
- Always activate the virtual environment before running the server or installing packages
- Keep the virtual environment in your project folder (
.venv) for easy management - Never share your
.venvfolder - others can recreate it withuv venvanduv pip install "mcp[cli]" - The server uses stdio transport by default, which works with MCP Inspector and clients
- All tools return structured output based on their type hints (floats, in this case)
- Tools support error handling - the
dividefunction raises an exception on division by zero - Prompts enable you to define structured templates and workflows that guide users through complex tasks (e.g., the Meeting Analysis template)
- The server exposes three types of MCP capabilities: Tools (callable functions), Resources (readable data), and Prompts (structured templates)
Resources
- Model Context Protocol Documentation
- MCP Python SDK Documentation
- MCP Specification
- uv Documentation
- Python Virtual Environments
- MCP Inspector
Congratulations! You now have a working MCP calculator server. Happy calculating! 🧮
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。