get_current_time
Retrieve current system time details for accurate Chinese Ziwei Doushu astrology chart calculations and horoscope analysis.
Instructions
获取当前系统时间,返回详细的时间信息
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_current_time"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- ziwei_mcp_server.js:99-121 (handler)The getCurrentTime function implements the core logic for the 'get_current_time' tool, retrieving the current date and time, formatting it into a structured object including year, month, day, hour, minute, second, datetime string, weekday in English and Chinese, and Unix timestamp.
function getCurrentTime() { try { const now = new Date(); const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; const result = { year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), datetime_str: now.toISOString().slice(0, 19).replace('T', ' '), weekday: now.toLocaleDateString('en-US', { weekday: 'long' }), weekday_cn: weekdays[now.getDay()], timestamp: Math.floor(now.getTime() / 1000) }; return { success: true, data: result }; } catch (error) { return { success: false, error: error.message }; } } - ziwei_mcp_server.js:292-299 (schema)The input schema for the 'get_current_time' tool, defining it as an object with no properties or required fields.
name: "get_current_time", description: "获取当前系统时间,返回详细的时间信息", inputSchema: { type: "object", properties: {}, required: [] } }, - ziwei_mcp_server.js:438-459 (registration)The registration and dispatch handler in the tools/call switch case that invokes getCurrentTime() and formats the MCP response.
case 'get_current_time': try { const result = getCurrentTime(); response = { jsonrpc: "2.0", id: request.id, result: { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], isError: false } }; } catch (error) { response = { jsonrpc: "2.0", id: request.id, result: { content: [{ type: "text", text: `获取时间错误: ${error.message}` }], isError: true } }; } break; - ziwei_mcp_server.js:292-299 (registration)Tool registration in the tools/list response, listing the 'get_current_time' tool with its name, description, and schema.
name: "get_current_time", description: "获取当前系统时间,返回详细的时间信息", inputSchema: { type: "object", properties: {}, required: [] } },