Skip to main content
Glama
odgrim

MCP DateTime

by odgrim

list-timezones

Retrieve a comprehensive list of all available timezones for accurate datetime handling and scheduling across global regions.

Instructions

List all available timezones

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list-timezones' tool, registered inline with server.tool(). It returns a text content with the formatted list of available timezones obtained from getFormattedTimezoneList().
    server.tool(
      "list-timezones",
      "List all available timezones",
      async () => {
        return {
          content: [{ 
            type: "text", 
            text: getFormattedTimezoneList()
          }]
        };
      }
    );
  • src/server.ts:73-84 (registration)
    Registration of the 'list-timezones' tool using server.tool(), including its description and handler.
    server.tool(
      "list-timezones",
      "List all available timezones",
      async () => {
        return {
          content: [{ 
            type: "text", 
            text: getFormattedTimezoneList()
          }]
        };
      }
    );
  • Helper function that formats the list of available timezones into a readable string, used by the list-timezones tool handler.
    export function getFormattedTimezoneList(prefix: string = "Available timezones"): string {
      const timezones = getAvailableTimezones();
      return `${prefix} (${timezones.length}): ${timezones.join(', ')}`;
    }
  • Core helper that retrieves all available timezones using Intl.supportedValuesOf('timeZone'), adds common ones, sorts them, with fallback to COMMON_TIMEZONES.
    export function getAvailableTimezones(): string[] {
      try {
        const timezones = new Set<string>(Intl.supportedValuesOf('timeZone'));
        
        // Ensure common timezones are always included
        COMMON_TIMEZONES.forEach(tz => timezones.add(tz));
        
        return Array.from(timezones).sort();
      } catch (error) {
        console.error("Error getting timezones from Intl API:", error);
        // Fallback to common timezones if the Intl API fails
        return COMMON_TIMEZONES;
      }
    }
  • Array of common timezones ensured to be available as fallback and for resource listing.
    export const COMMON_TIMEZONES = [
      "UTC",
      "Europe/London",
      "Europe/Paris",
      "Europe/Berlin",
      "America/New_York",
      "America/Chicago",
      "America/Denver",
      "America/Los_Angeles",
      "Asia/Tokyo",
      "Asia/Shanghai",
      "Asia/Kolkata",
      "Australia/Sydney",
      "Pacific/Auckland"
    ];

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

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