get_current_time
Retrieve the current time for any specified timezone to synchronize blockchain operations with local or global time requirements.
Instructions
Get the current time in a specified timezone
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No | Timezone identifier (e.g., "UTC", "America/New_York") |
Implementation Reference
- src/index.ts:459-496 (handler)Handler for the 'get_current_time' tool: parses optional timezone argument, formats current date using toLocaleString, handles invalid timezones with error response.case 'get_current_time': { const parsed = GetTimeArgsSchema.parse(args); const timezone = parsed.timezone || 'UTC'; try { const now = new Date(); const timeString = now.toLocaleString('en-US', { timeZone: timezone, weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', timeZoneName: 'short', }); return { content: [ { type: 'text', text: `Current time in ${timezone}: ${timeString}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error: Invalid timezone "${timezone}" - ${error}`, }, ], isError: true, }; } }
- src/index.ts:29-31 (schema)Zod schema used for input validation in the get_current_time handler: optional 'timezone' string.const GetTimeArgsSchema = z.object({ timezone: z.string().optional(), });
- src/index.ts:128-141 (registration)Tool registration in TOOLS array: defines name, description, and input schema for MCP listTools response.{ name: 'get_current_time', description: 'Get the current time in a specified timezone', inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: 'Timezone identifier (e.g., "UTC", "America/New_York")', }, }, required: [], }, },
- src/index.ts:131-140 (schema)MCP protocol input schema for get_current_time tool as registered in TOOLS.inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: 'Timezone identifier (e.g., "UTC", "America/New_York")', }, }, required: [], },