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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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
    """
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions what the tool does but lacks behavioral details such as whether it requires authentication, has rate limits, or how errors are handled (e.g., invalid timezone). The description is functional but misses key operational context for a tool with parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear opening sentence and organized sections for Args and Returns. It's appropriately sized, but the 'Returns' section is somewhat redundant given the presence of an output schema, slightly reducing efficiency without adding unique value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (2 parameters, no nested objects) and the presence of an output schema (which handles return values), the description is mostly complete. It covers purpose and parameters well, but could improve by adding more behavioral context (e.g., error handling) since annotations are absent, leaving minor gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% coverage. It explains both parameters: timezone_name with examples (e.g., 'UTC', 'US/Eastern') and format_type with options ('iso', 'readable', 'timestamp', 'custom'), clarifying their purposes and valid values, fully compensating for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verb ('Get') and resource ('current date and time'), including key aspects like timezone and format. It distinguishes itself from sibling tools (e.g., calculate_time_difference, download_meeting_data) by focusing solely on retrieving current datetime without calculations or data downloads.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through the mention of 'specified timezone and format', suggesting it's for when formatted datetime is needed. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., no comparison to calculate_time_difference for time calculations) or any exclusions, leaving usage context somewhat inferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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