Skip to main content
Glama
tinytelly

Time MCP Server

by tinytelly

get_time_info

Retrieve current time details like timezone and day of week for accurate time-related queries across different locations.

Instructions

Get detailed time information including timezone, day of week, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneNoTimezone (optional, defaults to system timezone)system

Implementation Reference

  • Handler implementation for the 'get_time_info' tool. Extracts timezone from arguments (defaults to 'system'), computes detailed time information using Date object and Intl.DateTimeFormat for specific timezones, handles errors for invalid timezones, and returns a structured text response with JSON-formatted time info.
    if (name === 'get_time_info') {
      const timezone = args?.timezone || 'system';
      log('INFO', `Getting detailed time info - timezone: ${timezone}`);
      
      const now = new Date();
    
      let timeInfo: any = {
        timestamp: now.getTime(),
        iso_string: now.toISOString(),
        local_time: now.toLocaleString(),
        day_of_week: now.toLocaleDateString('en-US', { weekday: 'long' }),
        date: now.toLocaleDateString('en-US'),
        year: now.getFullYear(),
        month: now.getMonth() + 1,
        day: now.getDate(),
        hour: now.getHours(),
        minute: now.getMinutes(),
        second: now.getSeconds(),
        timezone_offset: now.getTimezoneOffset(),
      };
    
      if (timezone !== 'system') {
        try {
          const tzFormatter = new Intl.DateTimeFormat('en-US', {
            timeZone: timezone as string,
            year: 'numeric',
            month: '2-digit',
            day: '2-digit',
            hour: '2-digit',
            minute: '2-digit',
            second: '2-digit',
            timeZoneName: 'short'
          });
          timeInfo.timezone_time = tzFormatter.format(now);
          timeInfo.requested_timezone = timezone;
        } catch (error) {
          timeInfo.timezone_error = `Invalid timezone: ${timezone}`;
        }
      }
    
      const result = {
        content: [
          {
            type: 'text',
            text: JSON.stringify(timeInfo, null, 2),
          },
        ],
      };
      
      log('INFO', 'Returning detailed time info');
      return result;
    }
  • Schema definition for the 'get_time_info' tool returned in tools/list response, including name, description, and inputSchema with optional 'timezone' string parameter.
    {
      name: 'get_time_info',
      description: 'Get detailed time information including timezone, day of week, etc.',
      inputSchema: {
        type: 'object',
        properties: {
          timezone: {
            type: 'string',
            description: 'Timezone (optional, defaults to system timezone)',
            default: 'system'
          }
        },
        additionalProperties: false,
      },
    }
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/tinytelly/mcp-time'

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