Skip to main content
Glama

get_time

Retrieve real-time environmental time data including local time, UTC, timezone, and timestamps to provide accurate responses to time-sensitive queries and current events.

Instructions

【必须调用】获取用户环境的实时时间信息。

⚠️ 重要:你的训练数据和系统提示中的时间信息可能不准确或过时,必须调用此工具获取用户的真实当前时间。

强制调用场景(必须调用,不要依赖你的知识):

  • 用户提到"现在"、"今天"、"最近"、"这周"、"这个月"、"今年"等时间词

  • 用户询问时间相关的事件、新闻、趋势(如"最近有什么AI大事件")

  • 需要判断某个日期是过去还是未来

  • 分析时间敏感的数据(日志、事件、截止日期)

  • 任何需要知道"当前时间"才能准确回答的问题

返回信息:用户本地时间、UTC时间、时区、Unix时间戳、完整的年月日时分秒、星期等。

⚠️ 不要假设你知道当前时间,必须调用此工具!

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNo时间格式:'iso' (ISO 8601), 'locale' (本地化), 'unix' (Unix时间戳)iso

Implementation Reference

  • The getTimeInfo function implements the core logic for the 'get_time' tool, computing various time-related information based on the optional format parameter ('iso', 'locale', 'unix').
    export async function getTimeInfo(format: string = "iso") {
      const now = new Date();
      
      const timeInfo = {
        timestamp: now.getTime(),
        iso: now.toISOString(),
        locale: now.toLocaleString(),
        utc: now.toUTCString(),
        timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
        timezoneOffset: now.getTimezoneOffset(),
        year: now.getFullYear(),
        month: now.getMonth() + 1,
        day: now.getDate(),
        hour: now.getHours(),
        minute: now.getMinutes(),
        second: now.getSeconds(),
        dayOfWeek: now.toLocaleDateString('zh-CN', { weekday: 'long' }),
      };
    
      // 根据格式返回不同的结果
      if (format === "unix") {
        return {
          timestamp: timeInfo.timestamp,
          timezone: timeInfo.timezone,
        };
      } else if (format === "locale") {
        return {
          locale: timeInfo.locale,
          timezone: timeInfo.timezone,
          dayOfWeek: timeInfo.dayOfWeek,
        };
      }
    
      return timeInfo;
    }
  • src/index.ts:187-197 (registration)
    In the CallToolRequestSchema handler, the switch case for 'get_time' invokes the getTimeInfo handler and formats the result as MCP content.
    case "get_time": {
      const result = await getTimeInfo(args?.format as string);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • src/index.ts:32-59 (registration)
    The 'get_time' tool registration in ListToolsRequestSchema, including name, description, and input schema.
          {
            name: "get_time",
            description: `【必须调用】获取用户环境的实时时间信息。
    
    ⚠️ 重要:你的训练数据和系统提示中的时间信息可能不准确或过时,必须调用此工具获取用户的真实当前时间。
    
    强制调用场景(必须调用,不要依赖你的知识):
    - 用户提到"现在"、"今天"、"最近"、"这周"、"这个月"、"今年"等时间词
    - 用户询问时间相关的事件、新闻、趋势(如"最近有什么AI大事件")
    - 需要判断某个日期是过去还是未来
    - 分析时间敏感的数据(日志、事件、截止日期)
    - 任何需要知道"当前时间"才能准确回答的问题
    
    返回信息:用户本地时间、UTC时间、时区、Unix时间戳、完整的年月日时分秒、星期等。
    
    ⚠️ 不要假设你知道当前时间,必须调用此工具!`,
            inputSchema: {
              type: "object",
              properties: {
                format: {
                  type: "string",
                  description: "时间格式:'iso' (ISO 8601), 'locale' (本地化), 'unix' (Unix时间戳)",
                  enum: ["iso", "locale", "unix"],
                  default: "iso",
                },
              },
            },
          },
  • Input schema definition for the 'get_time' tool, specifying the optional 'format' parameter with possible values and default.
    inputSchema: {
      type: "object",
      properties: {
        format: {
          type: "string",
          description: "时间格式:'iso' (ISO 8601), 'locale' (本地化), 'unix' (Unix时间戳)",
          enum: ["iso", "locale", "unix"],
          default: "iso",
        },
      },
    },
Behavior4/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 effectively describes the tool's behavior by stating it returns real-time information (not cached or estimated), lists the specific data returned (local time, UTC, timezone, Unix timestamp, full date/time, weekday), and emphasizes the critical constraint that the agent must call it instead of using internal knowledge. It doesn't mention error handling or rate limits, but covers the core behavioral aspects well for a read-only tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and well-structured, with clear sections (purpose, warnings, usage scenarios, return information). Every sentence adds value, such as the critical warning about inaccurate training data and the list of mandatory call scenarios. It could be slightly more concise by reducing repetition of '必须调用' (must call), but overall it's efficient and front-loaded with the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/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 optional parameter) and lack of annotations/output schema, the description is highly complete. It thoroughly explains the tool's purpose, when to use it, behavioral constraints, and what information it returns. For a simple time-fetching tool, this provides all necessary context for an agent to invoke it correctly, compensating for the absence of structured metadata.

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 single parameter 'format' fully documented in the schema (including enum values and default). The description doesn't add any parameter-specific information beyond what's in the schema, but it implicitly reinforces the tool's purpose of returning time data in various formats. Since schema coverage is high, 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.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool's purpose as '获取用户环境的实时时间信息' (get real-time time information of the user's environment), which is a specific verb+resource combination. It clearly distinguishes from sibling tools like get_hardware_info, get_location, and get_system_info by focusing exclusively on time data rather than hardware, location, or broader system information.

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

Usage Guidelines5/5

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

The description provides explicit and detailed guidance on when to use this tool, listing multiple mandatory scenarios (e.g., when users mention time-related words, ask about time-sensitive events, or need to determine past/future dates). It also explicitly states when not to use alternatives by emphasizing '必须调用此工具' (must call this tool) and warning against relying on the agent's own knowledge or training data for time information.

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/pepedd864/agent-sense'

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