### Start Bazi MCP with Streamable HTTP Source: https://github.com/cantian-ai/bazi-mcp/blob/dev/README.md Use this command to start the Bazi MCP service using the Streamable HTTP transport. Ensure Node.js 22 or above is installed. ```shell npm start ``` -------------------------------- ### Install Bazi MCP via Smithery for Claude Desktop Source: https://github.com/cantian-ai/bazi-mcp/blob/dev/README.md Install the bazi-mcp for Claude Desktop automatically using the Smithery CLI. This command simplifies the installation process. ```bash npx -y @smithery/cli install @cantian-ai/bazi-mcp --client claude ``` -------------------------------- ### Start Bazi MCP as HTTP Server Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Run this command to start the Bazi MCP server. It defaults to port 3000 but can be configured using the PORT environment variable. ```bash npm start # Server listens at http://localhost:3000/mcp # Set PORT env variable to override, e.g.: PORT=8080 npm start ``` -------------------------------- ### Expected Response from getSolarTimes Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt An example of the response from the `getSolarTimes` tool, which is a list of Gregorian datetimes that match the provided Bazi string. ```json // Expected response — list of matching solar datetimes ["1758-07-29 14:00:00", "1818-07-15 14:00:00", "1998-07-31 14:00:00"] ``` -------------------------------- ### Expected Response from getBaziDetail Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt An example of the detailed Bazi chart response from the `getBaziDetail` tool, including pillars, gods, fortunes, and more. The response is truncated for brevity. ```json // Expected response (truncated for brevity) { "性别": "男", "阳历": "1998年7月31日 14:10:00", "农历": "农历戊寅年六月初九辛未时", "八字": "戊寅 己未 己卯 辛未", "生肖": "虎", "日主": "己", "年柱": { "天干": { "天干": "戊", "五行": "土", "阴阳": "阳", "十神": "劫财" }, "地支": { "地支": "寅", "五行": "木", "阴阳": "阳", "藏干": { "主气": { "天干": "甲", "十神": "正官" }, "中气": { "天干": "丙", "十神": "正印" }, "余气": { "天干": "戊", "十神": "劫财" } } }, "纳音": "城头土", "旬": "甲戌", "空亡": "申酉", "星运": "死", "自坐": "长生" }, "月柱": { "..." : "..." }, "日柱": { "..." : "..." }, "时柱": { "..." : "..." }, "胎元": "庚戌", "胎息": "甲戌", "命宫": "乙卯", "身宫": "乙卯", "神煞": { "年柱": ["国印", "亡神"], "月柱": ["天德合", "月德合", "天乙贵人", "太极贵人", "福星贵人"], "日柱": ["天德合", "月德合", "桃花", "九丑", "童子煞"], "时柱": ["天乙贵人", "太极贵人", "福星贵人"] }, "大运": { "起运年龄": 4, "起运日期": "2001-1-26", "大运": [ { "干支": "庚申", "开始年份": 2001, "结束": 2010, "天干十神": "伤官", "地支十神": ["伤官", "正财", "劫财"], "地支藏干": ["庚", "壬", "戊"], "开始年龄": 4, "结束年龄": 13 } ] }, "刑冲合会": { "日": { "地支": { "半合": [{ "柱": "月", "知识点": "卯未半合木", "元素": "木" }] } } } } ``` -------------------------------- ### HTTP Transport: POST /mcp Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Accesses MCP tools via a single `POST /mcp` endpoint using the MCP Streamable HTTP protocol. Each request is stateless. Ensure the server is started with `PORT=3000 npm start`. ```bash # Start the server PORT=3000 npm start ``` ```bash # Call getBaziDetail via HTTP curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "getBaziDetail", "arguments": { "solarDatetime": "1990-01-15T08:30:00+08:00", "gender": 0, "eightCharProviderSect": 2 } } }' ``` ```bash # Call getChineseCalendar via HTTP curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "getChineseCalendar", "arguments": { "solarDatetime": "2025-01-29T00:00:00+08:00" } } }' ``` ```bash # Call getSolarTimes via HTTP curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "getSolarTimes", "arguments": { "bazi": "庚午 戊子 甲申 甲辰" } } }' ``` -------------------------------- ### Call getSolarTimes with Bazi String Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Example MCP tool call to `getSolarTimes` using a Bazi string to find matching Gregorian birth datetimes. The `bazi` parameter requires the four pillars separated by spaces. ```json // MCP tool call { "tool": "getSolarTimes", "arguments": { "bazi": "戊寅 己未 己卯 辛未" } } ``` -------------------------------- ### Call getBaziDetail with Solar Datetime Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Example MCP tool call to `getBaziDetail` using a solar (Gregorian) birth datetime and gender. Ensure only one of `solarDatetime` or `lunarDatetime` is provided. ```json // MCP tool call — solar datetime input (male born 1998-07-31 14:10 CST) { "tool": "getBaziDetail", "arguments": { "solarDatetime": "1998-07-31T14:10:00+08:00", "gender": 1, "eightCharProviderSect": 2 } } ``` -------------------------------- ### Call getBaziDetail with Lunar Datetime Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Example MCP tool call to `getBaziDetail` using a lunar birth datetime and gender. Ensure only one of `solarDatetime` or `lunarDatetime` is provided. ```json // MCP tool call — lunar datetime input (female) { "tool": "getBaziDetail", "arguments": { "lunarDatetime": "1998-6-9 14:10:00", "gender": 0 } } ``` -------------------------------- ### Programmatic Usage: getChineseCalendar Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Retrieves Chinese almanac information. Can be called with no arguments to get today's almanac, or with a specific `solarDatetime` string. ```typescript // Chinese almanac for today const today = getChineseCalendar(); console.log(today.节气); // e.g. "立夏" console.log(today.宜); // recommended activities ``` ```typescript // Chinese almanac for a specific date const almanac = getChineseCalendar('2025-02-05T00:00:00+08:00'); console.log(almanac.农历); // "农历乙巳年正月初八" console.log(almanac.财神方位); // e.g. "正北" ``` -------------------------------- ### HTTP Transport: POST /mcp Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt All MCP tools are accessible via a single `POST /mcp` endpoint when running as an HTTP server. Requests are stateless. ```APIDOC ## HTTP Transport: POST `/mcp` When running as an HTTP server (`npm start`), all three MCP tools are accessible via a single `POST /mcp` endpoint using the MCP Streamable HTTP protocol. Each request is stateless (no session ID). ### Request Example (getBaziDetail) ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "getBaziDetail", "arguments": { "solarDatetime": "1990-01-15T08:30:00+08:00", "gender": 0, "eightCharProviderSect": 2 } } }' ``` ### Request Example (getChineseCalendar) ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "getChineseCalendar", "arguments": { "solarDatetime": "2025-01-29T00:00:00+08:00" } } }' ``` ### Request Example (getSolarTimes) ```bash curl -X POST http://localhost:3000/mcp \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "getSolarTimes", "arguments": { "bazi": "庚午 戊子 甲申 甲辰" } } }' ``` ``` -------------------------------- ### Configure Bazi MCP for Stdio Transport Source: https://github.com/cantian-ai/bazi-mcp/blob/dev/README.md Configure your AI application, such as Claude Desktop, to use the Bazi MCP via Stdio transport by specifying the command and arguments in the configuration file. ```json { "mcpServers": { "Bazi": { "command": "npx", "args": ["bazi-mcp"] } } } ``` -------------------------------- ### Programmatic Usage: getBaziDetail Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Calculates a full Bazi chart from solar or lunar datetime. Requires `solarDatetime` or `lunarDatetime`, `gender`, and optionally `eightCharProviderSect`. The `gender` parameter uses 0 for female and 1 for male. ```typescript import { getBaziDetail, getSolarTimes, getChineseCalendar } from './src/index.js'; // Full Bazi chart from solar datetime (male) const chart = await getBaziDetail({ solarDatetime: '1998-07-31T14:10:00+08:00', gender: 1, eightCharProviderSect: 2, }); console.log(chart.八字); // "戊寅 己未 己卯 辛未" console.log(chart.日主); // "己" console.log(chart.大运.起运年龄); // 4 ``` ```typescript // Full Bazi chart from lunar datetime (female) const chartLunar = await getBaziDetail({ lunarDatetime: '1990-3-15 10:00:00', gender: 0, }); console.log(chartLunar.性别); // "女" ``` -------------------------------- ### getBaziDetail Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Calculates a full Bazi chart from a solar or lunar birth datetime and gender. It provides detailed information including the four pillars, ten gods, hidden stems, nayin, decade fortunes, auspicious gods, and clash/combination relationships. ```APIDOC ## MCP Tool: `getBaziDetail` ### Description Calculates a full Bazi chart — the four pillars (year, month, day, hour stems and branches), ten gods, hidden stems, nayin, decade fortunes (大运), auspicious gods (神煞), and clash/combination relationships — from either a solar (Gregorian) or lunar birth datetime plus gender. Exactly one of `solarDatetime` or `lunarDatetime` must be supplied. ### Method POST (MCP Tool Call) ### Endpoint `/mcp` (when running as HTTP server) ### Parameters #### Request Body Arguments - **`tool`** (string) - Required - Must be `"getBaziDetail"`. - **`arguments`** (object) - Required - Contains the parameters for the tool. - **`solarDatetime`** (string) - Required (one of `solarDatetime` or `lunarDatetime`) - ISO 8601 datetime, e.g. `"1998-07-31T14:10:00+08:00"`. - **`lunarDatetime`** (string) - Required (one of `solarDatetime` or `lunarDatetime`) - Lunar datetime, e.g. `"1998-6-9 14:10:00"`. - **`gender`** (number) - Optional - `0` = female, `1` = male. Defaults to `1`. - **`eightCharProviderSect`** (number) - Optional - `1` = 23:00–23:59 belongs to next day; `2` = same day. Defaults to `2`. ### Request Example ```json { "tool": "getBaziDetail", "arguments": { "solarDatetime": "1998-07-31T14:10:00+08:00", "gender": 1, "eightCharProviderSect": 2 } } ``` ### Response #### Success Response (200) - **`性别`** (string) - Gender. - **`阳历`** (string) - Solar datetime. - **`农历`** (string) - Lunar datetime. - **`八字`** (string) - The four pillars. - **`生肖`** (string) - Chinese zodiac animal. - **`日主`** (string) - Day master. - **`年柱`** (object) - Year pillar details. - **`月柱`** (object) - Month pillar details. - **`日柱`** (object) - Day pillar details. - **`时柱`** (object) - Hour pillar details. - **`胎元`** (string) - Fetal element. - **`胎息`** (string) - Fetal breath. - **`命宫`** (string) - Life palace. - **`身宫`** (string) - Body palace. - **`神煞`** (object) - Auspicious gods. - **`大运`** (object) - Decade fortunes. - **`刑冲合会`** (object) - Clash, combination, and harmony relationships. #### Response Example ```json { "性别": "男", "阳历": "1998年7月31日 14:10:00", "农历": "农历戊寅年六月初九辛未时", "八字": "戊寅 己未 己卯 辛未", "生肖": "虎", "日主": "己", "年柱": { "天干": {"天干": "戊", "五行": "土", "阴阳": "阳", "十神": "劫财"}, "地支": { "地支": "寅", "五行": "木", "阴阳": "阳", "藏干": { "主气": {"天干": "甲", "十神": "正官"}, "中气": {"天干": "丙", "十神": "正印"}, "余气": {"天干": "戊", "十神": "劫财"} } }, "纳音": "城头土", "旬": "甲戌", "空亡": "申酉", "星运": "死", "自坐": "长生" }, "月柱": { "..." : "..." }, "日柱": { "..." : "..." }, "时柱": { "..." : "..." }, "胎元": "庚戌", "胎息": "甲戌", "命宫": "乙卯", "身宫": "乙卯", "神煞": { "年柱": ["国印", "亡神"], "月柱": ["天德合", "月德合", "天乙贵人", "太极贵人", "福星贵人"], "日柱": ["天德合", "月德合", "桃花", "九丑", "童子煞"], "时柱": ["天乙贵人", "太极贵人", "福星贵人"] }, "大运": { "起运年龄": 4, "起运日期": "2001-1-26", "大运": [ { "干支": "庚申", "开始年份": 2001, "结束": 2010, "天干十神": "伤官", "地支十神": ["伤官", "正财", "劫财"], "地支藏干": ["庚", "壬", "戊"], "开始年龄": 4, "结束年龄": 13 } ] }, "刑冲合会": { "日": { "地支": { "半合": [{ "柱": "月", "知识点": "卯未半合木", "元素": "木" }] } } } } ``` ``` -------------------------------- ### getBaziDetail Source: https://github.com/cantian-ai/bazi-mcp/blob/dev/README.md Calculates Bazi information based on the provided solar or lunar datetime. This tool is designed to provide accurate Bazi data for various applications. ```APIDOC ## getBaziDetail ### Description Calculate the Bazi results based on the solar/lunar datetime. ### Arguments - **solarDatetime** (String) - Required - ISO format solar datetime. Example: `2000-05-15T12:00:00+08:00`. - **lunarDatetime** (String) - Required - Lunar datetime. Example: `2000-05-15 12:00:00`. - **gender** (Number) - Optional - Gender. 0 for female, 1 for male. 1 by default. - **eightCharProviderSect** (Number) - Optional - Configuration for eight char provider. 1 for meaning the day stem of 23:00-23:59 is for tomorrow, 2 for meaning the day stem of 23:00-23:59 is for today. 2 by default. ``` -------------------------------- ### Programmatic Usage (TypeScript/Node.js) Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt The core MCP functions can be imported directly as TypeScript modules for use in Node.js applications. ```APIDOC ## Programmatic Usage (TypeScript/Node.js) The core functions are also importable directly as TypeScript modules for use outside the MCP layer. ### `getBaziDetail` Calculates a full Bazi chart from solar or lunar datetime. #### Parameters - `solarDatetime` (string) - Optional - ISO 8601 datetime. - `lunarDatetime` (string) - Optional - Lunar datetime string. - `gender` (number) - Required - 0 for female, 1 for male. - `eightCharProviderSect` (number) - Optional - Specifies the sect for eight-character calculation. ### `getSolarTimes` Reverse lookup to find all birth dates matching a given Bazi string. #### Parameters - `bazi` (string) - Required - The Bazi string (e.g., "戊寅 己未 己卯 辛未"). ### `getChineseCalendar` Retrieves Chinese almanac information. #### Parameters - `solarDatetime` (string) - Optional - ISO 8601 datetime; defaults to today. ### Example Usage ```typescript import { getBaziDetail, getSolarTimes, getChineseCalendar } from './src/index.js'; // Full Bazi chart from solar datetime (male) const chart = await getBaziDetail({ solarDatetime: '1998-07-31T14:10:00+08:00', gender: 1, eightCharProviderSect: 2, }); console.log(chart.八字); // "戊寅 己未 己卯 辛未" console.log(chart.日主); // "己" console.log(chart.大运.起运年龄); // 4 // Full Bazi chart from lunar datetime (female) const chartLunar = await getBaziDetail({ lunarDatetime: '1990-3-15 10:00:00', gender: 0, }); console.log(chartLunar.性别); // "女" // Reverse lookup: find all birth dates matching a Bazi const dates = await getSolarTimes({ bazi: '戊寅 己未 己卯 辛未' }); console.log(dates); // ["1758-07-29 14:00:00", "1818-07-15 14:00:00", "1998-07-31 14:00:00"] // Chinese almanac for today const today = getChineseCalendar(); console.log(today.节气); // e.g. "立夏" console.log(today.宜); // recommended activities // Chinese almanac for a specific date const almanac = getChineseCalendar('2025-02-05T00:00:00+08:00'); console.log(almanac.农历); // "农历乙巳年正月初八" console.log(almanac.财神方位); // e.g. "正北" ``` ``` -------------------------------- ### getSolarTimes Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Performs a reverse Bazi lookup, returning all possible Gregorian birth datetimes for a given four-pillar Bazi string. ```APIDOC ## MCP Tool: `getSolarTimes` ### Description Performs a reverse Bazi lookup: given a four-pillar Bazi string (年柱 月柱 日柱 时柱 separated by spaces), returns all possible Gregorian birth datetimes from 1700 to the current year that produce that exact chart. ### Method POST (MCP Tool Call) ### Endpoint `/mcp` (when running as HTTP server) ### Parameters #### Request Body Arguments - **`tool`** (string) - Required - Must be `"getSolarTimes"`. - **`arguments`** (object) - Required - Contains the parameters for the tool. - **`bazi`** (string) - Required - Four pillars separated by spaces, e.g. `"戊寅 己未 己卯 辛未"`. ### Request Example ```json { "tool": "getSolarTimes", "arguments": { "bazi": "戊寅 己未 己卯 辛未" } } ``` ### Response #### Success Response (200) - **`response`** (array of strings) - A list of matching solar datetimes in `YYYY-MM-DD HH:MM:SS` format. #### Response Example ```json ["1758-07-29 14:00:00", "1818-07-15 14:00:00", "1998-07-31 14:00:00"] ``` ``` -------------------------------- ### Programmatic Usage: getSolarTimes Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Performs a reverse lookup to find all birth dates matching a given Bazi. The `bazi` argument should be a string of four pairs of heavenly stems and earthly branches. ```typescript // Reverse lookup: find all birth dates matching a Bazi const dates = await getSolarTimes({ bazi: '戊寅 己未 己卯 辛未' }); console.log(dates); // ["1758-07-29 14:00:00", "1818-07-15 14:00:00", "1998-07-31 14:00:00"] ``` -------------------------------- ### getChineseCalendar Tool Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Retrieves traditional Chinese almanac information for a given Gregorian date. It can be called with a specific date or defaults to today. ```APIDOC ## MCP Tool: `getChineseCalendar` Retrieves the traditional Chinese almanac (黄历) information for a given Gregorian date, including the lunar date, day stem-branch, solar term (节气), twenty-eight lunar mansion (二十八宿), Pengzu taboos (彭祖百忌), auspicious directions for various gods, clash/ominous information, and recommended/avoided activities for the day. ### Parameters #### Query Parameters - **solarDatetime** (string) - Optional - ISO 8601 datetime; defaults to today (China Standard Time) ### Request Example (Tool Call) ```json { "tool": "getChineseCalendar", "arguments": { "solarDatetime": "2025-05-07T12:00:00+08:00" } } ``` ### Response Example ```json { "公历": "2025年5月7日 星期三", "农历": "农历乙巳年四月初十", "干支": "乙巳 辛巳 丙子", "生肖": "蛇", "纳音": "涧下水", "节气": "立夏", "二十八宿": "箕水豹吉", "彭祖百忌": "丙不修灶必见灾殃 子不问卜自惹祸殃", "喜神方位": "西南", "阳贵神方位": "西", "阴贵神方位": "西北", "福神方位": "东", "财神方位": "西南", "冲煞": "冲马(午)煞南", "宜": "嫁娶,祭祀,祈福,求嗣,开光,出行,拆卸,动土,上梁,出火,进人口,入宅,移徙,安床,栽种,纳畜,牧养,竖柱,安门,修造,解除,会亲友", "忌": "" } ``` ``` -------------------------------- ### MCP Tool: getChineseCalendar Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Retrieves traditional Chinese almanac information for a given Gregorian date. The `solarDatetime` argument is optional and defaults to the current date in China Standard Time. ```json { "tool": "getChineseCalendar", "arguments": { "solarDatetime": "2025-05-07T12:00:00+08:00" } } ``` ```json { "tool": "getChineseCalendar", "arguments": {} } ``` ```json { "公历": "2025年5月7日 星期三", "农历": "农历乙巳年四月初十", "干支": "乙巳 辛巳 丙子", "生肖": "蛇", "纳音": "涧下水", "节气": "立夏", "二十八宿": "箕水豹吉", "彭祖百忌": "丙不修灶必见灾殃 子不问卜自惹祸殃", "喜神方位": "西南", "阳贵神方位": "西", "阴贵神方位": "西北", "福神方位": "东", "财神方位": "西南", "冲煞": "冲马(午)煞南", "宜": "嫁娶,祭祀,祈福,求嗣,开光,出行,拆卸,动土,上梁,出火,进人口,入宅,移徙,安床,栽种,纳畜,牧养,竖柱,安门,修造,解除,会亲友", "忌": "" } ``` -------------------------------- ### getChineseCalendar Source: https://context7.com/cantian-ai/bazi-mcp/llms.txt Retrieves traditional Chinese almanac (黄历) information for a given date. ```APIDOC ## MCP Tool: `getChineseCalendar` ### Description Retrieves traditional Chinese almanac (黄历) information for any given date. ### Method POST (MCP Tool Call) ### Endpoint `/mcp` (when running as HTTP server) ### Parameters #### Request Body Arguments - **`tool`** (string) - Required - Must be `"getChineseCalendar"`. - **`arguments`** (object) - Required - Contains the parameters for the tool. - **`date`** (string) - Required - The date for which to retrieve almanac information, in `YYYY-MM-DD` format. ### Request Example ```json { "tool": "getChineseCalendar", "arguments": { "date": "2023-10-26" } } ``` ### Response #### Success Response (200) - **`response`** (object) - Contains almanac information for the specified date. (Specific fields not detailed in source) #### Response Example (Example response structure not provided in source) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.