get_current_time
Retrieve current date and time with optional timezone specification and output format customization (full, date-only, or time-only).
Instructions
현재 날짜와 시간을 반환합니다. 시간대를 지정할 수 있습니다.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timezone | No | 시간대 (예: Asia/Seoul, America/New_York). 기본값: Asia/Seoul | |
| format | No | 출력 형식: full(전체), date(날짜만), time(시간만). 기본값: full |
Implementation Reference
- src/index.ts:94-109 (handler)Handler function that executes the get_current_time tool: gets current date, formats it using the formatTime helper with optional timezone and format parameters, and returns a text content block with the result.async ({ timezone, format }) => { const result = formatTime( new Date(), timezone || "Asia/Seoul", (format || "full") as TimeFormat ); return { content: [ { type: "text", text: `현재 시간 (${result.timezone}): ${result.formatted}`, }, ], }; }
- src/index.ts:84-93 (schema)Input schema for get_current_time tool defined using Zod: optional timezone (string) and format (enum: full/date/time).{ timezone: z .string() .optional() .describe("시간대 (예: Asia/Seoul, America/New_York). 기본값: Asia/Seoul"), format: z .enum(["full", "date", "time"]) .optional() .describe("출력 형식: full(전체), date(날짜만), time(시간만). 기본값: full"), },
- src/index.ts:81-110 (registration)Registration of the get_current_time tool using server.tool(), including description, input schema, and inline handler function.server.tool( "get_current_time", "현재 날짜와 시간을 반환합니다. 시간대를 지정할 수 있습니다.", { timezone: z .string() .optional() .describe("시간대 (예: Asia/Seoul, America/New_York). 기본값: Asia/Seoul"), format: z .enum(["full", "date", "time"]) .optional() .describe("출력 형식: full(전체), date(날짜만), time(시간만). 기본값: full"), }, async ({ timezone, format }) => { const result = formatTime( new Date(), timezone || "Asia/Seoul", (format || "full") as TimeFormat ); return { content: [ { type: "text", text: `현재 시간 (${result.timezone}): ${result.formatted}`, }, ], }; } );
- src/tools.ts:15-37 (helper)Pure helper function formatTime that performs the core time formatting logic using Intl.DateTimeFormat for Korean locale, supporting different formats and timezones. Used by the get_current_time handler.export function formatTime( date: Date, timezone: string = "Asia/Seoul", format: TimeFormat = "full" ): TimeResult { let options: Intl.DateTimeFormatOptions = { timeZone: timezone }; switch (format) { case "date": options = { ...options, dateStyle: "full" }; break; case "time": options = { ...options, timeStyle: "long" }; break; case "full": default: options = { ...options, dateStyle: "full", timeStyle: "long" }; break; } const formatted = date.toLocaleString("ko-KR", options); return { formatted, timezone }; }
- src/tools.ts:8-13 (schema)TypeScript type definitions for TimeFormat enum and TimeResult interface used in get_current_time implementation.export type TimeFormat = "full" | "date" | "time"; export interface TimeResult { formatted: string; timezone: string; }