Skip to main content
Glama
spyfree

Mingli MCP Server

by spyfree

get_bazi_fortune

Calculate Bazi (Four Pillars) fortune readings based on birth details to analyze destiny cycles, annual luck, and elemental influences for personal insight.

Instructions

获取八字运势信息,包含大运、流年等详情

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
birth_dateYes出生日期,格式:YYYY-MM-DD
time_indexYes出生时辰序号(0-12)
genderYes
calendarNosolar
is_leap_monthNo
query_dateNo查询运势的日期,格式:YYYY-MM-DD
formatNomarkdown
languageNozh-CN

Implementation Reference

  • The main handler function executing the tool logic: validates parameters, constructs birth information, retrieves fortune from the Bazi system, and formats the response.
    @log_performance def handle_get_bazi_fortune(args: Dict[str, Any]) -> str: """工具:获取八字运势""" # Validate parameters _validate_common_params( args, ["birth_date", "time_index", "gender"], BAZI_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("bazi") 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 _bazi_formatter.format_fortune(fortune, "markdown")
  • Defines the input schema, description, and annotations for the get_bazi_fortune tool.
    def get_bazi_fortune_definition() -> Dict[str, Any]: """Get definition for get_bazi_fortune tool""" return { "name": "get_bazi_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": ["男", "女"], }, "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"], }, }
  • Registers the get_bazi_fortune handler in the ToolRegistry alongside other Bazi tools.
    # 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)
  • Includes the get_bazi_fortune definition in the list of all tool definitions used for MCP tools/list.
    def get_all_tool_definitions() -> List[Dict[str, Any]]: """Get all tool definitions""" return [ get_ziwei_chart_definition(), get_ziwei_fortune_definition(), get_analyze_ziwei_palace_definition(), get_list_fortune_systems_definition(), get_bazi_chart_definition(), get_bazi_fortune_definition(), get_analyze_bazi_element_definition(), ]
  • Helper function used by the handler to construct standardized birth information dictionary.
    def _build_birth_info(args: Dict[str, Any], date_key: str = "date") -> Dict[str, Any]: """构建生辰信息字典""" return { "date": args[date_key], "time_index": args["time_index"], "gender": args["gender"], "calendar": args.get("calendar", "solar"), "is_leap_month": args.get("is_leap_month", False), }

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/spyfree/mingli-mcp'

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