Fix formatting issues in community environments - Applied black, isort, trailing whitespace, and end-of-file fixes - Remaining flake8 issues (unused imports, line length) noted for future cleanup

This commit is contained in:
Shannon Sands 2025-05-23 13:33:13 +10:00
parent e85a170c34
commit 7f2e1a4f90
34 changed files with 1560 additions and 821 deletions

View file

@ -1,18 +1,19 @@
from mcp.server.fastmcp import FastMCP
import logging
import os
from mcp.server.fastmcp import FastMCP
# Setup logging to a file
# Adjust the log file path if necessary, perhaps to be relative to this script's location
# or a dedicated logs directory.
log_file_path = os.path.join(os.path.dirname(__file__), 'math_server_official.log')
log_file_path = os.path.join(os.path.dirname(__file__), "math_server_official.log")
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(name)s - %(message)s',
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
handlers=[
logging.FileHandler(log_file_path, mode='w'), # 'w' to overwrite each run
logging.StreamHandler()
]
logging.FileHandler(log_file_path, mode="w"), # 'w' to overwrite each run
logging.StreamHandler(),
],
)
logger = logging.getLogger(__name__)
@ -20,17 +21,21 @@ mcp = FastMCP("Official Math Server 🚀")
@mcp.tool()
def add(a: int, b: int) -> int: # Changed return type hint to int
def add(a: int, b: int) -> int: # Changed return type hint to int
"""Add two numbers and return the result"""
logger.info(f"Executing add tool with a={a}, b={b}")
return a + b
@mcp.tool()
def multiply(a: int, b: int) -> int: # Changed return type hint to int
def multiply(a: int, b: int) -> int: # Changed return type hint to int
"""Multiply two numbers and return the result"""
logger.info(f"Executing multiply tool with a={a}, b={b}")
return a * b
if __name__ == "__main__":
logger.info(f"Starting Official MCP math_server.py with STDIO transport... Log file: {log_file_path}")
mcp.run(transport="stdio") # Ensure stdio transport is used as in server_stdio.py
logger.info(
f"Starting Official MCP math_server.py with STDIO transport... Log file: {log_file_path}"
)
mcp.run(transport="stdio") # Ensure stdio transport is used as in server_stdio.py