From 6508d260e533fc451a613cbc6e2e48977f8d0b82 Mon Sep 17 00:00:00 2001 From: goulustis Date: Sat, 11 Oct 2025 15:25:42 +0800 Subject: [PATCH] add dummy stuff --- dummy/calculator.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 dummy/calculator.py diff --git a/dummy/calculator.py b/dummy/calculator.py new file mode 100644 index 0000000..56992f2 --- /dev/null +++ b/dummy/calculator.py @@ -0,0 +1,45 @@ +# NOTE: dummy mcp for developement + +# server.py +from mcp.server.fastmcp import FastMCP +import sys +import logging + +logger = logging.getLogger('Calculator') + +# Fix UTF-8 encoding for Windows console +if sys.platform == 'win32': + sys.stderr.reconfigure(encoding='utf-8') + sys.stdout.reconfigure(encoding='utf-8') + +import math +import random + +# Create an MCP server +mcp = FastMCP("Calculator") + +# Add an addition tool +# @mcp.tool() +# def calculator(python_expression: str) -> dict: +# """For mathamatical calculation, always use this tool to calculate the result of a python expression. You can use 'math' or 'random' directly, without 'import'.""" +# result = eval(python_expression, {"math": math, "random": random}) +# logger.info(f"Calculating formula: {python_expression}, result: {result}") +# return {"success": True, "result": result} + +class Calculator: + def __init__(self): + pass + + @mcp.tool() + def calculator(self, python_expression: str) -> dict: + """For mathamatical calculation, always use this tool to calculate the result of a python expression. You can use 'math' or 'random' directly, without 'import'.""" + result = eval(python_expression, {"math": math, "random": random}) + logger.info(f"Calculating formula: {python_expression}, result: {result}") + return {"success": True, "result": result} + + + +# Start the server +if __name__ == "__main__": + + mcp.run(transport="stdio")