Skip to main content
Glama
guangxiangdebizi

FinanceMCP

current_timestamp

Retrieve the current timestamp in the China time zone (GMT+8), formatted as datetime, date, time, Unix timestamp, or readable text for accurate time-based financial data processing.

Instructions

获取当前东八区(中国时区)的时间戳,包括年月日时分秒信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNo时间格式,可选值:datetime(完整日期时间,默认)、date(仅日期)、time(仅时间)、timestamp(Unix时间戳)、readable(可读格式)

Implementation Reference

  • The core handler function for the 'current_timestamp' tool. It computes the current time in China timezone (UTC+8), supports formatting options (datetime, date, time, timestamp, readable), includes Chinese weekday, returns structured MCP content with markdown, and handles errors.
    async run(args?: { format?: string }) {
      try {
        // 获取当前UTC时间
        const now = new Date();
        
        // 转换为东八区时间(UTC+8)
        const chinaTime = new Date(now.getTime() + (8 * 60 * 60 * 1000));
        
        const format = args?.format || 'datetime';
        
        // 格式化时间函数
        const formatNumber = (num: number): string => num.toString().padStart(2, '0');
        
        const year = chinaTime.getUTCFullYear();
        const month = formatNumber(chinaTime.getUTCMonth() + 1);
        const day = formatNumber(chinaTime.getUTCDate());
        const hour = formatNumber(chinaTime.getUTCHours());
        const minute = formatNumber(chinaTime.getUTCMinutes());
        const second = formatNumber(chinaTime.getUTCSeconds());
        
        // 星期几
        const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
        const weekday = weekdays[chinaTime.getUTCDay()];
        
        let result: string;
        
        switch (format) {
          case 'date':
            result = `${year}-${month}-${day}`;
            break;
          case 'time':
            result = `${hour}:${minute}:${second}`;
            break;
          case 'timestamp':
            result = Math.floor(chinaTime.getTime() / 1000).toString();
            break;
          case 'readable':
            result = `${year}年${month}月${day}日 ${weekday} ${hour}时${minute}分${second}秒`;
            break;
          case 'datetime':
          default:
            result = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
            break;
        }
        
        return {
          content: [
            {
              type: "text",
              text: `## 🕐 当前东八区时间\n\n格式: ${format}\n时间: ${result}\n\n时区: 东八区 (UTC+8)\n星期: ${weekday}\n\n---\n\n*时间戳获取于: ${year}-${month}-${day} ${hour}:${minute}:${second}*`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text", 
              text: `❌ 获取时间戳时发生错误: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema for the current_timestamp tool, defining an optional 'format' parameter as string with description of supported formats.
    parameters: {
      type: "object",
      properties: {
        format: {
          type: "string",
          description: "时间格式,可选值:datetime(完整日期时间,默认)、date(仅日期)、time(仅时间)、timestamp(Unix时间戳)、readable(可读格式)"
        }
      }
  • src/index.ts:228-231 (registration)
    Registration/dispatch in the CallToolRequestSchema handler: extracts 'format' argument and calls the tool's run method.
    case "current_timestamp": {
      const format = request.params.arguments?.format ? String(request.params.arguments.format) : undefined;
      return await timestampTool.run({ format });
    }
  • Compact version of the core handler function for HTTP server, identical logic to stdio version but simplified response without error handling or full weekday in output.
    async run(args?: { format?: string }) {
      const now = new Date();
      const chinaTime = new Date(now.getTime() + (8 * 60 * 60 * 1000));
      const format = args?.format || 'datetime';
      const pad = (n: number) => n.toString().padStart(2, '0');
      const y = chinaTime.getUTCFullYear();
      const m = pad(chinaTime.getUTCMonth() + 1);
      const d = pad(chinaTime.getUTCDate());
      const hh = pad(chinaTime.getUTCHours());
      const mm = pad(chinaTime.getUTCMinutes());
      const ss = pad(chinaTime.getUTCSeconds());
      const weekdays = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
      const wd = weekdays[chinaTime.getUTCDay()];
      let result = `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
      if (format === 'date') result = `${y}-${m}-${d}`;
      if (format === 'time') result = `${hh}:${mm}:${ss}`;
      if (format === 'timestamp') result = Math.floor(chinaTime.getTime()/1000).toString();
      if (format === 'readable') result = `${y}年${m}月${d}日 ${wd} ${hh}时${mm}分${ss}秒`;
      return { content: [{ type: 'text', text: `## 🕐 当前东八区时间\n\n格式: ${format}\n时间: ${result}\n星期: ${wd}` }] };
  • Dispatch case in the HTTP /mcp POST tools/call handler for current_timestamp.
    case 'current_timestamp':
      return await timestampTool.run({ format: args?.format ? String(args.format) : undefined });
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 it mentions the timezone (East 8th/China) and what information is included, it doesn't disclose important behavioral aspects like whether this is a read-only operation, if it requires authentication, rate limits, error conditions, or what format the response takes. 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 Chinese sentence that communicates the core purpose without any wasted words. It's appropriately sized for a simple utility tool and front-loads the essential information about what the tool does and what timezone it uses.

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?

For a simple timestamp utility with one optional parameter and no output schema, the description is moderately complete. It covers the core purpose and timezone context but lacks behavioral details that would be helpful given the absence of annotations. The description doesn't need to explain return values since there's no output schema, but it could benefit from mentioning the response format or typical use cases.

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 doesn't mention the 'format' parameter at all, while the input schema has 100% description coverage with clear documentation of the format options. Since schema_description_coverage is high (>80%), the baseline is 3 even without parameter information in the description. The description adds no value beyond what the schema already provides about parameters.

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 clearly states the tool's purpose with specific verb ('获取' - get/retrieve) and resource ('当前东八区(中国时区)的时间戳' - current East 8th zone/China timezone timestamp), including what information it provides ('年月日时分秒信息' - year, month, day, hour, minute, second information). It distinguishes itself from sibling tools which appear to be financial data tools, making this a specialized utility function.

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. While the purpose is clear, there's no mention of use cases, prerequisites, or comparison to other time-related tools (though none appear in the sibling list). The agent must infer usage purely from the purpose statement.

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/guangxiangdebizi/FinanceMCP'

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