Skip to main content
Glama
ainarsklavins

Date MCP Server

get-current-datetime

Retrieve the current date and time in your local timezone or any specified IANA timezone for accurate temporal data in applications.

Instructions

Returns the current date and time. Optionally specify a timezone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneNoIANA timezone (e.g., "America/New_York", "Europe/London", "UTC")

Implementation Reference

  • Handler function that fetches the current date/time, formats it in the specified timezone (or system default), and returns structured JSON data or error.
    async ({ timezone }) => { const now = new Date(); const tz = timezone || Intl.DateTimeFormat().resolvedOptions().timeZone; try { const formatted = now.toLocaleString('en-US', { timeZone: tz }); return { content: [{ type: 'text', text: JSON.stringify({ iso: now.toISOString(), formatted, timezone: tz, timestamp: now.getTime() }, null, 2) }] }; } catch { return { content: [{ type: 'text', text: `Error: Invalid timezone "${timezone}". Use IANA format like "America/New_York".` }], isError: true }; } }
  • Input schema defining the optional 'timezone' parameter with Zod validation and description.
    { title: 'Get Current Date and Time', description: 'Returns the current date and time. Optionally specify a timezone.', inputSchema: { timezone: z.string().optional().describe('IANA timezone (e.g., "America/New_York", "Europe/London", "UTC")') } },
  • src/index.ts:11-44 (registration)
    Full registration of the 'get-current-datetime' tool with server.registerTool, specifying name, metadata/schema, and handler function.
    server.registerTool( 'get-current-datetime', { title: 'Get Current Date and Time', description: 'Returns the current date and time. Optionally specify a timezone.', inputSchema: { timezone: z.string().optional().describe('IANA timezone (e.g., "America/New_York", "Europe/London", "UTC")') } }, async ({ timezone }) => { const now = new Date(); const tz = timezone || Intl.DateTimeFormat().resolvedOptions().timeZone; try { const formatted = now.toLocaleString('en-US', { timeZone: tz }); return { content: [{ type: 'text', text: JSON.stringify({ iso: now.toISOString(), formatted, timezone: tz, timestamp: now.getTime() }, null, 2) }] }; } catch { return { content: [{ type: 'text', text: `Error: Invalid timezone "${timezone}". Use IANA format like "America/New_York".` }], isError: true }; } } );

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/ainarsklavins/date-mcp'

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