get_ziwei_fortune
Generate Ziwei Doushu fortune readings for specific dates using birth details. This tool provides comprehensive divination analysis including major cycles, yearly, monthly, daily, and hourly fortunes based on Chinese astrology principles.
Instructions
获取紫微斗数运势信息,包含大限、流年、流月、流日、流时的运势详情
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| birth_date | Yes | 出生日期,格式:YYYY-MM-DD | |
| time_index | Yes | 出生时辰序号(0-12) | |
| gender | Yes | 性别:男 或 女 | |
| calendar | No | solar | |
| is_leap_month | No | ||
| query_date | No | 查询运势的日期,格式:YYYY-MM-DD | |
| format | No | markdown | |
| language | No | zh-CN |
Implementation Reference
- mcp/tools/ziwei_handlers.py:107-136 (handler)The handler function that implements the core logic for the get_ziwei_fortune tool: validates parameters, builds birth info, queries the ziwei system for fortune data based on optional query_date, and formats output as markdown or JSON.@log_performance def handle_get_ziwei_fortune(args: Dict[str, Any]) -> str: """工具:获取紫微斗数运势""" # Validate parameters _validate_common_params( args, ["birth_date", "time_index", "gender"], ZIWEI_FORTUNE_PARAM_DESCRIPTIONS, date_key="birth_date", ) with PerformanceTimer("紫微运势查询"): birth_info = _build_birth_info(args, date_key="birth_date") query_date_str = args.get("query_date") if query_date_str: query_date = datetime.strptime(query_date_str, "%Y-%m-%d") else: query_date = datetime.now() language = args.get("language", "zh-CN") system = get_system("ziwei") fortune = system.get_fortune(birth_info, query_date, language) output_format = args.get("format", "markdown") if output_format == "json": return _format_response(fortune, "json") else: return _ziwei_formatter.format_fortune_markdown(fortune)
- mcp/tools/definitions.py:94-148 (schema)The schema definition function that provides the input schema, description, and annotations for the get_ziwei_fortune tool.def get_ziwei_fortune_definition() -> Dict[str, Any]: """Get definition for get_ziwei_fortune tool""" return { "name": "get_ziwei_fortune", "description": "获取紫微斗数运势信息,包含大限、流年、流月、流日、流时的运势详情", "annotations": { "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, }, "inputSchema": { "type": "object", "properties": { "birth_date": { "type": "string", "description": "出生日期,格式:YYYY-MM-DD", }, "time_index": { "type": "integer", "description": "出生时辰序号(0-12)", "minimum": 0, "maximum": 12, }, "gender": { "type": "string", "enum": ["男", "女"], "description": "性别:男 或 女", }, "calendar": { "type": "string", "enum": ["solar", "lunar"], "default": "solar", }, "is_leap_month": { "type": "boolean", "default": False, }, "query_date": { "type": "string", "description": "查询运势的日期,格式:YYYY-MM-DD", }, "format": { "type": "string", "enum": ["json", "markdown"], "default": "markdown", }, "language": { "type": "string", "enum": ["zh-CN", "zh-TW", "en-US", "ja-JP", "ko-KR", "vi-VN"], "default": "zh-CN", }, }, "required": ["birth_date", "time_index", "gender"], }, }
- mcp/tools/__init__.py:34-34 (registration)The registration of the get_ziwei_fortune tool handler in the ToolRegistry.self.register("get_ziwei_fortune", handle_get_ziwei_fortune)
- mcp/tools/__init__.py:15-19 (registration)The import of the handle_get_ziwei_fortune handler function, necessary for registration.from mcp.tools.ziwei_handlers import ( handle_analyze_ziwei_palace, handle_get_ziwei_chart, handle_get_ziwei_fortune, )