Skip to main content
Glama
TakanariShimbo

DateTime MCP Server

get_current_time

Retrieve the current date and time in multiple formats like ISO, Unix, or human-readable, with timezone support for accurate timestamping.

Instructions

Get the current date and time in various formats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format for the datetime (optional, defaults to "iso" from env)
timezoneNoTimezone to use (optional, defaults to "UTC" from env)

Implementation Reference

  • Executes the get_current_time tool: parses format and timezone arguments (falling back to environment variables), gets current date, formats it using formatDateTime helper, and returns the result as text content or an error message.
    if (name === "get_current_time") {
      const format = (args as any)?.format || DATETIME_FORMAT;
      const timezone = (args as any)?.timezone || TIMEZONE;
      const now = new Date();
    
      try {
        const formattedDate = formatDateTime(now, format, timezone);
        return {
          content: [
            {
              type: "text",
              text: formattedDate,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error formatting date: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema definition for the get_current_time tool, specifying optional format (enum of supported formats) and timezone parameters with descriptions referencing environment defaults.
    inputSchema: {
      type: "object",
      properties: {
        format: {
          type: "string",
          enum: ["iso", "unix", "unix_ms", "human", "date", "time", "custom"],
          description: `Output format for the datetime (optional, defaults to "${DATETIME_FORMAT}" from env)`,
        },
        timezone: {
          type: "string",
          description: `Timezone to use (optional, defaults to "${TIMEZONE}" from env)`,
        },
      },
    },
  • src/index.ts:114-131 (registration)
    Defines the Tool object for get_current_time, including name, description, and schema, which is used for registration.
    const GET_CURRENT_TIME_TOOL: Tool = {
      name: "get_current_time",
      description: "Get the current date and time in various formats",
      inputSchema: {
        type: "object",
        properties: {
          format: {
            type: "string",
            enum: ["iso", "unix", "unix_ms", "human", "date", "time", "custom"],
            description: `Output format for the datetime (optional, defaults to "${DATETIME_FORMAT}" from env)`,
          },
          timezone: {
            type: "string",
            description: `Timezone to use (optional, defaults to "${TIMEZONE}" from env)`,
          },
        },
      },
    };
  • src/index.ts:319-321 (registration)
    Registers the get_current_time tool by including it in the ListTools response.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [GET_CURRENT_TIME_TOOL],
    }));
  • Core helper function that implements all date/time formatting logic for different formats (iso, unix, human, etc.) using Intl API and timezone support.
    function formatDateTime(date: Date, format: string, timezone: string): string {
      // Create date in the specified timezone
      const options: Intl.DateTimeFormatOptions = {
        timeZone: timezone,
      };
    
      switch (format) {
        case "iso":
          return date.toISOString();
    
        case "unix":
          return Math.floor(date.getTime() / 1000).toString();
    
        case "unix_ms":
          return date.getTime().toString();
    
        case "human":
          options.weekday = "short";
          options.year = "numeric";
          options.month = "short";
          options.day = "numeric";
          options.hour = "2-digit";
          options.minute = "2-digit";
          options.second = "2-digit";
          options.hour12 = true;
          return date.toLocaleString("en-US", options);
    
        case "date":
          options.year = "numeric";
          options.month = "2-digit";
          options.day = "2-digit";
          return date.toLocaleDateString("en-CA", options); // en-CA gives YYYY-MM-DD format
    
        case "time":
          options.hour = "2-digit";
          options.minute = "2-digit";
          options.second = "2-digit";
          options.hour12 = false;
          return date.toLocaleTimeString("en-US", options);
    
        case "custom":
          // Simple custom format implementation
          return formatCustomDate(date, DATE_FORMAT_STRING, timezone);
    
        default:
          return date.toISOString();
      }
    }
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 data in 'various formats' but doesn't specify what those formats are, whether there are rate limits, authentication requirements, or how errors are handled. This leaves significant behavioral gaps for an 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 core functionality without any wasted words. It's appropriately sized and front-loaded with the essential information.

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 (simple time retrieval with 2 optional parameters) and 100% schema coverage, the description is minimally adequate. However, with no output schema and no annotations, it should ideally provide more context about return values and behavioral constraints to be fully complete.

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 schema description coverage is 100%, so the schema already fully documents both parameters (format with enum values and timezone). The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline 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 clearly states the tool's purpose with a specific verb ('Get') and resource ('current date and time'), and mentions the key capability of providing 'various formats'. However, it doesn't distinguish from siblings since there are none, so it can't achieve the full 5-point differentiation.

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, prerequisites, or specific use cases. It simply states what the tool does without contextual usage information.

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

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