Skip to main content
Glama
jaejin0me

TypeScript MCP Server Boilerplate

by jaejin0me

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
NameRequiredDescriptionDefault
formatNoTime format (optional, defaults to full)
timezoneNoTimezone (optional, defaults to Asia/Seoul)

Implementation Reference

  • 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 : '알 수 없는 오류'}` }] } } })
  • 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'],

Other Tools

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/jaejin0me/mcpServer_test'

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