Skip to main content
Glama
danfmaia

Utility MCP Server

by danfmaia

get_current_datetime

Retrieve the current date and time in your preferred timezone and format, including ISO, readable, timestamp, or custom options.

Instructions

Get the current date and time in the specified timezone and format. Args: timezone_name: Timezone name (e.g., "UTC", "US/Eastern", "Europe/London", "America/Sao_Paulo") format_type: Format type ("iso", "readable", "timestamp", "custom") Returns: Current datetime in the requested format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezone_nameNoUTC
format_typeNoiso

Implementation Reference

  • The core handler function for the 'get_current_datetime' MCP tool. It is decorated with @mcp.tool(), which registers the tool with the FastMCP server and automatically generates the input/output schema from the type hints and docstring. The function fetches the current datetime in the specified timezone and formats it as requested.
    async def get_current_datetime(timezone_name: str = "UTC", format_type: str = "iso") -> str: """ Get the current date and time in the specified timezone and format. Args: timezone_name: Timezone name (e.g., "UTC", "US/Eastern", "Europe/London", "America/Sao_Paulo") format_type: Format type ("iso", "readable", "timestamp", "custom") Returns: Current datetime in the requested format """ try: # Get current UTC time now_utc = datetime.now(timezone.utc) # Convert to requested timezone if timezone_name.upper() == "UTC": target_time = now_utc else: try: tz = pytz.timezone(timezone_name) target_time = now_utc.astimezone(tz) except pytz.UnknownTimeZoneError: return f"❌ Unknown timezone: {timezone_name}\nπŸ’‘ Try: UTC, US/Eastern, Europe/London, America/Sao_Paulo, etc." # Format the datetime if format_type.lower() == "iso": formatted_time = target_time.isoformat() elif format_type.lower() == "readable": formatted_time = target_time.strftime( "%A, %B %d, %Y at %I:%M:%S %p %Z") elif format_type.lower() == "timestamp": formatted_time = str(int(target_time.timestamp())) else: # custom or other formatted_time = target_time.strftime("%Y-%m-%d %H:%M:%S %Z") result = f"πŸ• **Current DateTime**\n" result += f"**Timezone:** {timezone_name}\n" result += f"**Format:** {format_type}\n" result += f"**DateTime:** {formatted_time}\n" result += f"**UTC Offset:** {target_time.strftime('%z')}\n" return result except Exception as e: return f"❌ Error getting current datetime: {str(e)}"
  • util_server.py:121-121 (registration)
    The @mcp.tool() decorator registers the get_current_datetime function as an MCP tool on the FastMCP server instance 'mcp'.
    async def get_current_datetime(timezone_name: str = "UTC", format_type: str = "iso") -> str:
  • The docstring provides the description used by FastMCP to generate the tool's JSON schema, along with type hints in the function signature (timezone_name: str = "UTC", format_type: str = "iso") -> str.
    """ Get the current date and time in the specified timezone and format. Args: timezone_name: Timezone name (e.g., "UTC", "US/Eastern", "Europe/London", "America/Sao_Paulo") format_type: Format type ("iso", "readable", "timestamp", "custom") Returns: Current datetime in the requested format """

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/danfmaia/util-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server