Skip to main content
Glama
davidan90

MCP Node Time

by davidan90

get_current_time

Retrieve the current date and time in any timezone with customizable formatting options to ensure accurate time information.

Instructions

Get the current date and time in a specific timezone with various formatting options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneYesIANA timezone identifier (e.g., "America/New_York", "Europe/London", "Asia/Tokyo")
formatNoOutput format: "iso" for ISO 8601, "local" for MM/DD/YYYY HH:MM:SS, "full" for human-readableiso

Implementation Reference

  • Handler for 'get_current_time' tool in the switch statement of CallToolRequestSchema, parses params, calls TimeService, formats and returns MCP response.
    case 'get_current_time': {
      const { timezone, format = 'iso' } = (args as unknown) as GetCurrentTimeParams;
      const result = TimeService.getCurrentTime(timezone, format);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              timezone: result.timezone,
              datetime: result.datetime,
              isDST: result.isDST,
              utcOffset: result.utcOffset,
              localizedFormat: result.localizedFormat,
              format: format,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:27-45 (registration)
    Registration of 'get_current_time' tool in the tools array provided to ListToolsRequestSchema.
      name: 'get_current_time',
      description: 'Get the current date and time in a specific timezone with various formatting options',
      inputSchema: {
        type: 'object',
        properties: {
          timezone: {
            type: 'string',
            description: 'IANA timezone identifier (e.g., "America/New_York", "Europe/London", "Asia/Tokyo")',
          },
          format: {
            type: 'string',
            enum: ['iso', 'local', 'full'],
            description: 'Output format: "iso" for ISO 8601, "local" for MM/DD/YYYY HH:MM:SS, "full" for human-readable',
            default: 'iso',
          },
        },
        required: ['timezone'],
      },
    },
  • TypeScript interface defining input parameters for get_current_time tool.
    export interface GetCurrentTimeParams {
      timezone: string;
      format?: 'iso' | 'local' | 'full';
    }
  • Core implementation of getCurrentTime logic in TimeService class, handles timezone validation, DST, offset, and formatting.
    static getCurrentTime(timezone: string, format: 'iso' | 'local' | 'full' = 'iso'): TimezoneInfo {
      this.validateTimezone(timezone);
    
      const now = new Date();
      
      const isDST = this.isDaylightSavingTime(now, timezone);
      const utcOffset = this.getUTCOffset(now, timezone);
    
      let datetime: string;
      let localizedFormat: string;
    
      switch (format) {
        case 'iso':
          datetime = new Date(now.toLocaleString('en-US', { timeZone: timezone })).toISOString();
          localizedFormat = datetime;
          break;
        case 'local':
          datetime = now.toLocaleString('en-US', { 
            timeZone: timezone,
            year: 'numeric',
            month: '2-digit',
            day: '2-digit',
            hour: '2-digit',
            minute: '2-digit',
            second: '2-digit',
            hour12: false
          });
          localizedFormat = datetime;
          break;
        case 'full':
          datetime = now.toLocaleString('en-US', { timeZone: timezone });
          localizedFormat = now.toLocaleString('en-US', { 
            timeZone: timezone,
            weekday: 'long',
            year: 'numeric',
            month: 'long',
            day: 'numeric',
            hour: '2-digit',
            minute: '2-digit',
            second: '2-digit',
            timeZoneName: 'long'
          });
          break;
      }
    
      return {
        timezone,
        datetime,
        isDST,
        utcOffset,
        localizedFormat
      };
    }
Behavior3/5

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

No annotations are provided, so the description carries full burden. It discloses the tool's behavior (returns current time with formatting) but lacks details on rate limits, error handling, or response structure. It adds basic context on timezone and format, but doesn't cover potential issues like invalid timezone inputs or default behavior beyond format.

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 front-loads the core purpose ('Get the current date and time') and adds key details (timezone, formatting). Every word earns its place with no redundancy or fluff, making it highly concise and well-structured.

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 no annotations and no output schema, the description is adequate for a simple read-only tool but incomplete. It covers the basic operation but lacks details on return values (e.g., format examples), error cases, or system dependencies. For a tool with 2 parameters and 100% schema coverage, it meets minimum viability but could be more comprehensive.

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?

Schema description coverage is 100%, so the schema fully documents parameters. The description adds marginal value by summarizing 'specific timezone' and 'various formatting options', but doesn't provide additional semantics beyond what the schema already specifies (e.g., IANA identifiers, enum values). Baseline 3 is appropriate as the schema does the heavy lifting.

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 verb 'Get' and resource 'current date and time', specifying timezone and formatting options. It distinguishes from siblings like 'get_current_date' (date only) and 'convert_time' (conversion), though not explicitly. However, it doesn't fully differentiate from 'get_system_timezone', which might overlap in purpose.

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 for obtaining formatted time in a timezone, but lacks explicit guidance on when to use this vs. alternatives like 'get_current_date' for date-only or 'convert_time' for time conversion. No exclusions or prerequisites are mentioned, leaving usage context inferred rather than stated.

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/davidan90/time-node-mcp'

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