Skip to main content
Glama
DSado88

DateTime MCP Server

by DSado88

get_current_time

Retrieve the current time in customizable formats (24h, 12h, or custom) with optional seconds inclusion for accurate time-sensitive operations.

Instructions

Get only the current time

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format: '24h' (HH:MM:SS), '12h' (hh:MM:SS AM/PM), or custom format24h
include_secondsNoInclude seconds in the output

Implementation Reference

  • Handler for the 'get_current_time' tool that formats the current time based on the provided format ('24h', '12h', or custom using formatDate helper) and whether to include seconds.
    case "get_current_time": {
      const format = request.params.arguments?.format || "24h";
      const includeSeconds = request.params.arguments?.include_seconds !== false;
      
      let result: string;
      
      if (format === "24h") {
        const hours = now.getHours().toString().padStart(2, '0');
        const minutes = now.getMinutes().toString().padStart(2, '0');
        const seconds = now.getSeconds().toString().padStart(2, '0');
        result = includeSeconds ? `${hours}:${minutes}:${seconds}` : `${hours}:${minutes}`;
      } else if (format === "12h") {
        let hours = now.getHours();
        const ampm = hours >= 12 ? 'PM' : 'AM';
        hours = hours % 12 || 12;
        const minutes = now.getMinutes().toString().padStart(2, '0');
        const seconds = now.getSeconds().toString().padStart(2, '0');
        result = includeSeconds ? `${hours}:${minutes}:${seconds} ${ampm}` : `${hours}:${minutes} ${ampm}`;
      } else {
        result = formatDate(now, format as string);
      }
      
      return {
        content: [{
          type: "text",
          text: result
        }]
      };
    }
  • Input schema definition for the 'get_current_time' tool as provided in the ListTools response.
    {
      name: "get_current_time",
      description: "Get only the current time",
      inputSchema: {
        type: "object",
        properties: {
          format: {
            type: "string",
            description: "Output format: '24h' (HH:MM:SS), '12h' (hh:MM:SS AM/PM), or custom format",
            default: "24h"
          },
          include_seconds: {
            type: "boolean",
            description: "Include seconds in the output",
            default: true
          }
        }
      }
    }
  • Helper function used by get_current_time (and other tools) for custom date/time formatting.
    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;
    }
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. It states 'Get only the current time' but doesn't disclose behavioral traits like whether this is a read-only operation, if it requires permissions, or how it handles errors. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 with zero waste. It's front-loaded and appropriately sized for a simple tool, 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?

Given the tool's low complexity (2 optional parameters, no output schema), the description is minimally adequate. However, with no annotations and no output schema, it lacks completeness in explaining behavioral aspects or return values, leaving gaps for the agent to infer.

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, documenting both parameters (format and include_seconds) with details like default values and options. The description adds no parameter-specific information beyond what the schema provides, so it meets the baseline of 3 for high schema 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 'Get only the current time' clearly states the verb ('Get') and resource ('current time'), distinguishing it from sibling tools like get_current_date and get_current_datetime. However, it lacks specificity about what 'only' means compared to siblings, which slightly reduces clarity.

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, get_current_datetime). It implies usage for time-only retrieval but doesn't explicitly state alternatives or exclusions, leaving the agent to infer context.

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