Skip to main content
Glama
dh1789

My First MCP

by dh1789

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
NameRequiredDescriptionDefault
timezoneNo시간대 (예: Asia/Seoul, America/New_York). 기본값: Asia/Seoul
formatNo출력 형식: full(전체), date(날짜만), time(시간만). 기본값: full

Implementation Reference

  • 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}`, }, ], }; }
  • 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}`, }, ], }; } );
  • 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 }; }
  • 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; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dh1789/my-first-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server