Skip to main content
Glama
t-shiratori

Time Tools MCP Server

get_elapsed_time

Calculate time duration between two datetime values in specified units like milliseconds, hours, or days for precise interval measurement.

Instructions

Get the difference time between two datetimes (e.g. 2025-01-01 01:01:01 and 2025-01-02 02:02:02)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromYes
toYes
unitNomillisecond

Implementation Reference

  • Handler function that calculates the elapsed time between two datetimes using dayjs.diff, with validation for valid dates.
    async ({ from, to, unit = "second" }) => {
        const fromDateTime = dayjs(from);
        const toDateTime = dayjs(to);
        if (!fromDateTime.isValid() || !toDateTime.isValid()) {
            return {
                content: [{ type: "text", text: "Invalid format" }],
                isError: true,
            };
        }
        /**
         * {@link https://day.js.org/docs/en/display/difference}
         */
        const duration = toDateTime.diff(fromDateTime, unit, true);
        return {
            content: [{ type: "text", text: String(duration) }],
        };
    },
  • Input schema using Zod for the from datetime, to datetime, and optional unit (defaults to millisecond).
    {
        from: z.string(),
        to: z.string(),
        unit: z
            .enum([
                "millisecond",
                "second",
                "minute",
                "hour",
                "day",
                "week",
                "month",
                "year",
            ])
            .optional()
            .default("millisecond"),
    },
  • src/index.ts:131-168 (registration)
    Registration of the get_elapsed_time tool using server.tool, including description, input schema, and inline handler.
    server.tool(
        "get_elapsed_time",
        "Get the difference time between two datetimes (e.g. 2025-01-01 01:01:01 and 2025-01-02 02:02:02)",
        {
            from: z.string(),
            to: z.string(),
            unit: z
                .enum([
                    "millisecond",
                    "second",
                    "minute",
                    "hour",
                    "day",
                    "week",
                    "month",
                    "year",
                ])
                .optional()
                .default("millisecond"),
        },
        async ({ from, to, unit = "second" }) => {
            const fromDateTime = dayjs(from);
            const toDateTime = dayjs(to);
            if (!fromDateTime.isValid() || !toDateTime.isValid()) {
                return {
                    content: [{ type: "text", text: "Invalid format" }],
                    isError: true,
                };
            }
            /**
             * {@link https://day.js.org/docs/en/display/difference}
             */
            const duration = toDateTime.diff(fromDateTime, unit, true);
            return {
                content: [{ type: "text", text: String(duration) }],
            };
        },
    );
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 what the tool does but doesn't describe how it behaves: no information about error handling (e.g., invalid date formats), timezone considerations, rounding behavior, or output format. The example helps but doesn't cover behavioral traits.

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 a helpful example. It's front-loaded with the core purpose and uses minimal words to convey the essential information without any wasted text.

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 (3 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on parameter usage, error handling, and output format. For a time calculation tool, more context on date-time formats and result interpretation would be helpful.

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 description mentions 'two datetimes' which maps to the 'from' and 'to' parameters, and the example shows date-time strings. However, with 0% schema description coverage, it doesn't explain the 'unit' parameter or its enum values. The description adds some meaning but doesn't fully compensate for the schema coverage gap.

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 difference time between two datetimes' with a specific example. It uses a clear verb ('Get') and resource ('difference time'), but doesn't explicitly differentiate from sibling tools like 'get_current_date_time' or 'convert_datetime_to_unix' which serve different purposes.

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 suggest scenarios where this tool is preferred over others like 'get_current_date_time' for current time or conversion tools for format changes.

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/t-shiratori/time-tools-mcp-server'

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