current_time
Get the current time in any timezone. Defaults to Korean time (Asia/Seoul) when no timezone is specified.
Instructions
현재 시간을 지정된 시간대에서 조회하는 도구. 시간대를 입력하지 않으면 한국 시간대(Asia/Seoul)를 사용합니다.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No | 시간대 (예: Asia/Seoul, America/New_York, Europe/London). 입력하지 않으면 한국 시간대를 사용합니다. |
Input Schema (JSON Schema)
{
"properties": {
"timezone": {
"description": "시간대 (예: Asia/Seoul, America/New_York, Europe/London). 입력하지 않으면 한국 시간대를 사용합니다.",
"type": "string"
}
},
"required": [],
"type": "object"
}
Implementation Reference
- src/index.ts:524-550 (handler)MCP CallToolRequest handler for 'current_time': parses arguments using TimeToolSchema, calls getCurrentTime, and returns the formatted time as text content.if (request.params.name === 'current_time') { try { const { timezone } = TimeToolSchema.parse(request.params.arguments) const currentTime = getCurrentTime(timezone) const message = `현재 시간: ${currentTime}` return { content: [ { type: 'text', text: message } ] } } catch (error) { return { content: [ { type: 'text', text: `시간 조회 오류: ${error instanceof Error ? error.message : '알 수 없는 오류'}` } ], isError: true } } }
- src/index.ts:27-29 (schema)Zod schema defining the input for current_time tool: optional timezone string.const TimeToolSchema = z.object({ timezone: z.string().optional().describe('시간대 (예: Asia/Seoul, America/New_York, Europe/London). 입력하지 않으면 한국 시간대(Asia/Seoul)를 사용합니다.') })
- src/index.ts:357-370 (registration)Tool registration in ListToolsRequest handler: defines 'current_time' tool with description and inputSchema matching TimeToolSchema.{ name: 'current_time', description: '현재 시간을 지정된 시간대에서 조회하는 도구. 시간대를 입력하지 않으면 한국 시간대(Asia/Seoul)를 사용합니다.', inputSchema: { type: 'object', properties: { timezone: { type: 'string', description: '시간대 (예: Asia/Seoul, America/New_York, Europe/London). 입력하지 않으면 한국 시간대를 사용합니다.' } }, required: [] } },
- src/index.ts:77-98 (helper)Helper function that formats and returns the current time in the specified timezone using Intl.DateTimeFormat, defaults to 'Asia/Seoul'.const getCurrentTime = (timezone: string = 'Asia/Seoul'): string => { try { const now = new Date() const options: Intl.DateTimeFormatOptions = { timeZone: timezone, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false } const formatter = new Intl.DateTimeFormat('ko-KR', options) const timeString = formatter.format(now) return `${timeString} (${timezone})` } catch (error) { throw new Error(`유효하지 않은 시간대입니다: ${timezone}`) } }