You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
681 B
28 lines
681 B
|
|
from fastmcp import FastMCP
|
|
from typing import Dict, Any
|
|
import math
|
|
|
|
# Initialize MCP server
|
|
mcp = FastMCP("Calc-Server")
|
|
|
|
@mcp.tool()
|
|
def square_root(x: float) -> float:
|
|
"""Calculate square root of a number"""
|
|
try:
|
|
return math.sqrt(x)
|
|
except Exception as e:
|
|
return {"error": str(e)}
|
|
|
|
@mcp.tool()
|
|
def power(base: float, exponent: float) -> float:
|
|
"""Raise a number to a power"""
|
|
try:
|
|
return math.pow(base, exponent)
|
|
except Exception as e:
|
|
return {"error": str(e)}
|
|
|
|
if __name__ == "__main__":
|
|
print("Starting Calc Server on port 6275...")
|
|
mcp.run(transport="sse", transport_kwargs={"host": "0.0.0.0", "port": 6275})
|