get_bazi_chart
Generate a Bazi (Four Pillars) chart for Chinese fortune-telling analysis by inputting birth date, time, gender, and calendar type to receive detailed pillar, element, and deity information.
Instructions
获取八字(四柱)排盘信息,包含年月日时四柱、十神、五行、地支藏干等详细信息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | 出生日期,格式:YYYY-MM-DD | |
| time_index | Yes | 出生时辰序号(0-12) | |
| gender | Yes | ||
| calendar | No | solar | |
| is_leap_month | No | ||
| format | No | markdown | |
| language | No | zh-CN |
Implementation Reference
- mcp/tools/bazi_handlers.py:84-104 (handler)The main handler function that implements the core logic for the get_bazi_chart tool. It validates input parameters, builds birth information, retrieves the Bazi chart from the system, and formats the output.@log_performance def handle_get_bazi_chart(args: Dict[str, Any]) -> str: """工具:获取八字排盘""" # Validate parameters _validate_common_params( args, ["date", "time_index", "gender"], BAZI_CHART_PARAM_DESCRIPTIONS, date_key="date" ) with PerformanceTimer("八字排盘"): birth_info = _build_birth_info(args) language = args.get("language", "zh-CN") system = get_system("bazi") chart = system.get_chart(birth_info, language) output_format = args.get("format", "markdown") if output_format == "json": return _format_response(chart, "json") else: return _bazi_formatter.format_chart(chart, "markdown")
- mcp/tools/definitions.py:246-295 (schema)The input schema and tool definition for get_bazi_chart, specifying parameters, types, descriptions, and required fields.def get_bazi_chart_definition() -> Dict[str, Any]: """Get definition for get_bazi_chart tool""" return { "name": "get_bazi_chart", "description": "获取八字(四柱)排盘信息,包含年月日时四柱、十神、五行、地支藏干等详细信息", "annotations": { "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, }, "inputSchema": { "type": "object", "properties": { "date": { "type": "string", "description": "出生日期,格式:YYYY-MM-DD", }, "time_index": { "type": "integer", "description": "出生时辰序号(0-12)", "minimum": 0, "maximum": 12, }, "gender": { "type": "string", "enum": ["男", "女"], }, "calendar": { "type": "string", "enum": ["solar", "lunar"], "default": "solar", }, "is_leap_month": { "type": "boolean", "default": False, }, "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": ["date", "time_index", "gender"], }, }
- mcp/tools/__init__.py:37-40 (registration)Registration of the get_bazi_chart handler (and related Bazi tools) in the ToolRegistry during initialization.# Bazi tools self.register("get_bazi_chart", handle_get_bazi_chart) self.register("get_bazi_fortune", handle_get_bazi_fortune) self.register("analyze_bazi_element", handle_analyze_bazi_element)
- mcp/tools/definitions.py:413-413 (registration)Inclusion of the get_bazi_chart schema definition in the list of all tool definitions.get_bazi_chart_definition(),
- mcp/tools/__init__.py:45-46 (registration)Loading of all tool definitions, including get_bazi_chart, into the registry.# Load definitions self._definitions = get_all_tool_definitions()