Skip to main content
Glama
ampcome-mcps

Time MCP Server

by ampcome-mcps

current_time

Retrieve the current date and time in customizable formats and timezones to enable time-aware applications and accurate timestamping.

Instructions

Get the current date and time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatYesThe format of the time, default is empty stringYYYY-MM-DD HH:mm:ss
timezoneNoThe timezone of the time, IANA timezone name, e.g. Asia/Shanghai

Implementation Reference

  • The core handler function that computes the current time in UTC and the specified (or guessed) local timezone, formatting it according to the provided format string using dayjs.
    function getCurrentTime(format: string, timezone?: string) {
      const utcTime = dayjs.utc();
      const localTimezone = timezone ?? dayjs.tz.guess();
      const localTime = dayjs().tz(localTimezone);
      return {
        utc: utcTime.format(format),
        local: localTime.format(format),
        timezone: localTimezone,
      };
    }
  • Defines the Tool metadata including name, description, and input schema for the 'current_time' tool, specifying parameters for format (with enum) and optional timezone.
    export const CURRENT_TIME: Tool = {
      name: 'current_time',
      description: 'Get the current date and time.',
      inputSchema: {
        type: 'object',
        properties: {
          format: {
            type: 'string',
            description: 'The format of the time, default is empty string',
            enum: [
              'h:mm A',
              'h:mm:ss A',
              'YYYY-MM-DD HH:mm:ss',
              'YYYY-MM-DD',
              'YYYY-MM',
              'MM/DD/YYYY',
              'MM/DD/YY',
              'YYYY/MM/DD',
              'YYYY/MM',
            ],
            default: 'YYYY-MM-DD HH:mm:ss',
          },
          timezone: {
            type: 'string',
            description: 'The timezone of the time, IANA timezone name, e.g. Asia/Shanghai',
            default: undefined,
          },
        },
        required: ['format'],
      },
    };
  • src/index.ts:30-34 (registration)
    Registers the 'current_time' tool (imported as CURRENT_TIME) in the list of available tools returned by the MCP ListTools request handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [CURRENT_TIME, RELATIVE_TIME, DAYS_IN_MONTH, GET_TIMESTAMP, CONVERT_TIME, GET_WEEK_YEAR],
      };
    });
  • The dispatch handler in the CallToolRequestSchema that validates arguments, calls getCurrentTime, and formats the MCP response for the 'current_time' tool.
    case 'current_time': {
      if (!checkCurrentTimeArgs(args)) {
        throw new Error(`Invalid arguments for tool: [${name}]`);
      }
    
      const { format, timezone } = args;
      const result = getCurrentTime(format, timezone);
      return {
        success: true,
        content: [
          {
            type: 'text',
            text: `Current UTC time is ${result.utc}, and the time in ${result.timezone} is ${result.local}.`,
          },
        ],
      };
    }
  • Type guard helper function to validate the arguments for the 'current_time' tool, checking for required 'format' string and optional 'timezone' string.
    function checkCurrentTimeArgs(args: unknown): args is { format: string, timezone?: string } {
      return (
        typeof args === 'object' &&
        args !== null &&
        'format' in args &&
        typeof args.format === 'string' &&
        ('timezone' in args ? typeof args.timezone === 'string' : true)
      );
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. While 'Get' suggests a read-only operation, it doesn't disclose behavioral traits like whether this tool requires authentication, has rate limits, returns real-time versus cached data, or handles errors. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 that directly states the tool's purpose with zero wasted words. It's appropriately sized for a simple tool and front-loaded with essential information, making it easy to parse 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 (2 parameters, no output schema, no annotations), the description is minimally adequate but incomplete. It lacks context on return values (e.g., string format), error handling, or performance considerations, which would be helpful despite the simple nature of the tool.

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%, with both parameters well-documented in the schema (format with enum values and default, timezone with IANA format). The description adds no parameter semantics beyond what the schema provides, so it meets the baseline of 3 for high schema coverage without additional value.

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 'Get the current date and time' clearly states the verb 'Get' and the resource 'current date and time', making the purpose specific and unambiguous. It distinguishes this tool from siblings like 'convert_time' or 'relative_time' by focusing on current time retrieval rather than conversion or relative calculations.

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

Usage Guidelines3/5

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

The description implies usage for obtaining current time, but provides no explicit guidance on when to use this tool versus alternatives like 'get_timestamp' or 'relative_time'. Without context on differences between these tools, users must infer based on tool names alone, which is insufficient for clear decision-making.

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/ampcome-mcps/time-mcp'

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