Skip to main content
Glama

get-current-date

Retrieve the current date in Shanghai timezone (UTC+8) formatted as yyyy-MM-dd for accurate relative date parsing in ticket searches.

Instructions

获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 "yyyy-MM-dd"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),提供准确的日期输入。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get-current-date' tool. It retrieves the current date in the Asia/Shanghai timezone using date-fns-tz.toZonedTime and date-fns.format, and returns it formatted as 'yyyy-MM-dd' in the MCP response format.
            try {
                const timeZone = 'Asia/Shanghai';
                const nowInShanghai = toZonedTime(new Date(), timeZone);
                const formattedDate = format(nowInShanghai, 'yyyy-MM-dd');
                return {
                    content: [{ type: 'text', text: formattedDate }],
                };
            } catch (error) {
                console.error('Error getting current date:', error);
                return {
                    content: [
                        {
                            type: 'text',
                            text: 'Error: Failed to get current date.',
                        },
                    ],
                };
            }
        }
    );
  • src/index.ts:816-840 (registration)
    Registration of the 'get-current-date' tool on the McpServer instance, including name, description, empty input schema ({}), and the handler function.
        'get-current-date',
        '获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 "yyyy-MM-dd"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),提供准确的日期输入。',
        {},
        async () => {
            try {
                const timeZone = 'Asia/Shanghai';
                const nowInShanghai = toZonedTime(new Date(), timeZone);
                const formattedDate = format(nowInShanghai, 'yyyy-MM-dd');
                return {
                    content: [{ type: 'text', text: formattedDate }],
                };
            } catch (error) {
                console.error('Error getting current date:', error);
                return {
                    content: [
                        {
                            type: 'text',
                            text: 'Error: Failed to get current date.',
                        },
                    ],
                };
            }
        }
    );
  • Empty input schema for the 'get-current-date' tool, indicating no parameters are required.
    async () => {

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/Joooook/12306-mcp'

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