getCurrentTime
Retrieve and format the current time for any locale or time zone using Intl.DateTimeFormat.
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 async handler function for the getCurrentTime tool. It formats the current time using Intl.DateTimeFormat with provided locale and timeZone parameters.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 systemTools (containing getCurrentTime) into the allTools object used by the MCP server for tool listing and execution.const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };
- src/index.ts:5-5 (registration)Import of systemTools which includes the getCurrentTime tool definition.import { systemTools } from './tools/system.js';