Bazi MCP

repository·dev·Indexed 19 days ago

https://github.com/cantian-ai/bazi-mcp

An AI-powered Model Context Protocol (MCP) server for precise Bazi (Chinese Metaphysics) calculations. It provides tools to calculate detailed Bazi profiles (Four Pillars, ten gods, major cycles), retrieve Chinese Almanac (Huangli) information, and find solar dates from Bazi strings. Supports both Stdio and Streamable HTTP transport, requiring Node.js version 22 or above.

Tokens
3K
Snippets
16
Records
20
Agent score
65%

What's inside bazi-mcp

  1. Start Bazi MCP using Stdio transport

    dev

    To use Bazi MCP with an AI application that supports the Model Context Protocol (MCP) via Stdio (such as Claude Desktop), add the following configuration to your application's MCP settings file:

    {
      "mcpServers": {
        "Bazi": {
          "command": "npx",
          "args": ["bazi-mcp"]
        }
      }
    }
  2. Install Bazi MCP via Smithery

    dev

    You can automatically install Bazi MCP for Claude Desktop using the Smithery CLI. This is the recommended method for automated setup.

    npx -y @smithery/cli install @cantian-ai/bazi-mcp --client claude
  3. Use getSolarTimes to find solar dates from Bazi

    dev

    Given a Bazi string, this tool returns a list of possible solar calendar datetimes that match those characters.

    // Example arguments for getSolarTimes
    {
      "bazi": "戊寅 己未 己卯 辛未"
    }
  4. Use getChineseCalendar to get Almanac information

    dev

    Retrieve Chinese Almanac (Huangli) information for a specific solar calendar date. If no date is provided, it defaults to today. The result includes information such as the lunar date, stems and branches, zodiac sign, solar terms (Jieqi), auspicious directions, and daily 'do's and don'ts' (宜/忌).

    // Example arguments for getChineseCalendar
    {
      "solarDatetime": "2000-05-15T12:00:00+08:00"
    }
  5. Use getBaziDetail to calculate Bazi information

    dev

    Calculate detailed Bazi (Eight Characters) results based on either a solar (ISO format) or lunar datetime. The tool provides comprehensive data including the four pillars (Year, Month, Day, Hour), stems and branches, five elements, ten gods, life palaces, and major cycles (Da Yun).

    // Example arguments for getBaziDetail
    {
      "solarDatetime": "2000-05-15T12:00:00+08:00",
      "gender": 1,
      "eightCharProviderSect": 2
    }
  6. getBaziDetail arguments and configuration

    dev

    The getBaziDetail tool accepts the following arguments:

    • solarDatetime (String): Solar datetime in ISO format. Example: 2000-05-15T12:00:00+08:00.
    • lunarDatetime (String): Lunar datetime. Example: 2000-05-15 12:00:00.
    • gender (Number, Optional): Gender. 0 for female, 1 for male. Defaults to 1.
    • eightCharProviderSect (Number, Optional): Configuration for the eight char provider regarding the late Zi hour (23:00-23:59). 1 means the day stem/branch is for tomorrow; 2 means it is for today. Defaults to 2.
  7. Build a Bazi profile with buildBazi()

    dev

    Use buildBazi to generate a comprehensive Bazi (Eight Characters) profile. This function calculates the Four Pillars (Year, Month, Day, Hour), Zodiac, Day Master (日主), Fetal Origin (胎元), Fetal Breath (胎息), Life Palace (命宫), Body Palace (身宫), Shen Sha (神煞), Decade Fortune (大运), and Pillar Relations (刑冲合会).

    Options

    • lunarHour: A LunarHour object representing the birth time.
    • eightCharProviderSect (optional): Determines the provider used for lunar hour calculations. Use 1 for DefaultEightCharProvider or 2 for LunarSect2EightCharProvider. Defaults to 2.
    • gender (optional): The gender of the individual. Use 0 for Female or 1 for Male. Defaults to 1.
    import { buildBazi } from './path-to-bazi';
    
    const baziProfile = buildBazi({
      lunarHour: myLunarHourInstance,
      eightCharProviderSect: 2,
      gender: 1
    });
  8. Build a Sixty Cycle object with buildSixtyCycleObject()

    dev

    The buildSixtyCycleObject function transforms a SixtyCycle (干支) into a detailed object containing information about the Heaven Stem (天干) and Earth Branch (地支).

    Parameters

    • sixtyCycle: The SixtyCycle instance to process.
    • me (optional): The Day Master (HeavenStem). If provided, the function calculates the Ten Stars (十神) for the stems and branches relative to this Day Master. If not provided, it defaults to the stem of the current cycle.

    Output Structure

    • 天干 (Heaven Stem): Includes name, element (五行), Yin/Yang (阴阳), and Ten Star (十神) if me is provided.
    • 地支 (Earth Branch): Includes name, element, Yin/Yang, and 藏干 (Hidden Stems) containing 主气 (Main), 中气 (Middle), and 余气 (Residual).
    • 纳音: The sound/element of the cycle.
    • : The decade/period.
    • 空亡: Void/Emptiness indicators.
    • 星运 & 自坐: Terrain-related properties based on the Day Master.
    import { buildSixtyCycleObject } from './path-to-bazi';
    
    // Example: Building an object for a specific cycle relative to a Day Master
    const cycleObject = buildSixtyCycleObject(mySixtyCycle, myDayMasterStem);