Skip to main content
Glama
ainarsklavins

Date MCP Server

Get Current Date and Time

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
          };
        }
      }
    );
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns current datetime and mentions an optional timezone, but does not specify return format (e.g., ISO string), whether it's read-only (implied by 'Returns'), or any rate limits or error conditions. It adds basic context but lacks detailed behavioral traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences with zero waste: the first states the core purpose, and the second adds the optional parameter. It is appropriately sized and front-loaded, making it easy for an agent to quickly understand the tool's function without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one optional parameter, no output schema, no annotations), the description is mostly complete. It covers the purpose and parameter, but lacks details on return format or behavioral aspects like error handling. For a simple tool, this is adequate but could be slightly enhanced with output information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the timezone parameter with IANA format examples. The description adds minimal value by mentioning 'Optionally specify a timezone' but does not provide additional syntax, format details, or constraints beyond what the schema provides. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Returns') and resource ('current date and time'), distinguishing it from siblings like format-date (which transforms dates) and get-timezone-info (which provides timezone details). It precisely communicates what the tool does without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by mentioning the optional timezone parameter, implying usage when current datetime is needed. However, it does not explicitly state when to use this tool versus alternatives like get-timezone-info or format-date, nor does it provide exclusions or prerequisites for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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