Skip to main content
Glama
bossjones

Datetime MCP Server

by bossjones

get-current-time

Retrieve the current time in ISO, readable, Unix, or RFC3339 format with optional timezone specification.

Instructions

Get the current time in various formats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatYesFormat to return the time in
timezoneNoOptional timezone (default: local system timezone)

Implementation Reference

  • Registration of the 'get-current-time' tool in the list_tools handler, including its name, description, and input schema.
    types.Tool(
        name="get-current-time",
        description="Get the current time in various formats",
        inputSchema={
            "type": "object",
            "properties": {
                "format": {
                    "type": "string",
                    "enum": ["iso", "readable", "unix", "rfc3339"],
                    "description": "Format to return the time in"
                },
                "timezone": {
                    "type": "string",
                    "description": "Optional timezone (default: local system timezone)"
                }
            },
            "required": ["format"]
        }
    ),
  • Handler execution logic for 'get-current-time' tool. Extracts format and optional timezone from arguments, computes current time (handling pytz if available), formats using format_time helper, and returns as TextContent.
    elif name == "get-current-time":
        if not arguments:
            raise ValueError("Missing arguments")
    
        time_format = arguments.get("format")
        timezone = arguments.get("timezone")
    
        if not time_format:
            raise ValueError("Missing format argument")
    
        # Handle timezone if provided, otherwise use system timezone
        if timezone:
            try:
                import pytz
                tz = pytz.timezone(timezone)
                now = datetime.datetime.now(tz)
            except ImportError:
                return [
                    types.TextContent(
                        type="text",
                        text="The pytz library is not available. Using system timezone instead."
                    ),
                    types.TextContent(
                        type="text",
                        text=format_time(datetime.datetime.now(), time_format)
                    )
                ]
            except Exception as e:
                return [
                    types.TextContent(
                        type="text",
                        text=f"Error with timezone '{timezone}': {str(e)}. Using system timezone instead."
                    ),
                    types.TextContent(
                        type="text",
                        text=format_time(datetime.datetime.now(), time_format)
                    )
                ]
        else:
            now = datetime.datetime.now()
    
        return [
            types.TextContent(
                type="text",
                text=format_time(now, time_format)
            )
        ]
  • JSON Schema for input validation of the 'get-current-time' tool, defining 'format' (required, enum) and optional 'timezone'.
    inputSchema={
        "type": "object",
        "properties": {
            "format": {
                "type": "string",
                "enum": ["iso", "readable", "unix", "rfc3339"],
                "description": "Format to return the time in"
            },
            "timezone": {
                "type": "string",
                "description": "Optional timezone (default: local system timezone)"
            }
        },
        "required": ["format"]
    }
  • Helper function to format datetime according to the specified format type: iso, readable, unix, rfc3339, or default to iso.
    def format_time(dt: datetime.datetime, format_type: str) -> str:
        """
        Format a datetime object according to the specified format.
    
        Args:
            dt (datetime.datetime): The datetime to format.
            format_type (str): The format type (iso, readable, unix, rfc3339).
    
        Returns:
            str: The formatted datetime string.
        """
        if format_type == "iso":
            return dt.isoformat()
        elif format_type == "readable":
            return dt.strftime("%Y-%m-%d %H:%M:%S")
        elif format_type == "unix":
            return str(int(dt.timestamp()))
        elif format_type == "rfc3339":
            return dt.strftime("%Y-%m-%dT%H:%M:%S%z")
        else:
            return dt.isoformat()
Behavior2/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 mentions the tool returns time 'in various formats' but doesn't specify what those formats are, whether the operation is read-only, if there are rate limits, or how errors are handled. This leaves significant behavioral aspects unclear for the agent.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a simple tool and front-loads the core functionality, making it easy for an agent to parse quickly.

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

Completeness3/5

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

For a simple tool with two parameters and no output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavioral aspects like error handling or return formats, which would help the agent use it correctly despite the absence of annotations.

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

Parameters3/5

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

The description mentions 'various formats', which aligns with the 'format' parameter's enum values in the schema. However, with 100% schema description coverage, the schema already documents both parameters thoroughly. The description adds minimal value beyond what the structured schema provides, meeting the baseline for high coverage.

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

Purpose4/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 ('Get the current time') and specifies the scope ('in various formats'), which distinguishes it from potential time-related operations. However, it doesn't explicitly differentiate from sibling tools like 'format-date', which might handle date formatting rather than current time retrieval.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'format-date'. It doesn't mention prerequisites, limitations, or scenarios where this tool is preferred, leaving the agent to infer usage from the tool name alone.

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

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