get_current_date_time_iso
Retrieve the current date and time in ISO 8601 format for standardized timestamping and timezone-aware applications.
Instructions
Get ISO 8601 time. (e.g. 2025-05-07T23:03:27+09:00)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No |
Implementation Reference
- src/index.ts:118-128 (handler)The asynchronous handler function that executes the tool logic: gets current datetime in ISO 8601 format using dayjs library, applies optional timezone via getTZ helper, and returns it as text content.async ({ timezone }) => { const currentDateTime = dayjs().tz(getTZ(timezone)).format(); return { content: [ { type: "text", text: currentDateTime, }, ], }; },
- src/index.ts:115-117 (schema)Input schema definition using Zod: optional 'timezone' string parameter.{ timezone: z.string().optional(), },
- src/index.ts:112-129 (registration)Registration of the 'get_current_date_time_iso' tool on the MCP server, specifying name, description, input schema, and handler function.server.tool( "get_current_date_time_iso", "Get ISO 8601 time. (e.g. 2025-05-07T23:03:27+09:00)", { timezone: z.string().optional(), }, async ({ timezone }) => { const currentDateTime = dayjs().tz(getTZ(timezone)).format(); return { content: [ { type: "text", text: currentDateTime, }, ], }; }, );
- src/index.ts:13-15 (helper)Helper function to determine timezone: uses provided value or guesses via dayjs.tz.guess() if omitted.const getTZ = (timezon?: string) => { return timezon || dayjs.tz.guess(); };