From 5919480312bd37e84e0454bedafdd4447dc9e86f Mon Sep 17 00:00:00 2001 From: goulustis Date: Tue, 20 Jan 2026 14:54:05 +0800 Subject: [PATCH] move fastapi to main --- lang_agent/dummy/calculator.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lang_agent/dummy/calculator.py b/lang_agent/dummy/calculator.py index c80b221..566050d 100644 --- a/lang_agent/dummy/calculator.py +++ b/lang_agent/dummy/calculator.py @@ -50,20 +50,18 @@ class Calculator(LangToolBase): return [self.calculator] -# Global calculator instance -calculator = Calculator(CalculatorConfig()) - -# FastMCP server setup -from fastmcp import FastMCP - -mcp = FastMCP("Calculator Server") - - -@mcp.tool() -async def calculate(python_expression: str) -> dict: - """For mathematical calculation, always use this tool to calculate the result of a python expression. You can use 'math' or 'random' directly, without 'import'.""" - return await calculator.calculator_async(python_expression) - - if __name__ == "__main__": + # Global calculator instance + calculator = Calculator(CalculatorConfig()) + + # FastMCP server setup + from fastmcp import FastMCP + + mcp = FastMCP("Calculator Server") + + + @mcp.tool() + async def calculate(python_expression: str) -> dict: + """For mathematical calculation, always use this tool to calculate the result of a python expression. You can use 'math' or 'random' directly, without 'import'.""" + return await calculator.calculator_async(python_expression) mcp.run(transport="streamable-http", host="0.0.0.0", port=9000)