Features
- FastMCP Framework: Simplified Python MCP development
- Arithmetic Operations: Add, subtract, multiply, divide
- Error Handling: Division by zero protection
- Minimal Setup: Quick to install and configure
Installation
Tools
calculate
Perform arithmetic operations on two numbers. Parameters:a(float): First numberb(float): Second numberoperation(string): Operation to perform -add,subtract,multiply, ordivide
Implementation
Server Setup
The server uses FastMCP for simplified MCP server creation:Arithmetic Functions
Core calculator operations:Calculator Tool
Unified tool that routes to specific operations:Running the Server
Complete Server Code
Error Handling
The calculator includes built-in error handling:Division by Zero
Invalid Operation
FastMCP Benefits
FastMCP simplifies MCP server development:Decorator-Based
Use
@mcp.tool() decorator to register tools automaticallyType Hints
Python type hints automatically define parameter schemas
Built-in Transport
Stdio transport configured with
mcp.run(transport='stdio')Error Handling
Automatic error serialization and reporting
Dependencies
pyproject.toml:mcp[cli]>=1.6.0- MCP SDK with CLI tools and FastMCP framework
Testing the Server
You can test the calculator using the MCP inspector:Extending the Calculator
Add more operations by defining new functions and updating the tool:Troubleshooting
Python version error
Python version error
This server requires Python 3.13+. Check your version:Install Python 3.13+ from python.org if needed.
uv not found
uv not found
Install uv for faster dependency management:Or use pip instead:
Import errors
Import errors
Ensure mcp package is installed:Reinstall if needed:
Project Structure
Next Steps
Basic TypeScript
Explore advanced MCP features with TypeScript
EDteam Go Server
Learn about API integration with Go MCP servers