Skip to main content
Glama
odgrim

MCP DateTime

by odgrim

get-current-time

Retrieve the current time in your local timezone. This tool provides datetime information for AI agents and chat interfaces.

Instructions

Get the current time in the configured local timezone

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/server.ts:19-28 (registration)
    Registration of the 'get-current-time' tool with an inline asynchronous handler function that retrieves the current timezone and formats the current time in that timezone using helper functions.
    server.tool(
      "get-current-time",
      "Get the current time in the configured local timezone",
      async () => ({
        content: [{ 
          type: "text", 
          text: `The current time is ${getCurrentTimeInTimezone(getCurrentTimezone())}`
        }]
      })
    );
  • Helper function that returns the current system timezone by querying Intl.DateTimeFormat, with fallback to 'UTC' on error. Called by the get-current-time handler.
    export function getCurrentTimezone(): string {
      try {
        const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
        return processTimezone(timezone);
      } catch (error) {
        console.error("Error getting current timezone:", error);
        return "UTC"; // Default to UTC if there's an error
      }
    }
  • Helper function that formats the current date and time in ISO8601 format for the specified timezone using Intl APIs. Called by the get-current-time handler.
    export function getCurrentTimeInTimezone(timezone: string): string {
      try {
        const date = new Date();
        
        // Create a formatter that includes the timezone
        const options: Intl.DateTimeFormatOptions = {
          timeZone: timezone,
          timeZoneName: 'short'
        };
        
        // Get the timezone offset from the formatter
        const formatter = new Intl.DateTimeFormat('en-US', options);
        const formattedDate = formatter.format(date);
        const timezonePart = formattedDate.split(' ').pop() || '';
        
        // Format the date in ISO8601 format with the timezone
        // First get the date in the specified timezone
        const tzFormatter = new Intl.DateTimeFormat('en-US', {
          timeZone: timezone,
          year: 'numeric',
          month: '2-digit',
          day: '2-digit',
          hour: '2-digit',
          minute: '2-digit',
          second: '2-digit',
          hour12: false,
          fractionalSecondDigits: 3
        });
        
        const parts = tzFormatter.formatToParts(date);
        const dateParts: Record<string, string> = {};
        
        parts.forEach(part => {
          if (part.type !== 'literal') {
            dateParts[part.type] = part.value;
          }
        });
        
        // Format as YYYY-MM-DDTHH:MM:SS.sss±HH:MM (ISO8601)
        const isoDate = `${dateParts.year}-${dateParts.month}-${dateParts.day}T${dateParts.hour}:${dateParts.minute}:${dateParts.second}.${dateParts.fractionalSecond || '000'}`;
        
        // For proper ISO8601, we need to add the timezone offset
        // We can use the Intl.DateTimeFormat to get the timezone offset
        const tzOffset = new Date().toLocaleString('en-US', { timeZone: timezone, timeZoneName: 'longOffset' }).split(' ').pop() || '';
        
        // Format the final ISO8601 string
        return `${isoDate}${tzOffset.replace('GMT', '')}`;
      } catch (error) {
        console.error(`Error formatting time for timezone ${timezone}:`, error);
        return 'Invalid timezone';
      }
    } 
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. It states the tool gets current time but doesn't disclose behavioral traits like whether it's read-only, requires permissions, has rate limits, or what the output format is. This is a significant gap for a tool with zero annotation coverage.

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 front-loads the purpose with zero waste. Every word earns its place, making it appropriately sized for this simple tool.

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 (0 parameters, no output schema), the description is minimally adequate but lacks details on behavioral aspects like output format or usage context. It doesn't fully compensate for the absence of annotations and output schema, leaving gaps in understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0 parameters and 100% schema description coverage, the baseline is 4. The description adds no parameter information, which is acceptable since there are no parameters to document.

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 action ('Get') and resource ('current time'), specifying it returns time in the configured local timezone. It distinguishes from siblings like get-time-in-timezone by focusing on local time, but doesn't explicitly contrast with get-current-timezone or list-timezones.

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?

No explicit guidance on when to use this tool versus alternatives like get-current-timezone or get-time-in-timezone. The description implies usage for local time retrieval but lacks context on exclusions or prerequisites.

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/odgrim/mcp-datetime'

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