"""laptop MCP Server"""

import logging
import platform
import uvicorn
import os
import sys
from datetime import datetime
from fastmcp import FastMCP
from mcp_helpers import add_code_updater

# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

mcp = FastMCP("8125_mcp_laptop")
add_code_updater(mcp, __file__)

# Przykładowa metoda
@mcp.tool()
def hello() -> str:
    """Prosta metoda testowa"""
    return "Hello from MCP server"

@mcp.tool()
def getSystemInfo() -> str:
    """Zwraca podstawowe informacje o systemie"""
    os_name = platform.system()
    os_version = platform.release()
    arch = platform.machine()
    py_version = platform.python_version()

    return f"Serwer działa na systemie {os_name} w wersji {os_version}. Architektura: {arch}. Używana wersja Pythona: {py_version}."

@mcp.tool()
def gettime() -> str:
    """Zwraca aktualny czas serwera"""
    now = datetime.now()
    return f"Aktualny czas serwera: {now.strftime('%Y-%m-%d %H:%M:%S')}"

if __name__ == "__main__":
    port = int(os.environ.get("MCP_PORT", 18125))
    print(f"-------------- claude mcp add --transport http 8125_mcp_laptop http://localhost:{port}/mcp/", flush=True)
    uvicorn.run(mcp.http_app(transport="streamable-http"), host="localhost", port=port)
