getCurrentTime
Retrieve and format the current time in any locale and time zone using Intl.DateTimeFormat. Specify locale and time zone for accurate, localized time data.
Instructions
Get current time formatted with Intl.DateTimeFormat
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| locale | No | Locale for formatting (e.g., en-US) | en-US |
| timeZone | No | Time zone (e.g., America/New_York) | UTC |
Implementation Reference
- src/tools/system.ts:23-41 (handler)The handler function for the getCurrentTime tool, which formats the current time using Intl.DateTimeFormat with specified locale and timeZone.handler: async ({ locale = 'en-US', timeZone = 'UTC' }) => { const formatter = new Intl.DateTimeFormat(locale, { timeZone, year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZoneName: 'short' }); return { content: [{ type: 'text', text: formatter.format(Date.now()) }] }; }
- src/tools/system.ts:8-22 (schema)Input schema for the getCurrentTime tool, defining optional locale and timeZone parameters.inputSchema: { type: 'object', properties: { locale: { type: 'string', description: 'Locale for formatting (e.g., en-US)', default: 'en-US' }, timeZone: { type: 'string', description: 'Time zone (e.g., America/New_York)', default: 'UTC' } } },
- src/index.ts:28-35 (registration)Registration of the getCurrentTime tool by spreading systemTools into the allTools object, which is used by the MCP server's tool listing and execution handlers.const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };