Skip to main content
Glama
ainarsklavins

Date MCP Server

Get Timezone Information

get-timezone-info

Retrieve timezone details including current or specified IANA timezone information for accurate temporal data handling.

Instructions

Returns information about the current or specified timezone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneNoIANA timezone name (e.g., "America/New_York")

Implementation Reference

  • The asynchronous handler function implementing the core logic for the 'get-timezone-info' tool. It retrieves timezone offset, abbreviation, and current time using Intl.DateTimeFormat API, with error handling for invalid timezones.
      async ({ timezone }) => {
        const tz = timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
        const now = new Date();
    
        try {
          const longFormatter = new Intl.DateTimeFormat('en-US', {
            timeZone: tz,
            timeZoneName: 'longOffset'
          });
          const shortFormatter = new Intl.DateTimeFormat('en-US', {
            timeZone: tz,
            timeZoneName: 'short'
          });
    
          const longParts = longFormatter.formatToParts(now);
          const shortParts = shortFormatter.formatToParts(now);
    
          const offset = longParts.find(p => p.type === 'timeZoneName')?.value || 'Unknown';
          const abbreviation = shortParts.find(p => p.type === 'timeZoneName')?.value || 'Unknown';
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                timezone: tz,
                offset,
                abbreviation,
                currentTime: now.toLocaleString('en-US', { timeZone: tz })
              }, null, 2)
            }]
          };
        } catch {
          return {
            content: [{ type: 'text', text: `Error: Invalid timezone "${timezone}". Use IANA format.` }],
            isError: true
          };
        }
      }
    );
  • The input schema definition for the tool, using Zod for validation. Defines an optional 'timezone' parameter.
    {
      title: 'Get Timezone Information',
      description: 'Returns information about the current or specified timezone.',
      inputSchema: {
        timezone: z.string().optional().describe('IANA timezone name (e.g., "America/New_York")')
      }
    },
  • src/index.ts:88-136 (registration)
    The registration of the 'get-timezone-info' tool using server.registerTool, including name, schema, and handler.
    server.registerTool(
      'get-timezone-info',
      {
        title: 'Get Timezone Information',
        description: 'Returns information about the current or specified timezone.',
        inputSchema: {
          timezone: z.string().optional().describe('IANA timezone name (e.g., "America/New_York")')
        }
      },
      async ({ timezone }) => {
        const tz = timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
        const now = new Date();
    
        try {
          const longFormatter = new Intl.DateTimeFormat('en-US', {
            timeZone: tz,
            timeZoneName: 'longOffset'
          });
          const shortFormatter = new Intl.DateTimeFormat('en-US', {
            timeZone: tz,
            timeZoneName: 'short'
          });
    
          const longParts = longFormatter.formatToParts(now);
          const shortParts = shortFormatter.formatToParts(now);
    
          const offset = longParts.find(p => p.type === 'timeZoneName')?.value || 'Unknown';
          const abbreviation = shortParts.find(p => p.type === 'timeZoneName')?.value || 'Unknown';
    
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                timezone: tz,
                offset,
                abbreviation,
                currentTime: now.toLocaleString('en-US', { timeZone: tz })
              }, null, 2)
            }]
          };
        } catch {
          return {
            content: [{ type: 'text', text: `Error: Invalid timezone "${timezone}". Use IANA format.` }],
            isError: true
          };
        }
      }
    );
Behavior2/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 information, implying a read-only operation, but doesn't detail aspects like error handling (e.g., for invalid timezone names), response format, or any constraints (e.g., rate limits). This leaves significant gaps in understanding how the tool behaves beyond its basic purpose.

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 a single, clear sentence that efficiently conveys the core functionality without unnecessary words. It's front-loaded with the main action and resource, making it easy to parse and understand quickly.

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

Completeness3/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 annotations, no output schema), the description is adequate as a starting point but incomplete. It lacks details on return values, error cases, and behavioral traits, which are important for an agent to use the tool effectively, especially without annotations to fill in gaps.

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?

The input schema has 100% description coverage, fully documenting the single optional parameter 'timezone' with its IANA format. The description adds minimal value by implying the parameter is optional ('current or specified'), but doesn't provide additional semantics beyond what the schema already covers, meeting the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb ('Returns') and resource ('information about the current or specified timezone'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get-current-datetime' or 'format-date', which might also involve timezone handling, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides minimal guidance by mentioning 'current or specified timezone,' but it doesn't specify when to use this tool versus alternatives like 'get-current-datetime' or 'format-date.' There's no explicit advice on use cases or exclusions, leaving the agent to infer usage from context.

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