Skip to main content
Glama
batteryshark

DateTime MCP Server

by batteryshark

get_current_date

Retrieve the current date in ISO format (YYYY-MM-DD) with optional weekday display for accurate date referencing in applications.

Instructions

Get the current date in ISO format (YYYY-MM-DD).

Args: include_weekday: Whether to append the day of the week

Returns: ISO date string, optionally with weekday

Examples: get_current_date() -> "2024-01-15" get_current_date(include_weekday=True) -> "2024-01-15 (Monday)"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_weekdayNo

Implementation Reference

  • server.py:67-96 (handler)
    The main handler function for the 'get_current_date' tool, decorated with @mcp.tool for registration. It loads timezone config, gets current date in that timezone, optionally appends weekday, and returns as ToolResult with text content.
    def get_current_date(include_weekday: bool = False, ctx: Context = None) -> ToolResult:
        """
        Get the current date in ISO format (YYYY-MM-DD).
        
        Args:
            include_weekday: Whether to append the day of the week
            
        Returns:
            ISO date string, optionally with weekday
            
        Examples:
            get_current_date() -> "2024-01-15"
            get_current_date(include_weekday=True) -> "2024-01-15 (Monday)"
        """
        tz_string, _ = load_config(ctx)
        timezone = get_timezone(tz_string)
        
        # Get current date in the specified timezone
        now = datetime.now(timezone)
        date_str = now.strftime("%Y-%m-%d")
        
        if include_weekday:
            weekday = now.strftime("%A")
            result_text = f"{date_str} ({weekday})"
        else:
            result_text = date_str
        
        # Return raw text without JSON wrapping - more efficient per policy
        return ToolResult(content=[TextContent(type="text", text=result_text)])
  • Helper function to load timezone and time format configuration from context headers or environment variables, used by get_current_date.
    def load_config(context: Optional[Context] = None) -> tuple[str, str]:
        """
        Load timezone and time format configuration.
        
        For HTTP transport, configuration comes from headers.
        For stdio transport, configuration comes from environment variables.
        
        Returns:
            tuple: (timezone_string, time_format)
        """
        # Default values
        default_tz = "UTC"
        default_timefmt = "24"
        
        # Try to get from context headers first (HTTP transport)
        if context and hasattr(context, 'meta') and context.meta:
            headers = context.meta.get('headers', {})
            tz_string = headers.get('DEFAULT_TZ', headers.get('default_tz'))
            time_format = headers.get('TIMEFMT', headers.get('timefmt'))
            
            if tz_string and time_format:
                return tz_string, time_format
        
        # Fall back to environment variables (stdio transport)
        tz_string = os.getenv('DEFAULT_TZ', default_tz)
        time_format = os.getenv('TIMEFMT', default_timefmt)
        
        return tz_string, time_format
  • Helper function to resolve timezone string to ZoneInfo object with fallback to UTC, used by get_current_date.
    def get_timezone(tz_string: str) -> ZoneInfo:
        """
        Convert timezone string to ZoneInfo object.
        
        Args:
            tz_string: Timezone identifier (e.g., "America/New_York", "UTC")
            
        Returns:
            ZoneInfo object, defaults to UTC if invalid timezone
        """
        try:
            return ZoneInfo(tz_string)
        except Exception:
            # Graceful fallback to UTC for invalid timezones
            return ZoneInfo("UTC")
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's behavior: it returns the current date in a specific format, optionally with the weekday appended. However, it lacks details on potential limitations like timezone handling or system dependencies.

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

Conciseness5/5

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

The description is well-structured with clear sections (description, args, returns, examples), front-loaded key information, and no redundant sentences. Each part adds value, making it efficient and easy to parse.

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 (1 parameter, no output schema, no annotations), the description is nearly complete. It covers purpose, parameters, and return values with examples. A minor gap is the lack of explicit error handling or timezone context, but overall it provides sufficient information for effective use.

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 input schema has 0% description coverage, so the description must fully compensate. It clearly explains the single parameter 'include_weekday' and its effect on the output, including examples that illustrate the semantics beyond the schema's boolean type.

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 explicitly states the tool's purpose with a specific verb ('Get') and resource ('current date'), including the output format ('ISO format (YYYY-MM-DD)'). It clearly distinguishes from the sibling tool 'get_current_time' by focusing on date rather than time.

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 examples showing when to include the weekday parameter, but it does not explicitly state when to use this tool versus alternatives like 'get_current_time' or other date-related tools. No guidance on exclusions or prerequisites is provided.

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/batteryshark/mcp-datetime'

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