Skip to main content
Glama

relative_time

Convert a specified timestamp into relative time (e.g., '2 hours ago') to add time awareness to your applications. Ideal for enhancing workflows with precise time-related functionalities.

Instructions

Get the relative time from now.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeYesThe time to get the relative time from now. Format: YYYY-MM-DD HH:mm:ss

Implementation Reference

  • Core handler function that computes the relative time from the provided time string using dayjs.fromNow().
    function getRelativeTime(time: string) {
      return dayjs(time).fromNow();
    }
  • Defines the input schema for the relative_time tool, specifying the required 'time' parameter.
    export const RELATIVE_TIME: Tool = {
      name: 'relative_time',
      description: 'Get the relative time from now.',
      inputSchema: {
        type: 'object',
        properties: {
          time: {
            type: 'string',
            description: 'The time to get the relative time from now. Format: YYYY-MM-DD HH:mm:ss',
          },
        },
        required: ['time'],
      },
    };
  • src/index.ts:30-34 (registration)
    Registers the RELATIVE_TIME tool in the list returned for tool discovery.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [CURRENT_TIME, RELATIVE_TIME, DAYS_IN_MONTH, GET_TIMESTAMP, CONVERT_TIME, GET_WEEK_YEAR],
      };
    });
  • Dispatch handler in the main tool call switch that validates args and invokes getRelativeTime.
    case 'relative_time': {
      if (!checkRelativeTimeArgs(args)) {
        throw new Error(`Invalid arguments for tool: [${name}]`);
      }
    
      const time = args.time;
      const result = getRelativeTime(time);
      return {
        success: true,
        content: [
          {
            type: 'text',
            text: result,
          },
        ],
      };
    }
  • Runtime type guard for validating relative_time tool arguments.
    function checkRelativeTimeArgs(args: unknown): args is { time: string } {
      return (
        typeof args === 'object' &&
        args !== null &&
        'time' in args &&
        typeof args.time === '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 tool 'gets' relative time, implying a read-only operation, but doesn't clarify if it's safe, has side effects, requires specific inputs beyond the schema, or how it handles errors. For a tool with no annotations, this is a significant gap in transparency.

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: 'Get the relative time from now.' It is front-loaded with the core purpose, has zero waste, and is appropriately sized for a simple tool, making it highly concise and well-structured.

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 parameter, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on behavior, usage context, or output, which could be helpful for an agent. It meets the basic requirement but has clear gaps 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%, with the parameter 'time' fully documented in the input schema. The description doesn't add any meaning beyond the schema, such as explaining the relative time calculation or output format. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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: 'Get the relative time from now.' It specifies the verb ('get') and resource ('relative time'), making it understandable. However, it doesn't explicitly differentiate from siblings like 'convert_time' or 'current_time', which could handle similar time-related tasks, 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 no guidance on when to use this tool versus alternatives. It doesn't mention any context, exclusions, or comparisons to sibling tools like 'convert_time' or 'current_time', leaving the agent to infer usage based on the name alone.

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

Related 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/yokingma/time-mcp'

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