Skip to main content
Glama

get_current_time

Retrieve the current time in various formats and timezones to check or display accurate time information.

Instructions

지금 몇시|현재 시간|몇시야|what time|current time|time now - Get current time

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoTime format
timezoneNoTimezone (e.g., America/New_York, Asia/Seoul)

Implementation Reference

  • The handler function that implements the core logic of the 'get_current_time' tool, handling different time formats and timezones.
    export async function getCurrentTime(args: { format?: string; timezone?: string }): Promise<ToolResult> { const { format = 'iso', timezone } = args; const now = new Date(); let timeResult: string; switch (format) { case 'iso': timeResult = now.toISOString(); break; case 'local': timeResult = now.toLocaleString(); break; case 'utc': timeResult = now.toUTCString(); break; case 'timestamp': timeResult = Math.floor(now.getTime() / 1000).toString(); break; case 'human': const options: Intl.DateTimeFormatOptions = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit', timeZone: timezone }; timeResult = now.toLocaleString('en-US', options); break; default: timeResult = now.toISOString(); } const currentTimeResult = { action: 'get_current_time', format, timezone: timezone || 'local', result: timeResult, timestamp: now.getTime(), status: 'success' }; return { content: [{ type: 'text', text: `Time: ${timeResult}\nFormat: ${format}\nTimezone: ${timezone || 'local'}\nTimestamp: ${now.getTime()}` }] }; }
  • The ToolDefinition object defining the schema, description, input parameters, and annotations for the 'get_current_time' tool.
    export const getCurrentTimeDefinition: ToolDefinition = { name: 'get_current_time', description: '지금 몇시|현재 시간|몇시야|what time|current time|time now - Get current time', inputSchema: { type: 'object', properties: { format: { type: 'string', description: 'Time format', enum: ['iso', 'local', 'utc', 'timestamp', 'human'] }, timezone: { type: 'string', description: 'Timezone (e.g., America/New_York, Asia/Seoul)' } }, required: [] }, annotations: { title: 'Get Current Time', audience: ['user', 'assistant'], readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: false } };
  • src/index.ts:90-90 (registration)
    Registration of the tool definition in the 'tools' array provided to the MCP server.
    getCurrentTimeDefinition,
  • src/index.ts:157-157 (registration)
    Registration of the handler function in the 'toolHandlers' dispatch map for dynamic tool execution.
    'get_current_time': getCurrentTime,
  • src/index.ts:28-28 (registration)
    Import statement bringing in the tool definition and handler implementation.
    import { getCurrentTimeDefinition, getCurrentTime } from './tools/time/getCurrentTime.js';

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/su-record/hi-ai'

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