listTimezones
Filter and retrieve all IANA timezones by region or globally. Simplify timezone selection for applications and configurations.
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-133 (handler)Handler function for the listTimezones tool. Fetches IANA timezones using Intl.supportedValuesOf('timeZone'), filters by optional region, but currently serializes all zones (note: potential bug, uses 'zones' instead of 'filteredZones').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 for listTimezones tool, defining an optional 'region' parameter for filtering timezones.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)Definition and local registration of the listTimezones tool within the dateTimeTools export object.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:27-33 (registration)Global registration of listTimezones by spreading dateTimeTools into the allTools object, which is used by MCP server for tool discovery (list) and execution (call).const allTools: ToolKit = { ...encodingTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };