Skip to main content
Glama
davidan90

MCP Node Time

by davidan90

get_current_date

Retrieve the current date with day-of-week information for any IANA timezone, optionally including time details, to ensure accurate timezone-aware date handling.

Instructions

Get the current date in a specific timezone with day of week information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneYesIANA timezone identifier (e.g., "America/New_York", "Europe/London")
includeTimeNoWhether to include time information

Implementation Reference

  • The handler implementation for the 'get_current_date' tool. It extracts parameters, validates the timezone, formats the current date with day of week information, optionally adds time details, and returns a JSON-formatted response.
    case 'get_current_date': {
      const { timezone, includeTime = false } = args as { timezone: string; includeTime?: boolean };
      TimeService.validateTimezone(timezone);
      
      const now = new Date();
      const dateInfo = {
        timezone,
        date: now.toLocaleDateString('en-US', { 
          timeZone: timezone,
          year: 'numeric',
          month: '2-digit',
          day: '2-digit'
        }),
        dayOfWeek: now.toLocaleDateString('en-US', { 
          timeZone: timezone,
          weekday: 'long'
        }),
        fullDate: now.toLocaleDateString('en-US', { 
          timeZone: timezone,
          weekday: 'long',
          year: 'numeric',
          month: 'long',
          day: 'numeric'
        }),
      };
    
      if (includeTime) {
        const timeInfo = TimeService.getCurrentTime(timezone, 'full');
        Object.assign(dateInfo, {
          time: timeInfo.datetime,
          fullDateTime: timeInfo.localizedFormat,
          isDST: timeInfo.isDST,
          utcOffset: timeInfo.utcOffset,
        });
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(dateInfo, null, 2),
          },
        ],
      };
    }
  • src/index.ts:80-98 (registration)
    The tool registration object for 'get_current_date' in the tools array used by ListToolsRequestHandler, including description and input schema.
    {
      name: 'get_current_date',
      description: 'Get the current date in a specific timezone with day of week information',
      inputSchema: {
        type: 'object',
        properties: {
          timezone: {
            type: 'string',
            description: 'IANA timezone identifier (e.g., "America/New_York", "Europe/London")',
          },
          includeTime: {
            type: 'boolean',
            description: 'Whether to include time information',
            default: false,
          },
        },
        required: ['timezone'],
      },
    },
  • Input schema definition for the 'get_current_date' tool, defining parameters for timezone and optional includeTime.
    inputSchema: {
      type: 'object',
      properties: {
        timezone: {
          type: 'string',
          description: 'IANA timezone identifier (e.g., "America/New_York", "Europe/London")',
        },
        includeTime: {
          type: 'boolean',
          description: 'Whether to include time information',
          default: false,
        },
      },
      required: ['timezone'],
    },

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