Skip to main content
Glama
ZoezoeCookie

mcp-luopan

by ZoezoeCookie

luopan_analyze

Produce a comprehensive Bazi destiny chart from birth date, time, and gender, revealing pattern, luck pillars, and personal insights.

Instructions

Produce a full destiny-chart reading for a birth moment.

IMPORTANT: Before calling, you MUST confirm with the user:

  • solar calendar date (阳历): year / month / day

  • birth hour 0-23 (时辰),if unsure warn them the reading will be less precise

  • gender: 1 for 男, 0 for 女

Output contains: session_id (used for follow-ups), sizhu (the chart), pattern (格局), report (a three-tier reading), dayun (luck pillars), highlights (notable traits), partner (气场画像), female (if gender=0), and followup_remaining (starts at 5).

When presenting to the user, translate technical terms (e.g. 十神, 格局名称) into plain language like "气场 / 画像 / 此局". The public persona is 罗盘 (fengshui compass), never expose the words 八字 / 子平.

Sessions expire in 2 hours and allow up to 5 follow-up questions via luopan_chat.

Args: year: Birth year, e.g. 1991 month: Birth month 1-12 day: Birth day 1-31 hour: Birth hour 0-23 gender: 1 = 男, 0 = 女

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes
monthYes
dayYes
hourYes
genderYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the luopan_analyze tool. It validates input parameters (year, month, day, hour, gender), calls the backend HTTP client (LuopanClient.analyze), handles errors, and returns a formatted JSON response containing the session_id, chart data, and next-step instructions.
    @mcp.tool()
    async def luopan_analyze(year: int, month: int, day: int, hour: int, gender: int) -> str:
        """Produce a full destiny-chart reading for a birth moment.
    
        IMPORTANT: Before calling, you MUST confirm with the user:
          - solar calendar date (阳历): year / month / day
          - birth hour 0-23 (时辰),if unsure warn them the reading will be less precise
          - gender: 1 for 男, 0 for 女
    
        Output contains: session_id (used for follow-ups), sizhu (the chart),
        pattern (格局), report (a three-tier reading), dayun (luck pillars),
        highlights (notable traits), partner (气场画像), female (if gender=0),
        and followup_remaining (starts at 5).
    
        When presenting to the user, translate technical terms (e.g. 十神, 格局名称)
        into plain language like "气场 / 画像 / 此局". The public persona is 罗盘
        (fengshui compass), never expose the words 八字 / 子平.
    
        Sessions expire in 2 hours and allow up to 5 follow-up questions via luopan_chat.
    
        Args:
            year: Birth year, e.g. 1991
            month: Birth month 1-12
            day: Birth day 1-31
            hour: Birth hour 0-23
            gender: 1 = 男, 0 = 女
        """
        if not (1900 <= year <= 2100):
            return _err("bad_input", f"年份 {year} 超出支持范围 1900-2100")
        if not (1 <= month <= 12):
            return _err("bad_input", f"月份 {month} 无效")
        if not (1 <= day <= 31):
            return _err("bad_input", f"日期 {day} 无效")
        if not (0 <= hour <= 23):
            return _err("bad_input", f"时辰 {hour} 无效,应为 0-23")
        if gender not in (0, 1):
            return _err("bad_input", f"性别 {gender} 无效,应为 0 (女) 或 1 (男)")
    
        try:
            data = await _client.analyze(year, month, day, hour, gender)
        except LuopanServiceError as e:
            if e.kind == "service_unreachable":
                return _err("service_unreachable", f"罗盘后端未就绪:{_config.api_base}。请先启动 uvicorn。")
            return _err(e.kind, e.detail)
        except Exception as e:  # noqa: BLE001
            logger.exception("luopan_analyze unexpected error")
            return _err("internal", str(e))
    
        if isinstance(data, dict) and data.get("session_id"):
            data.setdefault("followup_remaining", 5)
        data["_next_step"] = (
            "向用户概述 report.tier1,抛 2-3 个 highlights 作为切入点,"
            "并保存 session_id 至 memory/sessions.json。追问时调 luopan_chat。"
        )
        return _dump(data)
  • The @mcp.tool() decorator registers luopan_analyze as a tool with FastMCP on the 'luopan' server instance.
    @mcp.tool()
  • Helper function (_err) that formats error responses as JSON strings, used by the handler for validation and service errors.
    def _err(kind: str, hint: str) -> str:
        return json.dumps({"error": kind, "hint": hint}, ensure_ascii=False)
  • Helper function (_dump) that formats the final response dict as a pretty-printed JSON string, used by the handler to return results.
    def _dump(payload: dict) -> str:
        return json.dumps(payload, ensure_ascii=False, indent=2)
  • The HTTP client method (LuopanClient.analyze) that sends the birth data to the upstream backend's /api/analyze endpoint. Called by the luopan_analyze handler.
    async def analyze(self, year: int, month: int, day: int, hour: int, gender: int) -> dict[str, Any]:
        return await self._post(
            "/api/analyze",
            {"year": year, "month": month, "day": day, "hour": hour, "gender": gender},
        )
Behavior5/5

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

Despite no annotations, the description fully discloses behavioral traits: outputs, session expiration (2 hours), follow-up limit (5), and presentation instructions (translate terms, use persona).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with clear sections (title, note, output, presentation, session info). Slightly lengthy but every sentence adds value; no wasted words.

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

Completeness5/5

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

Given the output schema exists, the description still adds valuable context about follow-ups, session expiration, and output fields. No notable gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description explains all 5 parameters with examples and ranges (e.g., year e.g. 1991, month 1-12, day 1-31, hour 0-23, gender 1=男, 0=女). This adds complete meaning beyond the 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 it produces a full destiny-chart reading for a birth moment. It distinguishes from the sibling tool luopan_chat by mentioning follow-up capability.

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

Usage Guidelines5/5

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

Explicitly lists pre-call confirmations required from the user, warns about less precise hour, and explains session expiration and follow-up limit. Provides clear guidance on when to use this tool vs luopan_chat.

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

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/ZoezoeCookie/mcp-luopan'

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