Skip to main content
Let’s create a simple calculator MCP server that provides basic math operations.
from fastmcp import FastMCP

mcp = FastMCP("Calculator MCP Server")

@mcp.tool
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

@mcp.tool
def subtract(a: int, b: int) -> int:
    """Subtract two numbers"""
    return a - b

@mcp.tool
def multiply(a: int, b: int) -> int:
    """Multiply two numbers"""
    return a * b

@mcp.tool
def divide(a: float, b: float) -> float:
    """Divide two numbers"""
    if b == 0:
        raise ValueError("Cannot divide by zero")
    return a / b

@mcp.tool
def power(a: int, b: int) -> int:
    """Raise a number to the power of another number"""
    return a ** b

if __name__ == "__main__":
    mcp.run(transport="http", host="0.0.0.0", port=8000, path="/mcp")

Run Locally

# Install dependencies
pip install -r requirements.txt

# Run the server
python server.py
Your MCP server will be available at http://localhost:8000/mcp.
We have already added this code to a Github Repo and deployed it on our live demo link:Repository: You can find the complete example code at: Calculator MCP ServerDeployment: You can find the live demo link at: Calculator MCP Server DeploymentServer Endpoint: The MCP server can be accessed at this endpoint: https://calculator-mcp-server.apps.live-demo.truefoundry.cloud

Register in TrueFoundry

To add this MCP server to your MCP group, provide the following details:
FieldValue
Namecalculator-mcp-server
Endpoint URLhttps://calculator-mcp-server.apps.live-demo.truefoundry.cloud
DescriptionA simple calculator MCP server
AuthenticationNo Auth