Skip to main content
Glama
ampcome-mcps

Time MCP Server

by ampcome-mcps

convert_time

Convert dates and times between different timezones using IANA timezone names. Specify source timezone, target timezone, and time in 24-hour format for accurate conversion.

Instructions

Convert time between timezones.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceTimezoneYesThe source timezone. IANA timezone name, e.g. Asia/Shanghai
targetTimezoneYesThe target timezone. IANA timezone name, e.g. Europe/London
timeYesDate and time in 24-hour format. e.g. 2025-03-23 12:30:00

Implementation Reference

  • Core function executing the timezone conversion logic using dayjs library.
    function convertTime(sourceTimezone: string, targetTimezone: string, time?: string) {
      const sourceTime = time ? dayjs(time).tz(sourceTimezone) : dayjs().tz(sourceTimezone);
      const targetTime = sourceTime.tz(targetTimezone);
      const formatString = 'YYYY-MM-DD HH:mm:ss';
      return {
        sourceTime: sourceTime.format(formatString),
        targetTime: targetTime.format(formatString),
        timeDiff: dayjs(targetTime).diff(dayjs(sourceTime), 'hours'),
      };
    }
  • Tool definition with input schema for validating arguments.
    export const CONVERT_TIME: Tool = {
      name: 'convert_time',
      description: 'Convert time between timezones.',
      inputSchema: {
        type: 'object',
        properties: {
          sourceTimezone: {
            type: 'string',
            description: 'The source timezone. IANA timezone name, e.g. Asia/Shanghai',
          },
          targetTimezone: {
            type: 'string',
            description: 'The target timezone. IANA timezone name, e.g. Europe/London',
          },
          time: {
            type: 'string',
            description: 'Date and time in 24-hour format. e.g. 2025-03-23 12:30:00',
          },
        },
        required: ['sourceTimezone', 'targetTimezone', 'time'],
      },
    };
  • src/index.ts:30-34 (registration)
    Registers the convert_time tool (via CONVERT_TIME) in the list of available tools for MCP.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [CURRENT_TIME, RELATIVE_TIME, DAYS_IN_MONTH, GET_TIMESTAMP, CONVERT_TIME, GET_WEEK_YEAR],
      };
    });
  • Dispatcher handler case for 'convert_time' tool that handles request, validates, calls core logic, and formats response.
    case 'convert_time': {
      if (!checkConvertTimeArgs(args)) {
        throw new Error(`Invalid arguments for tool: [${name}]`);
      }
      const { sourceTimezone, targetTimezone, time } = args;
      const { sourceTime, targetTime, timeDiff } = convertTime(sourceTimezone, targetTimezone, time);
      return {
        success: true,
        content: [
          {
            type: 'text',
            text: `Current time in ${sourceTimezone} is ${sourceTime}, and the time in ${targetTimezone} is ${targetTime}. The time difference is ${timeDiff} hours.`,
          },
        ],
      };
    }
  • Helper function for validating input arguments against the schema types.
    function checkConvertTimeArgs(args: unknown): args is { sourceTimezone: string, targetTimezone: string, time: string } {
      return (
        typeof args === 'object' &&
        args !== null &&
        'sourceTimezone' in args &&
        typeof args.sourceTimezone === 'string' &&
        'targetTimezone' in args &&
        typeof args.targetTimezone === 'string' &&
        'time' in args &&
        typeof args.time === 'string'
      );
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.1/5.0
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. It states the tool converts time but doesn't disclose behavioral traits such as error handling (e.g., invalid timezone inputs), format requirements beyond the schema, or whether it performs validation. This leaves gaps in understanding how the tool behaves in edge cases.

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 with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration, making it highly efficient.

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 moderate complexity (time conversion with three parameters) and no annotations or output schema, the description is minimally adequate. It states what the tool does but lacks details on behavior, usage context, or output format, leaving room for improvement in completeness.

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 schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what's in the schema, such as examples or constraints not covered. With high schema coverage, the baseline is 3, and the description doesn't compensate with extra insights.

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: converting time between timezones. It specifies the verb 'convert' and the resource 'time', making it distinct from sibling tools like current_time or relative_time. However, it doesn't explicitly differentiate from all siblings (e.g., get_timestamp might involve timezone handling), so it's not a perfect 5.

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 prerequisites, context, or exclusions, and it doesn't reference sibling tools like current_time or relative_time that might be used in similar time-related scenarios.

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