time
Retrieve current date and time information with optional timezone and format settings for accurate timekeeping and scheduling applications.
Instructions
Get current date and time
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Time format (optional, defaults to full) | |
| timezone | No | Timezone (optional, defaults to Asia/Seoul) |
Implementation Reference
- src/index.ts:93-154 (handler)The handler function for the 'time' tool. It destructures timezone and format from args, uses Date and Intl APIs to format current time in Korean locale, supports formats 'full' (default), 'date', 'time', 'iso', includes timezone display, error handling, and returns MCP content.}, async (args) => { const { timezone = 'Asia/Seoul', format = 'full' } = args try { const now = new Date() let timeString: string switch (format) { case 'date': timeString = now.toLocaleDateString('ko-KR', { timeZone: timezone, year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' }) break case 'time': timeString = now.toLocaleTimeString('ko-KR', { timeZone: timezone, hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' }) break case 'iso': timeString = now.toISOString() break case 'full': default: const dateStr = now.toLocaleDateString('ko-KR', { timeZone: timezone, year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' }) const timeStr = now.toLocaleTimeString('ko-KR', { timeZone: timezone, hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' }) timeString = `${dateStr} ${timeStr} (${timezone})` break } return { content: [{ type: 'text', text: `현재 시간: ${timeString}` }] } } catch (error) { return { content: [{ type: 'text', text: `시간 조회 오류: ${error instanceof Error ? error.message : '알 수 없는 오류'}` }] } } })
- src/index.ts:91-92 (schema)Zod input schema defining optional 'timezone' (string) and 'format' (enum: full/date/time/iso) parameters for the 'time' tool.timezone: z.string().optional().describe('Timezone (optional, defaults to Asia/Seoul)'), format: z.enum(['full', 'date', 'time', 'iso']).optional().describe('Time format (optional, defaults to full)')
- src/index.ts:90-90 (registration)Registration of the 'time' tool via server.tool() with description 'Get current date and time'.server.tool('time', 'Get current date and time', {
- src/index.ts:249-249 (registration)The 'time' tool is listed in the server capabilities within the server-info resource.tools: ['greeting', 'calculator', 'time'],