Skip to main content
Glama
DSado88

DateTime MCP Server

by DSado88

get_current_datetime

Retrieve the current date and time in various formats including ISO 8601, Unix timestamp, or human-readable output, with optional timezone specification.

Instructions

Get the current date and time

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format: 'iso' (ISO 8601), 'unix' (timestamp), 'human' (readable), or a custom format stringiso
timezoneNoTimezone (e.g., 'UTC', 'America/New_York'). Defaults to system timezonesystem

Implementation Reference

  • The switch case that implements the core logic for the 'get_current_datetime' tool, handling different output formats and returning the formatted current datetime.
    case "get_current_datetime": {
      const format = request.params.arguments?.format || "iso";
      const timezone = request.params.arguments?.timezone || "system";
      
      let result: string;
      
      if (format === "iso") {
        result = now.toISOString();
      } else if (format === "unix") {
        result = Math.floor(now.getTime() / 1000).toString();
      } else if (format === "human") {
        result = now.toString();
      } else {
        result = formatDate(now, format as string);
      }
      
      return {
        content: [{
          type: "text",
          text: result
        }]
      };
    }
  • src/index.ts:25-43 (registration)
    Registration of the 'get_current_datetime' tool in the ListTools response, including its name, description, and input schema definition.
    {
      name: "get_current_datetime",
      description: "Get the current date and time",
      inputSchema: {
        type: "object",
        properties: {
          format: {
            type: "string",
            description: "Output format: 'iso' (ISO 8601), 'unix' (timestamp), 'human' (readable), or a custom format string",
            default: "iso"
          },
          timezone: {
            type: "string",
            description: "Timezone (e.g., 'UTC', 'America/New_York'). Defaults to system timezone",
            default: "system"
          }
        }
      }
    },
  • Helper utility function for custom date and time formatting, used by the get_current_datetime handler and others.
    function formatDate(date: Date, format: string): string {
      const replacements: { [key: string]: string } = {
        'YYYY': date.getFullYear().toString(),
        'MM': (date.getMonth() + 1).toString().padStart(2, '0'),
        'DD': date.getDate().toString().padStart(2, '0'),
        'HH': date.getHours().toString().padStart(2, '0'),
        'mm': date.getMinutes().toString().padStart(2, '0'),
        'ss': date.getSeconds().toString().padStart(2, '0'),
      };
      
      let result = format;
      for (const [key, value] of Object.entries(replacements)) {
        result = result.replace(new RegExp(key, 'g'), value);
      }
      
      return result;
    }
  • The input schema definition for the 'get_current_datetime' tool, specifying parameters for format and timezone.
      inputSchema: {
        type: "object",
        properties: {
          format: {
            type: "string",
            description: "Output format: 'iso' (ISO 8601), 'unix' (timestamp), 'human' (readable), or a custom format string",
            default: "iso"
          },
          timezone: {
            type: "string",
            description: "Timezone (e.g., 'UTC', 'America/New_York'). Defaults to system timezone",
            default: "system"
          }
        }
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'Get[s] the current date and time,' which implies a read-only operation, but doesn't clarify aspects like whether it requires permissions, has rate limits, or what the output format might be. For a tool with no annotations, this leaves significant gaps in understanding its behavior beyond the basic action.

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 'Get the current date and time' is a single, efficient sentence that front-loads the core purpose without any wasted words. It's appropriately sized for a simple tool, making it easy for an agent to parse and understand 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?

Given the tool's low complexity (2 optional parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on output format or behavioral traits. Without an output schema, the description doesn't explain return values, which could be a gap, but for this simple tool, it's borderline acceptable, scoring at the minimum viable level.

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 input schema has 100% description coverage, detailing both parameters ('format' and 'timezone') with clear descriptions and defaults. The tool description adds no parameter-specific information beyond what's in the schema, so it doesn't enhance semantic understanding. According to the rules, with high schema coverage (>80%), the baseline score is 3, which is appropriate here.

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 'Get the current date and time' clearly states the tool's function with a specific verb ('Get') and resource ('current date and time'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_current_date' and 'get_current_time', which likely provide more specific outputs, so it doesn't reach the highest score.

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 its siblings ('get_current_date' and 'get_current_time'), nor does it mention any prerequisites or exclusions. It's a basic statement of function without contextual usage advice, leaving the agent to infer when this general tool is preferred over more specific alternatives.

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

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