Skip to main content
Glama
Xxx00xxX33

FinanceMCP

by Xxx00xxX33

current_timestamp

Retrieve current timestamp in China's East 8 timezone for financial data synchronization and time-sensitive analysis across markets.

Instructions

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

Input Schema

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

Implementation Reference

  • The core handler function for the 'current_timestamp' tool in the stdio MCP server. Computes current time in China timezone (UTC+8), formats it according to the 'format' parameter (datetime, date, time, timestamp, readable), and returns structured content with markdown.
    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 definition for the 'current_timestamp' tool, defining the optional 'format' parameter.
      type: "object",
      properties: {
        format: {
          type: "string",
          description: "时间格式,可选值:datetime(完整日期时间,默认)、date(仅日期)、time(仅时间)、timestamp(Unix时间戳)、readable(可读格式)"
        }
      }
    },
    async run(args?: { format?: string }) {
      try {
        // 获取当前UTC时间
        const now = new Date();
        
        // 转换为东八区时间(UTC+8)
        const chinaTime = new Date(now.getTime() + (8 * 60 * 60 * 1000));
  • src/index.ts:169-172 (registration)
    Registration of the 'current_timestamp' tool in the ListToolsRequestHandler response.
    {
      name: timestampTool.name,
      description: timestampTool.description,
      inputSchema: timestampTool.parameters
  • The core handler function for the 'current_timestamp' tool in the HTTP MCP server. Similar logic to stdio version, computes UTC+8 timestamp in specified format.
    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}` }] };
  • Registration of the 'current_timestamp' tool in the tools/list response for HTTP server.
    { name: timestampTool.name, description: timestampTool.description, inputSchema: timestampTool.parameters },
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 returns a timestamp in a specific time zone with datetime components, but lacks details on output format, error handling, rate limits, or authentication needs. For a tool with no annotations, this leaves significant gaps in understanding its behavior beyond the basic purpose.

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 core purpose without unnecessary words. It directly communicates what the tool does (get timestamp) and key context (time zone, included components), making it highly concise and well-structured for quick understanding.

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 (1 optional parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the purpose and time zone context but lacks details on output format, error cases, or usage scenarios, which could help an agent invoke it correctly in varied contexts. It meets minimum viability but has clear gaps.

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 input schema has 100% description coverage, with the 'format' parameter fully documented in the schema (including optional values like datetime, date, time, timestamp, readable). The description does not add any parameter semantics beyond what the schema provides, such as default behavior or examples, so it meets the baseline of 3 for high schema coverage.

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: '获取当前东八区(中国时区)的时间戳,包括年月日时分秒信息' (Get the current timestamp in the East 8th time zone (China time zone), including year, month, day, hour, minute, and second information). It specifies the verb ('获取' - get), resource ('时间戳' - timestamp), and scope (East 8th time zone with full datetime details), distinguishing it from siblings that handle financial data like stock_data or fund_data.

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 does not mention any prerequisites, exclusions, or related tools, leaving the agent to infer usage based on the purpose alone. For example, it does not clarify if this is for system time retrieval versus other time-related operations.

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

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