Skip to main content
Glama
davidan90

MCP Node Time

by davidan90

convert_time

Convert time between different timezones using IANA identifiers. Specify source and target timezones with a time value to get accurate conversions.

Instructions

Convert time from one timezone to another

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceTimezoneYesSource IANA timezone identifier
targetTimezoneYesTarget IANA timezone identifier
timeYesTime in HH:MM or HH:MM:SS format (24-hour)
dateNoOptional date in YYYY-MM-DD format. If not provided, uses current date

Implementation Reference

  • Core handler implementing the timezone conversion logic: validates inputs, parses time/date, computes UTC adjustments, generates source/target timezone info including DST and offsets, and calculates time difference.
    static convertTime(
      sourceTimezone: string,
      targetTimezone: string,
      time: string,
      date?: string
    ): TimeConversionResult {
      this.validateTimezone(sourceTimezone);
      this.validateTimezone(targetTimezone);
      this.validateTime(time);
    
      const baseDate = date ? new Date(date) : new Date();
      const [hours, minutes, seconds = 0] = time.split(':').map(Number);
    
      const sourceDate = new Date(baseDate);
      sourceDate.setHours(hours, minutes, seconds, 0);
    
      const sourceUTC = new Date(sourceDate.toLocaleString('en-US', { timeZone: 'UTC' }));
      const sourceLocal = new Date(sourceDate.toLocaleString('en-US', { timeZone: sourceTimezone }));
      const offset = sourceUTC.getTime() - sourceLocal.getTime();
      const adjustedDate = new Date(sourceDate.getTime() + offset);
    
      const targetDate = new Date(adjustedDate.toLocaleString('en-US', { timeZone: targetTimezone }));
    
      const sourceInfo: TimezoneInfo = {
        timezone: sourceTimezone,
        datetime: sourceDate.toLocaleString('en-US', { 
          timeZone: sourceTimezone,
          year: 'numeric',
          month: '2-digit',
          day: '2-digit',
          hour: '2-digit',
          minute: '2-digit',
          second: '2-digit',
          hour12: false
        }),
        isDST: this.isDaylightSavingTime(sourceDate, sourceTimezone),
        utcOffset: this.getUTCOffset(sourceDate, sourceTimezone),
        localizedFormat: sourceDate.toLocaleString('en-US', { 
          timeZone: sourceTimezone,
          weekday: 'long',
          year: 'numeric',
          month: 'long',
          day: 'numeric',
          hour: '2-digit',
          minute: '2-digit',
          timeZoneName: 'short'
        })
      };
    
      const targetInfo: TimezoneInfo = {
        timezone: targetTimezone,
        datetime: targetDate.toLocaleString('en-US', { 
          timeZone: targetTimezone,
          year: 'numeric',
          month: '2-digit',
          day: '2-digit',
          hour: '2-digit',
          minute: '2-digit',
          second: '2-digit',
          hour12: false
        }),
        isDST: this.isDaylightSavingTime(adjustedDate, targetTimezone),
        utcOffset: this.getUTCOffset(adjustedDate, targetTimezone),
        localizedFormat: adjustedDate.toLocaleString('en-US', { 
          timeZone: targetTimezone,
          weekday: 'long',
          year: 'numeric',
          month: 'long',
          day: 'numeric',
          hour: '2-digit',
          minute: '2-digit',
          timeZoneName: 'short'
        })
      };
    
      const timeDifference = this.calculateTimeDifference(
        new Date(`2000-01-01T${time}`),
        targetDate
      );
    
      return {
        source: sourceInfo,
        target: targetInfo,
        timeDifference
      };
    }
  • src/index.ts:46-71 (registration)
    MCP tool registration defining the 'convert_time' tool name, description, and JSON input schema matching the params.
    {
      name: 'convert_time',
      description: 'Convert time from one timezone to another',
      inputSchema: {
        type: 'object',
        properties: {
          sourceTimezone: {
            type: 'string',
            description: 'Source IANA timezone identifier',
          },
          targetTimezone: {
            type: 'string',
            description: 'Target IANA timezone identifier',
          },
          time: {
            type: 'string',
            description: 'Time in HH:MM or HH:MM:SS format (24-hour)',
          },
          date: {
            type: 'string',
            description: 'Optional date in YYYY-MM-DD format. If not provided, uses current date',
          },
        },
        required: ['sourceTimezone', 'targetTimezone', 'time'],
      },
    },
  • TypeScript interface for ConvertTimeParams providing type safety for the tool parameters used in the handler.
    export interface ConvertTimeParams {
      sourceTimezone: string;
      targetTimezone: string;
      time: string;
      date?: string;
    }
  • MCP request handler switch case for 'convert_time': casts args to params, calls TimeService.convertTime, and returns JSON-formatted response.
    case 'convert_time': {
      const { sourceTimezone, targetTimezone, time, date } = (args as unknown) as ConvertTimeParams;
      const result = TimeService.convertTime(sourceTimezone, targetTimezone, time, date);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              conversion: {
                source: result.source,
                target: result.target,
                timeDifference: result.timeDifference,
              },
            }, null, 2),
          },
        ],
      };
    }
  • TypeScript interface for TimeConversionResult defining the output structure from the convertTime handler.
    export interface TimeConversionResult {
      source: TimezoneInfo;
      target: TimezoneInfo;
      timeDifference: string;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the conversion action but doesn't cover important aspects like error handling (e.g., invalid timezone identifiers), output format, or whether it's a read-only operation. For a tool with no annotations, this leaves significant gaps in understanding how it behaves.

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: 'Convert time from one timezone to another.' It is front-loaded with the core purpose, has zero wasted words, and is appropriately sized for the tool's complexity. Every part of the sentence earns its place by clearly stating the action.

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 (time conversion with multiple parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., converted time string), error conditions, or behavioral details like timezone validation. This leaves the agent with insufficient context to use the tool effectively beyond basic parameter passing.

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, clearly documenting all four parameters with their types, formats, and optionality. The description adds no additional parameter semantics beyond what the schema provides, such as examples or edge cases. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.

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 tool's purpose: 'Convert time from one timezone to another.' It specifies the verb ('convert') and resource ('time'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get_current_time' or 'get_system_timezone,' which are read-only operations rather than conversion tools.

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. It doesn't mention sibling tools or explain scenarios where conversion is needed over simply retrieving current time or timezone information. Usage is implied by the purpose but lacks explicit context or exclusions.

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

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