Skip to main content
Glama
ctermiii

HeFeng Weather MCP Server

by ctermiii

get_datetime

Retrieve current date and time with an optional timezone parameter, defaulting to 'Asia/Shanghai'. Ideal for synchronizing timestamps in weather forecasts or applications requiring precise time data.

Instructions

获取当前的日期和时间。可以提供一个可选的时区参数,默认为 'Asia/Shanghai'。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timezoneNo可选的时区,例如 'America/New_York', 'Europe/London'。如果未提供,默认为 'Asia/Shanghai'。

Implementation Reference

  • Handler implementation for the 'get_datetime' tool. Parses input arguments using the schema, retrieves current date/time using JavaScript Date object adjusted for the specified timezone (defaults to 'Asia/Shanghai'), handles invalid timezone errors with fallback, and returns a formatted string response.
    } else if (name === "get_datetime") {
        const { timezone } = getDatetimeSchema.parse(args);
        const currentDateTime = new Date();
        let dateTimeString: string;
        const targetTimezone = timezone || 'Asia/Shanghai'; // Default to Asia/Shanghai
    
        try {
            // Use toLocaleString with options to get time in the target timezone
            dateTimeString = currentDateTime.toLocaleString('zh-CN', { timeZone: targetTimezone });
        } catch (error) {
            // Fallback to a known good default if specific timezone fails
            logger.warn(`无效的时区 "${targetTimezone}" 或格式化错误:`, error);
            const fallbackTimezone = 'Asia/Shanghai';
            dateTimeString = currentDateTime.toLocaleString('zh-CN', { timeZone: fallbackTimezone });
            dateTimeString += ` (无法识别提供的时区 "${timezone}", 已回退到 ${fallbackTimezone})`;
        }
    
        return {
            content: [{ type: "text", text: `当前日期时间 (${targetTimezone}): ${dateTimeString}` }],
        };
    }
  • Zod schema definition for the 'get_datetime' tool input: optional 'timezone' string parameter with description.
    const getDatetimeSchema = z.object({
        timezone: z.string().optional().describe("可选的时区,例如 'America/New_York', 'Europe/London'。如果未提供,默认为 'Asia/Shanghai'。"),
    });
  • src/index.ts:183-186 (registration)
    Registration of the 'get_datetime' tool within the 'tools' object, specifying its description and referencing the schema.
    get_datetime: {
        description: "获取当前的日期和时间。可以提供一个可选的时区参数(如 'America/New_York', 'Europe/London'),默认为 'Asia/Shanghai'。",
        schema: getDatetimeSchema,
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it indicates the tool retrieves current datetime (implying read-only behavior), it doesn't disclose important traits like whether this is a real-time query, potential rate limits, authentication requirements, or what format the datetime is returned in. The description is minimal beyond stating the basic function.

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 extremely concise with just two sentences that directly state the tool's function and parameter behavior. Every word earns its place with zero wasted text, and the information is front-loaded with the core purpose stated first.

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

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is inadequate for a tool that returns data. It doesn't explain what format the datetime is returned in (ISO string? timestamp? structured object?), whether it includes timezone information, or what happens on errors. For a data retrieval tool, this leaves significant gaps in understanding how to interpret results.

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?

Schema description coverage is 100%, so the schema already fully documents the single optional timezone parameter. The description adds only that the parameter is optional and defaults to 'Asia/Shanghai', which is already stated in the schema. No additional semantic context is provided beyond what's in the structured schema.

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 a specific verb ('获取' meaning 'get') and resource ('当前的日期和时间' meaning 'current date and time'). It distinguishes itself from sibling tools like get_location_id and get_weather by focusing on datetime retrieval rather than location or weather data.

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

Usage Guidelines3/5

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

The description implies usage when current datetime is needed, but provides no explicit guidance on when to use this tool versus alternatives or any prerequisites. It mentions the optional timezone parameter but doesn't specify scenarios where different timezones would be appropriate.

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/ctermiii/hefeng-mcp-server'

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