listTimezones
Retrieve all IANA timezones with optional region filtering to support global time management and scheduling applications.
Instructions
List all available IANA timezones
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | No | Filter timezones by region (e.g., America, Europe) |
Implementation Reference
- src/tools/datetime.ts:112-132 (handler)The handler function for the 'listTimezones' tool. Retrieves all IANA timezones using Intl.supportedValuesOf('timeZone'), optionally filters by region prefix, and returns them as JSON (note: currently serializes unfiltered zones).handler: async ({ region }: { region?: string }) => { try { // Get list of unique timezone names from Luxon const zones = Array.from(new Set( Intl.supportedValuesOf('timeZone') )); const filteredZones = region ? zones.filter((zone: string) => zone.startsWith(region)) : zones; return { content: [{ type: 'text', text: JSON.stringify(zones, null, 2) }] }; } catch (error) { throw new Error(`Failed to list timezones: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
- src/tools/datetime.ts:102-111 (schema)Input schema definition for the 'listTimezones' tool, specifying an optional 'region' string parameter for filtering.inputSchema: { type: 'object', properties: { region: { type: 'string', description: 'Filter timezones by region (e.g., America, Europe)', optional: true } } },
- src/tools/datetime.ts:99-133 (registration)The complete tool definition object for 'listTimezones' within the dateTimeTools export, including name, description, inputSchema, and handler. This object is imported and spread into the main allTools registry in src/index.ts.listTimezones: { name: 'listTimezones', description: 'List all available IANA timezones', inputSchema: { type: 'object', properties: { region: { type: 'string', description: 'Filter timezones by region (e.g., America, Europe)', optional: true } } }, handler: async ({ region }: { region?: string }) => { try { // Get list of unique timezone names from Luxon const zones = Array.from(new Set( Intl.supportedValuesOf('timeZone') )); const filteredZones = region ? zones.filter((zone: string) => zone.startsWith(region)) : zones; return { content: [{ type: 'text', text: JSON.stringify(zones, null, 2) }] }; } catch (error) { throw new Error(`Failed to list timezones: ${error instanceof Error ? error.message : 'Unknown error'}`); } } }
- src/index.ts:28-35 (registration)Registration of all tools by spreading individual toolkits (including dateTimeTools containing listTimezones) into the central allTools object used by MCP request handlers for tool listing and execution.const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };