This is a Python sample for an MCP Server
Here's what the calculator portion looks like:
@mcp.tool()
def add(a: float, b: float) -> float:
"""Add two numbers together and return the result."""
return a + b
@mcp.tool()
def subtract(a: float, b: float) -> float:
"""Subtract b from a and return the result."""
return a - b
@mcp.tool()
def multiply(a: float, b: float) -> float:
"""Multiply two numbers together and return the result."""
return a * b
@mcp.tool()
def divide(a: float, b: float) -> float:
"""
Divide a by b and return the result.
Raises:
ValueError: If b is zero
"""
if b == 0:
raise ValueError("Cannot divide by zero")
return a / bRun the following command:
pip install mcppython mcp_calculator_server.py