get_time_info
Retrieve current time details including timezone, day of week, and date information for accurate temporal responses to user queries.
Instructions
Get detailed time information including timezone, day of week, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No | Timezone (optional, defaults to system timezone) | system |
Implementation Reference
- src/index.ts:157-208 (handler)Handler function that executes the 'get_time_info' tool logic, computing detailed time information including timestamp, local time, date components, and timezone handling.if (name === 'get_time_info') { const timezone = args?.timezone || 'system'; log('INFO', `Getting detailed time info - timezone: ${timezone}`); const now = new Date(); let timeInfo: any = { timestamp: now.getTime(), iso_string: now.toISOString(), local_time: now.toLocaleString(), day_of_week: now.toLocaleDateString('en-US', { weekday: 'long' }), date: now.toLocaleDateString('en-US'), year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), timezone_offset: now.getTimezoneOffset(), }; if (timezone !== 'system') { try { const tzFormatter = new Intl.DateTimeFormat('en-US', { timeZone: timezone as string, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', timeZoneName: 'short' }); timeInfo.timezone_time = tzFormatter.format(now); timeInfo.requested_timezone = timezone; } catch (error) { timeInfo.timezone_error = `Invalid timezone: ${timezone}`; } } const result = { content: [ { type: 'text', text: JSON.stringify(timeInfo, null, 2), }, ], }; log('INFO', 'Returning detailed time info'); return result; }
- src/index.ts:83-97 (registration)Registration of the 'get_time_info' tool in the ListToolsRequestSchema response, including name, description, and input schema.{ name: 'get_time_info', description: 'Get detailed time information including timezone, day of week, etc.', inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: 'Timezone (optional, defaults to system timezone)', default: 'system' } }, additionalProperties: false, }, }
- src/index.ts:86-96 (schema)Input schema for the 'get_time_info' tool defining the optional timezone parameter.inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: 'Timezone (optional, defaults to system timezone)', default: 'system' } }, additionalProperties: false, },