pull/819/head
parent
4e457e3bcc
commit
c4c81a4767
@ -1,27 +1,36 @@
|
||||
|
||||
from fastmcp import FastMCP
|
||||
from typing import Dict, Any
|
||||
import math
|
||||
|
||||
# Initialize MCP server
|
||||
# Initialize MCP server for business calculations
|
||||
mcp = FastMCP("Calc-Server")
|
||||
|
||||
@mcp.tool()
|
||||
def square_root(x: float) -> float:
|
||||
"""Calculate square root of a number"""
|
||||
def profit_margin(revenue: float, cost: float) -> Dict[str, Any]:
|
||||
"""Calculate profit margin from revenue and cost"""
|
||||
try:
|
||||
return math.sqrt(x)
|
||||
profit = revenue - cost
|
||||
margin = (profit / revenue) * 100
|
||||
return {
|
||||
"profit": profit,
|
||||
"margin_percentage": margin,
|
||||
"summary": f"On revenue of ${revenue:.2f} and costs of ${cost:.2f}, profit is ${profit:.2f} with a margin of {margin:.1f}%"
|
||||
}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
@mcp.tool()
|
||||
def power(base: float, exponent: float) -> float:
|
||||
"""Raise a number to a power"""
|
||||
def break_even_point(fixed_costs: float, price_per_unit: float, cost_per_unit: float) -> Dict[str, Any]:
|
||||
"""Calculate break-even point"""
|
||||
try:
|
||||
return math.pow(base, exponent)
|
||||
bep = fixed_costs / (price_per_unit - cost_per_unit)
|
||||
return {
|
||||
"break_even_units": bep,
|
||||
"summary": f"You need to sell {bep:.0f} units to break even"
|
||||
}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Starting Calc Server on port 6275...")
|
||||
mcp.run(transport="sse", host="0.0.0.0", port=6275)
|
||||
print("Starting Business Calculator Server on port 6275...")
|
||||
mcp.run(transport="sse")
|
||||
|
Loading…
Reference in new issue