Skip to main content
Glama
pshempel

MCP Time Server Node

by pshempel

convert_timezone

Convert time between timezones using IANA timezone identifiers. Specify source and target timezones with input time to get accurate conversions.

Instructions

Convert time between timezones

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeYesInput time
from_timezoneYesSource IANA timezone
to_timezoneYesTarget IANA timezone
formatNoOutput format

Implementation Reference

  • Core handler function for the 'convert_timezone' tool. Parses input time, validates timezones, computes offsets using date-fns-tz, formats original and converted times, calculates difference, and returns structured result with caching.
    export function convertTimezone(params: ConvertTimezoneParams): ConvertTimezoneResult {
      debug.timezone('convertTimezone called with: %O', params);
      const { time, from_timezone, to_timezone } = params;
    
      // Validate string lengths first
      if (typeof time === 'string') validateDateString(time, 'time');
      if (params.format) validateStringLength(params.format, LIMITS.MAX_FORMAT_LENGTH, 'format');
    
      const format = params.format ?? "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
    
      // Use withCache wrapper instead of manual cache management
      return withCache(
        `convert_${time}_${from_timezone}_${to_timezone}_${format}`,
        CacheTTL.TIMEZONE_CONVERT,
        () => {
          // Validate timezones
          validateTimezones(from_timezone, to_timezone);
    
          // Parse the input time
          const { date: utcDate, actualFromTimezone } = parseDateForConversion(time, from_timezone);
    
          try {
            // Get offsets
            const fromOffset = getTimezoneOffset(actualFromTimezone, utcDate);
            const toOffset = getTimezoneOffset(to_timezone, utcDate);
            const difference = (toOffset - fromOffset) / 1000 / 60; // in minutes
    
            // Format the times
            const original = formatOriginalTime(utcDate, time, actualFromTimezone);
    
            // Format the converted time
            const converted = formatConvertedTime(utcDate, to_timezone, params.format, format);
    
            // Get offset strings
            const fromOffsetStr = extractOffsetString(time, utcDate, actualFromTimezone);
            const toOffsetStr = extractOffsetString('', utcDate, to_timezone);
    
            const result = buildConversionResult(
              original,
              converted,
              fromOffsetStr,
              toOffsetStr,
              difference
            );
    
            debug.timezone('convertTimezone returning: %O', result);
            return result;
          } catch (error: unknown) {
            handleConversionError(error, params.format ?? format);
          }
        }
      );
    }
  • TypeScript interfaces defining the input parameters (ConvertTimezoneParams) and output structure (ConvertTimezoneResult) for the convert_timezone tool.
    export interface ConvertTimezoneParams {
      time: string;
      from_timezone: string;
      to_timezone: string;
      format?: string;
    }
    
    export interface ConvertTimezoneResult {
      original: string;
      converted: string;
      from_offset: string;
      to_offset: string;
      difference: number;
    }
  • src/index.ts:59-72 (registration)
    Tool definition in TOOL_DEFINITIONS array, including name, description, and inputSchema for MCP tools/list endpoint.
    {
      name: 'convert_timezone',
      description: 'Convert time between timezones',
      inputSchema: {
        type: 'object' as const,
        properties: {
          time: { type: 'string' as const, description: 'Input time' },
          from_timezone: { type: 'string' as const, description: 'Source IANA timezone' },
          to_timezone: { type: 'string' as const, description: 'Target IANA timezone' },
          format: { type: 'string' as const, description: 'Output format' },
        },
        required: ['time', 'from_timezone', 'to_timezone'],
      },
    },
  • src/index.ts:260-261 (registration)
    Mapping in TOOL_FUNCTIONS record that associates 'convert_timezone' tool name with the convertTimezone handler function for execution in MCP tools/call.
    convert_timezone: (params: unknown) =>
      convertTimezone(params as Parameters<typeof convertTimezone>[0]),
  • src/tools/index.ts:3-3 (registration)
    Re-export of the convertTimezone handler from its module for use in src/index.ts.
    export { convertTimezone } from './convertTimezone';
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 conversion action but doesn't mention error handling (e.g., invalid timezone inputs), performance characteristics, or what the output looks like (though no output schema exists). This leaves significant gaps in understanding how the tool behaves beyond its basic function.

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, efficient sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized for a straightforward conversion tool and is front-loaded with essential information.

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

Completeness2/5

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

Given the tool's moderate complexity (timezone conversion with 4 parameters) and no annotations or output schema, the description is incomplete. It doesn't explain error cases, input formats (e.g., time string structure), or output details, leaving the agent with insufficient context for reliable use.

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 all parameters (time, from_timezone, to_timezone, format) with descriptions like 'Source IANA timezone'. The description adds no additional meaning beyond what the schema provides, such as examples or constraints, 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 ('convert') and resource ('time between timezones'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'format_time' or 'get_current_time' which might also involve timezone handling, so it lacks sibling differentiation.

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 no guidance on when to use this tool versus alternatives like 'format_time' or 'get_current_time'. There's no mention of prerequisites, exclusions, or specific contexts where this tool is preferred over siblings, leaving the agent with minimal usage direction.

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/pshempel/mcp-time-server-node'

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