OpenFate Charts MCP v0.8.0. Sixteen local BaZi, Zi Wei and Western natal tools for Claude Code, Claude Desktop and Cursor. npx -y @openfate/bazi-mcp@0.8.0

npm CI License: MIT Desktop extension Engine

Download for Claude Desktop · Claude Code setup · Cursor setup · Recreate Ren Tieqiao’s chart · 繁體中文安裝

BaZi · 八字  /  Zi Wei Dou Shu · 紫微斗數  /  Western astrology · 西洋占星

16 local tools, zero API keys, 3,336,072 sampled charts across the three published archives, stdio for Node.js 20+. **Sixteen local tools for BaZi, Zi Wei Dou Shu and Western astrology in Claude or Cursor.** Trace a BaZi reading back to its hour pillar, find which star carries a natal transformation, or see why Venus changes house when the sky stays the same. One installation includes all three engines and needs no OpenFate API key. The same read_bazi_relationship tool returns day-hour-destruction at 08:30 (戊辰) and day-hour-harm at 12:30 (庚午) for August 15, 1997. Jump to the example request. Two birth times, two rule IDs. [Try this request](#try-one-chart) or [explore all sixteen tools](#tools). For the **1,112,328 chart samples and 14,460,264 life chapters** available offline, visit the [OpenFate Bazi Engine](https://github.com/openfate-ai/bazi-engine). ## Three chart libraries Select a sampled birth time, ask for a chapter, and follow its evidence back to the chart. The three editions contain **3,336,072 sample records and 43,368,936 Traditional Chinese chapters**. Each archive includes the text and publishes the rules that produced it. | Archive | Samples | Chapters | Example to open | | --- | ---: | ---: | --- | | BaZi | 1,112,328 | 14,460,264 | [Open the chart](https://openfate-ai.github.io/bazi-engine/library/#id=1991-10-18T08%3A30%3A00%2B08%3A00%2Ffemale) | | Zi Wei Dou Shu | 1,111,872 | 14,454,336 | [Life Palace with Zi Wei](https://openfate-ai.github.io/ziwei-engine/#date=2000-08-16&hour=4&gender=female&chapter=life) | | Western astrology | 1,111,872 | 14,454,336 | [The Sun–Moon conjunction](https://openfate-ai.github.io/astrology-engine/#date=2024-04-09&hour=2&chapter=aspect) | ## Install **Claude Desktop.** Download the [v0.8.0 desktop extension (.mcpb)](https://github.com/openfate-ai/openfate-mcp/releases/download/v0.8.0/openfate-bazi-mcp-v0.8.0.mcpb) and open it in a client that supports desktop extensions. The release includes its runtime dependencies. [Release notes](https://github.com/openfate-ai/openfate-mcp/releases/tag/v0.8.0) **Claude Code.** With Node.js 20+ and `npx` on your path, run: ```sh claude mcp add --transport stdio openfate-bazi -- npx -y @openfate/bazi-mcp@0.8.0 ``` Run `claude mcp get openfate-bazi` to check the connection. **Cursor and Cline** can launch the same stdio server using the JSON configurations below. Running `npx -y @openfate/bazi-mcp@0.8.0` directly starts a process that waits for an MCP client on stdin. [Claude Code MCP setup](https://code.claude.com/docs/en/mcp) ### Try one chart Paste this into your connected client: > Use `read_bazi_relationship` for August 15, 1997, female, 08:30 local time, UTC+8, no DST, longitude 120° east. Run it again at 12:30. Show both hour pillars, the rule IDs and the chart evidence for each reading. | Local time | Hour pillar | Selected rule | Evidence in `data.chart` | | --- | --- | --- | --- | | 08:30 | 戊辰 | `day-hour-destruction` | `DESTRUCTION:day:丑\|hour:辰` | | 12:30 | 庚午 | `day-hour-harm` | `HARM:day:丑\|hour:午` | Look in `data.reading.evidence` for the chart pointer. In both examples the relationship ID is at `/interactions/1/id`. Omit the birth time entirely and the reading reports `unknown-hour`. [Open these two charts in the browser](https://openfate-ai.github.io/bazi-engine/compare/) · [Chapter rules](https://github.com/openfate-ai/bazi-engine/blob/main/src/readings/relationship.ts) ## Claude Desktop ```jsonc { "mcpServers": { "openfate-bazi": { "command": "npx", "args": ["-y", "@openfate/bazi-mcp"] } } } ```
Claude Desktop cannot find npx on macOS Run `which npx` in your terminal and use the returned path for `command`. This example uses the Homebrew location. ```jsonc { "mcpServers": { "openfate-bazi": { "command": "/opt/homebrew/bin/npx", "args": ["-y", "@openfate/bazi-mcp"] } } } ```
## Cursor Add the entry below to `.cursor/mcp.json` in your project, or to `~/.cursor/mcp.json` to make it available across projects. Keep any existing servers in the file. [Cursor MCP configuration](https://cursor.com/docs/mcp) ```jsonc { "mcpServers": { "openfate-bazi": { "command": "npx", "args": ["-y", "@openfate/bazi-mcp"] } } } ``` ## Cline ```jsonc { "mcpServers": { "openfate-bazi": { "command": "npx", "args": ["-y", "@openfate/bazi-mcp"], "disabled": false } } } ``` ## Agent Skill This repository also includes a portable Agent Skill: ```txt skills/openfate-bazi/SKILL.md ``` Use it when you want Claude, Claude Code, Codex, OpenClaw-style agents, or other `SKILL.md` compatible tools to remember how to use the OpenFate Bazi MCP correctly. For Claude Code workspace usage, copy the skill folder to: ```txt .claude/skills/openfate-bazi/ ``` For Claude custom Skills, zip the `openfate-bazi` folder with `SKILL.md` at the folder root and upload it in Claude's Skills settings. ## Tools | If your user asks… | Call | | --- | --- | | “What are my four pillars and first luck cycle?” | `calculate_bazi_chart` | | “What changed in the reading when I changed the hour?” | `read_bazi_relationship` | | “Open the career chapter for this corpus sample.” | `read_bazi_corpus_chapter` | | “Which two branches actually clash?” | `detect_bazi_interactions` | | “How did 08:30 on the clock become a different solar time?” | `calculate_true_solar_time` | | “I have four pillars from a book. Which dates could fit?” | `reverse_bazi_to_solar_times` | | “Does this tool change the day at 23:00?” | `get_openfate_bazi_policy` | | “Where can I open the chart or continue reading?” | `get_openfate_bazi_resources` | | “List the 83 Zi Wei rules, then check whether this chart meets the Three Transformations rule.” | `detect_ziwei_patterns` | | “Show which four planets form a Kite. Give me all six angles.” | `detect_western_patterns` | | “Read the published Life Palace chapter for this chart.” | `read_ziwei_chapter` | | “Read the closest-aspect chapter and show me the two planets.” | `read_western_chapter` | | “Which stars and transformations occupy the twelve Zi Wei palaces?” | `calculate_ziwei_chart` | | “Which palaces form the trines and opposition to my Life Palace?” | `inspect_ziwei_palace` | | “How close were the Sun and Moon at this instant?” | `calculate_western_natal_chart` | | “Does Venus stay in the same house under both house systems?” | `compare_western_houses` | **Try Zi Wei.** Send `{"datetime":"2000-08-16T04:00:00+08:00","gender":"female"}` to `inspect_ziwei_palace`. The Life Palace at 午 contains 紫微. Change 04:00 to 06:00 and the Life Palace moves to 巳 with 天相. [Two complete charts and the placement rules](https://github.com/openfate-ai/ziwei-engine) **Try Western astrology.** Send `{"datetime":"2024-04-08T18:00:00Z","latitude":25.033,"longitude":121.5654}` to `compare_western_houses`. Venus at 4.427° falls in house three under Whole Sign and house two under Equal houses. [The chart and both sets of cusps](https://github.com/openfate-ai/astrology-engine) ### Read a Zi Wei or Western chapter Use either pattern tool with `{"mode":"catalog"}` to list the public rules without a birth date. To audit one result, add `"patternId":"three-transformations"` to a Zi Wei chart request or `"patternId":"kite"` to a Western request. The returned references resolve against `data.chart`. [Zi Wei atlas](https://openfate-ai.github.io/ziwei-engine/atlas/) · [Western atlas](https://openfate-ai.github.io/astrology-engine/atlas/) Call `read_ziwei_chapter` with `{"sampleId":"2000-08-16T04:30:00+08:00/female","topic":"life"}`, or `read_western_chapter` with `{"sampleId":"2024-04-09T02:30:00+08:00","topic":"aspect"}`. Each tool returns the published Traditional Chinese text, rule, evidence pointers rooted at `data.chart`, CC BY 4.0 license and the matching browser page. Both libraries run from 1900-01-31 through 2026-12-03 at fixed UTC+8. Zi Wei samples even hours with two traditional cycle directions. Western astrology samples all 24 hours at Taipei coordinates. ### `read_bazi_corpus_chapter` Try `{"sampleId":"1991-10-18T08:30:00+08:00/female","topic":"work"}`. Change the hour to 06:30 and compare both opening paragraphs. Each call returns one full chapter, the chart, evidence paths, edition, license and a link to the same [online reader](https://openfate-ai.github.io/bazi-engine/library/). All text is reproduced locally from corpus v2.1.0. The corpus accepts twelve even-hour slots at :30 per day from 1900-01-01 to 2026-11-22, UTC+8, 120° E. ### `read_bazi_relationship` Returns the calculated chart and a Traditional Chinese relationship chapter in `data.reading`. The response includes `ruleId`, `rulesVersion`, and evidence pointers relative to `data.chart`. Omit the hour to receive the explicit `unknown-hour` status. This tool uses the same deterministic chapter function as the npm SDK and the [browser comparison](https://openfate-ai.github.io/bazi-engine/compare/). Try `{"year":1997,"month":8,"day":15,"hour":8,"minute":30,"gender":"female","timezone":8,"dstOffset":0,"longitude":120}`. Change only the hour to 12 to compare a day–hour destruction with a day–hour harm. When both timezone forms are supplied, an explicit numeric timezone **and** DST offset take precedence. Omit the DST offset to let the IANA zone resolve the historical clock. The response reports the basis actually used. ### `calculate_bazi_chart` Calculates a deterministic Bazi chart. Inputs: - `year` - `month` - `day` - `hour` - `minute` - `second` - `gender` - `calendarType` - `isLeapMonth` - `longitude` - `timezone` - `timezoneId` - `dstOffset` - `enableTrueSolarTime` - `dayBoundaryMode` The MCP fixes the onset policy to `DAYUN_SECOND_V2`; callers cannot silently select a different rule. Pass an exact birth time plus `timezone` or `timezoneId` for a calculated receipt. Present an exact onset only when `chart.daYun.timing.status` is `CALCULATED` and its version is `DAYUN_SECOND_V2`. An `UNAVAILABLE` receipt identifies the reason and marks the retained legacy scalar fields as a fallback. Pass `longitude` as well for True Solar Time correction. ### `detect_bazi_interactions` Detects raw Earthly Branch relationship occurrences for a natal chart, with optional annual and Da Yun branches. Inputs are `yearBranch`, `monthBranch`, `dayBranch`, optional `hourBranch`, optional `annualBranch`, and optional `dayunBranch`. Omit `hourBranch` when birth time is unknown; it is not replaced with an assumed branch. Existing annual-only calls remain supported. Supported interaction types: - clash - six-combination - central-branch half-trine (`COMBINATION_HALF`) - trine - directional - punishment - destruction - harm Every matching pillar occurrence is preserved. For example, `{ yearBranch: '申', monthBranch: '寅', dayBranch: '申', hourBranch: '申' }` returns three distinct 寅申 clashes, not one. Annual and Da Yun branches keep separate `annual` and `dayun` roles even when their branch values match natal positions. The half-trine profile covers 申子、子辰、寅午、午戌、亥卯、卯未、巳酉、酉丑: each pair includes a central branch (子午卯酉). Endpoint-only pairs such as 申辰 are not this half-trine type. Half-trines remain in raw output when the full three-branch trine is also present. Each occurrence has a stable `id` and aligned `branches` / `pillars` arrays. `targetElement` means relationship affinity, not transformed energy. Combination `transformationStatus` is `NOT_EVALUATED`: branch-only presence does not establish transformation or its failure. Other relationship types use `NOT_APPLICABLE`. These results are not scored weights and do not automatically cancel clashes; settlement and interpretation belong to a separate analysis layer. For API compatibility, full `TRINE` and `DIRECTIONAL` occurrences also retain legacy `resultElement`, equal to `targetElement` and carrying the same affinity-only meaning. Six-combinations and half-trines do not emit `resultElement`. ### `calculate_true_solar_time` Calculates True Solar Time directly. Use this when a user asks why OpenFate's hour pillar differs from a clock-time tool. ### `reverse_bazi_to_solar_times` reverse_bazi_to_solar_times finds 1953-06-24 and 2013-06-09 for 癸巳 戊午 丙午 壬辰. At 08:30 both charts keep the same pillars after True Solar Time. Ren Tieqiao recorded his own Four Pillars in his commentary on *Di Tian Sui*. Paste this request into Claude or Cursor after connecting the server. > Use `reverse_bazi_to_solar_times` to find dates from 1900 through 2026 for 癸巳 戊午 丙午 壬辰. Use `ZI_HOUR_23`. For each distinct date, use `calculate_bazi_chart` for a male chart at 08:30 civil time, longitude 120° east, UTC+8, no DST, with True Solar Time enabled. Show the date and the four recalculated pillars. The reverse lookup uses clock time and finds two dates. At 08:30, both charts still read 癸巳 戊午 丙午 壬辰 after solar-time correction. [June 24, 1953](https://openfate-ai.github.io/bazi-engine/library/#id=1953-06-24T08%3A30%3A00%2B08%3A00%2Fmale) · [June 9, 2013](https://openfate-ai.github.io/bazi-engine/library/#id=2013-06-09T08%3A30%3A00%2B08%3A00%2Fmale) · [The two charts in Ren’s commentary](https://github.com/openfate-ai/bazi-engine/blob/main/README.en.md#one-character) ### `get_openfate_bazi_policy` Returns OpenFate calculation policy: - True Solar Time is preferred when location data is available. - Default day-boundary mode is `ZI_HOUR_23`. - DST should be passed as `dstOffset` when birth certificate time includes daylight saving. - Da Yun onset uses `DAYUN_SECOND_V2`; exact dates require a calculated timing receipt. - Reverse lookup should be treated as a candidate search. - Branch interactions preserve raw pillar occurrences, not weighted or automatically transformed outcomes. ### `get_openfate_bazi_resources` Returns canonical OpenFate links for charting, readings, compatibility, wealth, true solar time, and `llms.txt`. ## Output Shape Responses use machine-friendly English keys: ```jsonc { "data": { "chart": {}, "policy": {} }, "attribution": { "brand": "OpenFate.ai", "url": "https://openfate.ai", "engine": "@openfate/bazi-engine", "trueSolarTimeEngine": "@openfate/true-solar-time" } } ``` Attribution is returned as first-class data, not hidden `_meta`, so MCP clients and generated artifacts can display it reliably. BaZi chart results include enriched pillar facts (Ten Gods, hidden stems, Na Yin, Xun, void branches, and growth stages), a versioned Da Yun timing receipt, normalized solar/lunar calendar data, and the calculation policy actually applied. ## Development To build a desktop extension from a source checkout, install dependencies and run `npm run mcpb:pack`. The artifact is written to `release/openfate-bazi-mcp-v.mcpb`. Maintainers publishing a local bundle to Smithery can use `npm run smithery:publish` after `smithery auth login`. ```bash npm install npm run build npm run smoke ``` The smoke test spawns the built stdio server and drives it through the real MCP SDK client. To test source changes without building `dist`, run `npm run smoke:source`. This requires the sibling `../bazi-engine` source checkout with its dependencies installed, as well as this package's dependencies. The test-only `tests/tsconfig.source.json` maps `@openfate/bazi-engine` to that sibling's `src/index.ts`; the smoke runner passes this configuration to the SDK-spawned server and asserts the resolved source path before testing. It does not rely on a patched installed engine and remains reproducible after `npm ci --ignore-scripts` in this package. Both smoke modes exercise the same MCP transport and regression fixtures, including second-resolved Da Yun onset, missing timing inputs, repeated branches, eight half-trines, unknown hour, and annual/Da Yun roles. The ordinary `smoke` command still tests built MCP output against its installed published engine dependency. `npx tsc --noEmit -p tests/tsconfig.source.json` checks the coordinated source contract without emitting build files. ### Engine compatibility The npm package includes both natal SDK runtimes. Run `python3 scripts/sync-natal-sdks.py --verify` to check their files and licenses against the published GitHub archives. Version 0.8.0 uses BaZi 2.2.0, Zi Wei 0.3.0 and Western Astrology 0.3.0. The stdio smoke test calls the installed server, compares its chapter and chart with the SDK, and checks unknown birth times and historical DST. [Test cases](tests/smoke-stdio.ts) ## Privacy Chart calculations run in the local MCP subprocess. The host client receives the tool arguments and results and handles the conversation under its own settings. ## OpenFate Links - [OpenFate.ai](https://openfate.ai) - [Free Bazi Chart Calculator](https://openfate.ai/en/bazi-chart?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [AI Bazi Reading](https://openfate.ai/en/bazi?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [Bazi Compatibility](https://openfate.ai/en/compatibility/bazi/marriage?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [True Solar Time Guide](https://openfate.ai/en/insights/true-solar-time?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [OpenFate llms.txt](https://openfate.ai/llms.txt) ## Where it is listed | Channel | Name | Use it for | | --- | --- | --- | | [npm](https://www.npmjs.com/package/@openfate/bazi-mcp) | `@openfate/bazi-mcp` | Claude Code, Cursor, Cline and any stdio client | | [Official MCP Registry](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.openfate-ai) | `io.github.openfate-ai/bazi-mcp` | Clients that discover servers from the registry | | [GitHub Releases](https://github.com/openfate-ai/openfate-mcp/releases) | `openfate-bazi-mcp-v.mcpb` | One-click install in Claude Desktop | | [Glama](https://glama.ai/mcp/servers/openfate-ai/openfate-mcp) | `openfate-ai/openfate-mcp` | Docker-based hosting and server directory | | [Agent Skill](skills/openfate-bazi) | `openfate-bazi` | Claude Skills, Claude Code and Codex-style agents | ## Changelog | Date | Version | What changed | | --- | --- | --- | | 2026‑12‑03 | v0.8.0 | Two local pattern tools with complete rule catalogs and natal evidence | | 2026‑12‑03 | v0.7.0 | Published Zi Wei and Western reading tools with a rule, chart evidence and a reader link for each chapter | | 2026‑12‑03 | v0.6.1 | Bundled both public natal SDKs for installation with default npm 12 settings | | 2026‑12‑03 | v0.6.0 | Added Zi Wei natal and palace tools, Western natal charts and a two-system house comparison | | 2026‑12‑03 | README | Ink cover, black-and-white figures and dark mode | | 2026‑12‑02 | README | Reverse-search Ren Tieqiao’s Four Pillars over MCP | | 2026‑11‑24 | v0.5.0 | `read_bazi_corpus_chapter` reads a published corpus chapter by sample ID; guided first chart and client setup | | 2026‑11‑23 | v0.4.0 | `read_bazi_relationship` returns traceable relationship readings with rule ID and chart evidence | | 2026‑09‑20 | v0.3.0–v0.3.1 | Second-resolved Da Yun onset; every branch-interaction occurrence kept | | 2026‑07‑01 | v0.2.4–v0.2.6 | Historical DST correction kept across the server boundary; registry metadata synced | | 2026‑06‑18 | v0.2.0–v0.2.3 | Richer chart output, desktop extension (.mcpb), automated GitHub and MCP Registry releases | | 2026‑06‑17 | v0.1.2 | First public release on npm and the MCP Registry | Full history: [Releases](https://github.com/openfate-ai/openfate-mcp/releases). ## Open-source scope | In this repository (MIT) | Stays on OpenFate.ai | | --- | --- | | The MCP server and all sixteen tools | Paid full reports | | Agent Skill, desktop extension build and Docker image | AI chat and Q&A | | Smoke tests against the published engine | Accounts, points and membership | Each engine documents its public calculation conventions. [BaZi](https://github.com/openfate-ai/bazi-engine) · [Zi Wei Dou Shu](https://github.com/openfate-ai/ziwei-engine) · [Western astrology](https://github.com/openfate-ai/astrology-engine) ## Contributing Issues and pull requests are welcome. For a calculation discrepancy, include the civil birth time, timezone or IANA name, longitude, day boundary and Da Yun timing version, plus the result you expected. Run `npm run build` and `npm run smoke` before opening a pull request. Details: [CONTRIBUTING.md](CONTRIBUTING.md) · [Code of Conduct](CODE_OF_CONDUCT.md) ## About and contact **Mission** Give AI clients charts that a reader can reproduce from the same time, coordinates and calculation settings. **Stack** TypeScript · Model Context Protocol SDK · stdio transport · Node.js 20+ **Contact** Questions and bugs: [GitHub issues](https://github.com/openfate-ai/openfate-mcp/issues). Product and partnerships: [OpenFate.ai](https://openfate.ai/en?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp). ## License MIT --- ## 繁體中文(台灣) 紫微可查 **83 條格局規則**,占星可查 **36 種圖形**。對 Claude 說「幫我找星盤上的風箏,列出四顆行星和六條邊各差幾度」,就能看到實際計算值。兩個判格工具傳入 `{"mode":"catalog"}` 都能讀完整目錄。[紫微圖鑑](https://openfate-ai.github.io/ziwei-engine/atlas/) · [占星圖鑑](https://openfate-ai.github.io/astrology-engine/atlas/) **一次安裝,Claude 或 Cursor 就能用 16 個本機工具排八字、紫微斗數和西洋星盤。** 八字可追到選出感情章的那一柱,紫微可查化權落在哪顆星,占星可比較同一顆金星在兩種宮制裡的位置。使用時無須 OpenFate API 金鑰。 三套命盤庫共收錄 **3,336,072 筆樣本、43,368,936 章成稿**。用 MCP 選一章,可讀全文、看規則,也能打開網頁核對盤上的字。[紫微選讀](https://openfate-ai.github.io/ziwei-engine/) · [占星選讀](https://openfate-ai.github.io/astrology-engine/) 任鐵樵在《滴天髓闡微》留下自己的四柱。裝好後,可以直接問 Claude 或 Cursor,哪些現代日期排得出這張盤。[複製四柱反查範例](#ren-tieqiao-zh) 可以先讀 1997 年 8 月 15 日的 08:30 和 12:30 兩張盤。前一篇問約好買菜卻沒買成,在哪一步漏了交接。後一篇問替對方做了哪個決定,讓原本的一番好意變了味。用瀏覽器打開兩篇,再用下面的工具輸入同一組資料,就能核對結果。[雙盤對照](https://openfate-ai.github.io/bazi-engine/compare/) · [命例教材](https://github.com/openfate-ai/bazi-engine/blob/main/learn/README.md) · [逐年命盤資料](https://github.com/openfate-ai/bazi-engine/releases/tag/corpus-v2.1.0) ## 安裝 **Claude Desktop** 可直接[下載 v0.8.0 桌面擴充套件](https://github.com/openfate-ai/openfate-mcp/releases/download/v0.8.0/openfate-bazi-mcp-v0.8.0.mcpb),在支援 MCPB 的客戶端開啟。安裝包已包含所需依賴。 **Claude Code** 使用 Node.js 20 以上的環境,確認終端機找得到 `npx`,再執行: ```sh claude mcp add --transport stdio openfate-bazi -- npx -y @openfate/bazi-mcp@0.8.0 ``` 用 `claude mcp get openfate-bazi` 查看連線狀態。Cursor 或 Cline 可使用下方 JSON 設定。若直接執行 `npx -y @openfate/bazi-mcp@0.8.0`,程式會等待客戶端從標準輸入送來請求。[Claude Code 安裝說明](https://code.claude.com/docs/en/mcp) ### 裝好後,把這句貼進對話 > 請用 `read_bazi_relationship` 比較兩張盤。1997 年 8 月 15 日,女,東經 120°、UTC+8、無夏令時間。第一張用 08:30,第二張用 12:30。請列出兩個時柱、各自選中的規則,以及命盤中對應的地支關係。 | 民用時刻 | 時柱 | 工具回傳的規則 | 正文從哪件事談起 | | --- | --- | --- | --- | | 08:30 | 戊辰 | `day-hour-destruction` | 兩人說好輪流買菜,哪一步交接漏了? | | 12:30 | 庚午 | `day-hour-harm` | 菜買好了,但邀朋友來吃飯這件事,對方想自己決定嗎? | 兩次回傳的 `data.reading.evidence` 都可對回 `data.chart`。想改這段文字,打開同一份[解讀規則](https://github.com/openfate-ai/bazi-engine/blob/main/src/readings/relationship.ts)。想批次讀各年份的 13 章生活解讀,可到引擎專案下載 **111 萬筆排盤樣本、1,446 萬章生活解讀**的[開放資料集](https://github.com/openfate-ai/bazi-engine/releases/tag/corpus-v2.1.0)。 ## Claude Desktop 設定 ```jsonc { "mcpServers": { "openfate-bazi": { "command": "npx", "args": ["-y", "@openfate/bazi-mcp"] } } } ```
macOS 找不到 npx 時,如何指定執行檔? 先在終端機執行 `which npx`,將結果填入 `command`。以下以 Homebrew 的安裝路徑為例。 ```jsonc { "mcpServers": { "openfate-bazi": { "command": "/opt/homebrew/bin/npx", "args": ["-y", "@openfate/bazi-mcp"] } } } ```
## Cursor 設定 將下方設定併入專案的 `.cursor/mcp.json`。若要在不同專案使用,可放在 `~/.cursor/mcp.json`。[Cursor 設定檔位置](https://cursor.com/docs/mcp) ```jsonc { "mcpServers": { "openfate-bazi": { "command": "npx", "args": ["-y", "@openfate/bazi-mcp"] } } } ``` ## Cline 設定 ```jsonc { "mcpServers": { "openfate-bazi": { "command": "npx", "args": ["-y", "@openfate/bazi-mcp"], "disabled": false } } } ``` ## Agent Skill 這個 repository 也包含一個可攜式 Agent Skill: ```txt skills/openfate-bazi/SKILL.md ``` 當你希望 Claude、Claude Code、Codex、OpenClaw-style agent,或其他支援 `SKILL.md` 的工具記住如何正確使用 OpenFate Bazi MCP 時,可以使用這個 Skill。 如果要在 Claude Code workspace 使用,請把整個 skill folder 複製到: ```txt .claude/skills/openfate-bazi/ ``` 如果要做 Claude custom Skill,請把 `openfate-bazi` folder 壓成 zip,確保 `SKILL.md` 位於 folder root,再到 Claude 的 Skills 設定中上傳。 ## 工具列表 | 你想查什麼 | 工具 | | --- | --- | | 四柱、十神、九步大運與起運依據 | `calculate_bazi_chart` | | 感情章的正文、規則與命盤引用 | `read_bazi_relationship` | | 按公開樣本 ID 查 13 章之一,逐段對照盤面 | `read_bazi_corpus_chapter` | | 哪兩柱相沖,加入流年後多出哪些關係 | `detect_bazi_interactions` | | 出生鐘點換成真太陽時的結果 | `calculate_true_solar_time` | | 古書只留四柱,哪些公曆日期可能符合 | `reverse_bazi_to_solar_times` | | 換日或起運採用的設定 | `get_openfate_bazi_policy` | | 線上排盤與延伸閱讀入口 | `get_openfate_bazi_resources` | | 紫微十二宮星曜、生年四化與大限歲數 | `calculate_ziwei_chart` | | 命宮的兩個三合宮、對宮及四化落點 | `inspect_ziwei_palace` | | 太陽和月亮相距幾度,有沒有形成相位 | `calculate_western_natal_chart` | | 同一顆金星在整宮制和等宮制各落哪一宮 | `compare_western_houses` | **試紫微。** 請工具比較 2000 年 8 月 16 日 04:00 與 06:00 的女盤,兩次都用 UTC+8 民用時間。第一張命宮在午,紫微坐命。兩小時後命宮到了巳,主星換成天相。[兩張原盤與安星約定](https://github.com/openfate-ai/ziwei-engine) **試占星。** 請工具以台北座標(北緯 25.033°、東經 121.5654°),比較 2024 年 4 月 8 日 18:00 UTC 的整宮制與等宮制。金星黃經都是 4.427°,兩張盤分別落在第三宮和第二宮。[金星與兩組宮頭](https://github.com/openfate-ai/astrology-engine) ### `read_bazi_corpus_chapter` 例如問:「幫我比較 1991-10-18 的 06:30 和 08:30 女盤,分別讀工作章,列出文字不同的第一段及其盤面依據。」使用 `{"sampleId":"1991-10-18T08:30:00+08:00/female","topic":"work"}`,再把日期裡的時刻改成 06:30。回傳的 `chapter.parts[].ref` 可在同一筆的 `data.chart` 找到。讀者也能用 `readerUrl` 在瀏覽器打開同一章。[線上命盤庫](https://openfate-ai.github.io/bazi-engine/library/) ### `read_bazi_relationship` 接受和排盤工具相同的出生輸入。感情章在 `data.reading`,其中的 `evidence` 記錄原始值與它在 `data.chart` 的位置。省略出生時辰時,回傳 `unknown-hour`。同時提供 IANA 時區名稱與數字時區時,明確填入的數字時區及夏令時間偏移優先;偏移資料填不齊時,依 IANA 時區換算。可從 `timezoneBasis` 查閱實際採用的設定。 ### `calculate_bazi_chart` 計算確定性的八字命盤。 輸入欄位: - `year` - `month` - `day` - `hour` - `minute` - `second` - `gender` - `calendarType` - `isLeapMonth` - `longitude` - `timezone` - `timezoneId` - `dstOffset` - `enableTrueSolarTime` - `dayBoundaryMode` MCP 固定使用 `DAYUN_SECOND_V2`,呼叫端不能暗中切換起運規則。精確出生時間還要搭配 `timezone` 或 `timezoneId`,並且只有 `chart.daYun.timing.status` 為 `CALCULATED`、版本為 `DAYUN_SECOND_V2` 時才能呈現精確起運時間。`UNAVAILABLE` 會說明原因,原有起運欄位只作 明確標記的舊版 fallback。若要校正真太陽時,還應提供 `longitude`。 ### `detect_bazi_interactions` 偵測本命盤及選填流年、大運地支的原始關係。 輸入欄位為 `yearBranch`、`monthBranch`、`dayBranch`,以及選填的 `hourBranch`、`annualBranch`、`dayunBranch`。出生時辰未知時省略 `hourBranch`,不會補入假設時柱。原有只傳流年的呼叫方式仍可使用。 支援類型: - 沖 - 六合 - 含旺支的半合(`COMBINATION_HALF`) - 三合 - 三會 - 刑 - 破 - 害 同一地支出現在不同柱位時,每個關係都會保留。例如申、寅、申、申會回傳三組不同柱位的寅申沖。流年與大運分別使用 `annual`、`dayun` 角色,即使地支相同,也不會與本命柱位合併。 半合口徑涵蓋申子、子辰、寅午、午戌、亥卯、卯未、巳酉、酉丑八組,每組都含子午卯酉其中一個旺支。申辰等兩端支不屬於此半合類型。三合齊全時,原始資料仍保留其中的半合關係。 每個關係包含穩定的 `id`,以及逐項對應的 `branches`、`pillars`。`targetElement` 只表示關係指向的五行,不代表已經合化。合類的 `transformationStatus` 為 `NOT_EVALUATED`,表示尚未評估合化,並非已成化或已判定不能化;其他關係使用 `NOT_APPLICABLE`。這些資料不是可直接累加的評分,也不會自動解沖;成立程度與解讀須由獨立分析層處理。 為相容既有 API,完整 `TRINE`、`DIRECTIONAL` 關係仍保留舊欄位 `resultElement`,值與 `targetElement` 相同,也僅表示五行指向。六合與半合不回傳 `resultElement`。 ### `calculate_true_solar_time` 直接計算真太陽時。 當使用者問「為什麼 OpenFate 算出的時柱跟一般排盤網站不同」時,可以用這個工具說明差異。 ### `reverse_bazi_to_solar_times` 用 reverse_bazi_to_solar_times 反查癸巳、戊午、丙午、壬辰,得到 1953 年 6 月 24 日與 2013 年 6 月 9 日。兩盤 08:30 換算真太陽時後四柱不變。 要重排任鐵樵自記的八字,可以把這句貼進已連上工具的對話。 > 請用 `reverse_bazi_to_solar_times` 查 1900 到 2026 年有哪些日期符合「癸巳 戊午 丙午 壬辰」,採子初換日(`ZI_HOUR_23`)。每個日期取上午 8 點半,再用 `calculate_bazi_chart` 排男命,東經 120°、UTC+8、無夏令時間,開啟真太陽時。列出日期和重排後的四柱。 工具先按鐘錶時間找出兩個日期。各取上午 8 點半重排,換算真太陽時後,四柱仍是癸巳、戊午、丙午、壬辰。[1953 年 6 月 24 日](https://openfate-ai.github.io/bazi-engine/library/#id=1953-06-24T08%3A30%3A00%2B08%3A00%2Fmale) · [2013 年 6 月 9 日](https://openfate-ai.github.io/bazi-engine/library/#id=2013-06-09T08%3A30%3A00%2B08%3A00%2Fmale) · [對讀任氏兩張命例](https://github.com/openfate-ai/bazi-engine#one-character) ### `get_openfate_bazi_policy` 回傳 OpenFate 的計算口徑: - 有出生地資料時,優先使用真太陽時。 - 預設換日規則是 `ZI_HOUR_23`。 - 如果出生證明時間包含夏令時間,應傳入 `dstOffset`。 - 大運起運固定採用 `DAYUN_SECOND_V2`;只有計算成功的 timing receipt 才是精確起運時間。 - 八字反查只能當候選搜尋,不能取代精準排盤。 - 地支互動保留原始柱位關係,不代表加權分數或自動合化結果。 ### `get_openfate_bazi_resources` 回傳 OpenFate 的官方連結,包括排盤、解讀、合盤、財富、真太陽時與 `llms.txt`。 ## 回傳格式 回傳資料使用穩定、適合機器讀取的英文 key: ```jsonc { "data": { "chart": {}, "policy": {} }, "attribution": { "brand": "OpenFate.ai", "url": "https://openfate.ai", "engine": "@openfate/bazi-engine", "trueSolarTimeEngine": "@openfate/true-solar-time" } } ``` 署名資訊會以一般資料欄位回傳,而不是藏在 `_meta`,方便 MCP client 或 AI 產生的圖表正確顯示來源。 排盤結果同時包含十神、藏干、納音、旬空、十二長生等柱位資料、版本化大運起運 receipt、標準化陽曆/農曆日期,以及實際採用的計算口徑。 ## 開發 若要從原始碼製作桌面擴充套件,請先安裝依賴,再執行 `npm run mcpb:pack`。成品位於 `release/openfate-bazi-mcp-v.mcpb`。維護者可於 Smithery 登入後使用 `npm run smithery:publish`。 ```bash npm install npm run build npm run smoke ``` `smoke` 測試會啟動編譯後的 stdio server,並透過真正的 MCP SDK client 呼叫工具。 不編譯 `dist` 時可執行 `npm run smoke:source` 驗證原始碼。須具備相鄰的 `../bazi-engine` 原始碼工作目錄,且引擎與本套件都已安裝依賴。測試專用的 `tests/tsconfig.source.json` 將 `@openfate/bazi-engine` 指向該引擎的 `src/index.ts`;測試執行器會把設定傳給 MCP SDK 啟動的伺服器,並先驗證實際解析的原始碼路徑。這個模式不依賴修改過的已安裝引擎,在本套件重新執行 `npm ci --ignore-scripts` 後仍可重現。 兩種 smoke 模式使用相同 MCP 傳輸與回歸案例,涵蓋秒級起運、缺少起運輸入、重複地支、八組半合、未知時辰,以及流年/大運角色。一般 `smoke` 仍驗證編譯後 MCP 與已安裝的 npm 公開引擎。`npx tsc --noEmit -p tests/tsconfig.source.json` 可檢查協調中的原始碼契約,不產生編譯檔案。 ### 引擎相容性 npm 套件隨附紫微與西洋占星的公開引擎。可用 `python3 scripts/sync-natal-sdks.py --verify` 逐檔核對 GitHub 發布內容與授權。0.8.0 版使用八字引擎 2.2.0、紫微引擎 0.3.0 與西洋占星引擎 0.3.0。測試會啟動 stdio 伺服器,比對 MCP 與 SDK 回傳的命盤和解讀,並涵蓋出生時辰不詳及歷史夏令時間。[測試命例](tests/smoke-stdio.ts) ## 隱私 排盤在本機 MCP 程序中執行。你選用的 AI 客戶端會收到工具輸入與結果,並依該客戶端的設定處理對話。 ## OpenFate 連結 - [OpenFate.ai](https://openfate.ai) - [免費八字排盤工具](https://openfate.ai/zh-hant/bazi-chart?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [AI 八字解讀](https://openfate.ai/zh-hant/bazi?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [八字合盤](https://openfate.ai/zh-hant/compatibility/bazi/marriage?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [真太陽時說明](https://openfate.ai/zh-hant/insights/true-solar-time?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp) - [OpenFate llms.txt](https://openfate.ai/llms.txt) ## 上架位置 | 管道 | 名稱 | 適合 | | --- | --- | --- | | [npm](https://www.npmjs.com/package/@openfate/bazi-mcp) | `@openfate/bazi-mcp` | Claude Code、Cursor、Cline 等 stdio 客戶端 | | [官方 MCP Registry](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.openfate-ai) | `io.github.openfate-ai/bazi-mcp` | 從 Registry 搜尋伺服器的客戶端 | | [GitHub Releases](https://github.com/openfate-ai/openfate-mcp/releases) | `openfate-bazi-mcp-v<版本>.mcpb` | Claude Desktop 一鍵安裝 | | [Glama](https://glama.ai/mcp/servers/openfate-ai/openfate-mcp) | `openfate-ai/openfate-mcp` | Docker 部署與伺服器目錄 | | [Agent Skill](skills/openfate-bazi) | `openfate-bazi` | Claude Skills、Claude Code、Codex 類代理 | ## 更新紀錄 | 日期 | 版本 | 內容 | | --- | --- | --- | | 2026‑12‑03 | v0.8.0 | 新增 83 條紫微判準與 36 種占星圖形,可查全部成立項目及每條依據 | | 2026‑12‑03 | v0.7.0 | 紫微和占星可逐章選讀,附規則、盤面依據和同盤連結 | | 2026‑12‑03 | v0.6.1 | 隨附兩套公開引擎,支援 npm 12 預設安裝設定 | | 2026‑12‑03 | v0.6.0 | 新增紫微本命盤、單宮三方四正、西洋本命盤與雙宮制對照 | | 2026‑12‑03 | README | 墨色封面、黑白圖版、支援深色模式 | | 2026‑12‑02 | README | 用 MCP 反查任鐵樵自記的四柱 | | 2026‑11‑24 | v0.5.0 | 新增 `read_bazi_corpus_chapter`,用樣本編號讀命盤庫章節;加入第一張盤的引導與客戶端設定 | | 2026‑11‑23 | v0.4.0 | 新增 `read_bazi_relationship`,感情解讀附規則編號與盤面依據 | | 2026‑09‑20 | v0.3.0–v0.3.1 | 秒級起運;地支關係每次出現都保留 | | 2026‑07‑01 | v0.2.4–v0.2.6 | 歷史夏令時修正穿過伺服器邊界仍正確;同步各平台版本資料 | | 2026‑06‑18 | v0.2.0–v0.2.3 | 排盤欄位擴充、桌面擴充套件(.mcpb)、自動發布到 GitHub 與 MCP Registry | | 2026‑06‑17 | v0.1.2 | 首次公開發布到 npm 與 MCP Registry | 完整紀錄見 [Releases](https://github.com/openfate-ai/openfate-mcp/releases)。 ## 開源範圍 | 在這個倉庫(MIT) | 留在 OpenFate.ai | | --- | --- | | MCP 伺服器與 16 個工具 | 付費完整報告 | | Agent Skill、桌面擴充套件與 Docker 映像 | AI 對話與問答 | | 對照公開引擎的 smoke 測試 | 帳號、點數與會員 | 三套引擎各自公開排盤約定、原始碼與可重跑的範例。[八字](https://github.com/openfate-ai/bazi-engine) · [紫微斗數](https://github.com/openfate-ai/ziwei-engine) · [西洋占星](https://github.com/openfate-ai/astrology-engine) ## 參與貢獻 歡迎提 Issue 與 Pull Request。回報排盤差異時,請附出生的民用時間、時區或 IANA 名稱、經度、換日與起運版本,以及你預期的結果。送出前請跑 `npm run build` 和 `npm run smoke`。詳見 [CONTRIBUTING.md](CONTRIBUTING.md) · [行為準則](CODE_OF_CONDUCT.md) ## 關於與聯絡 **理念** 讀者可以拿相同的出生時刻、地點與設定,自己重排一張 AI 助理交回的命盤。 **技術組成** TypeScript · Model Context Protocol SDK · stdio 傳輸 · Node.js 20+ **聯絡** 問題與錯誤回報請開 [GitHub Issue](https://github.com/openfate-ai/openfate-mcp/issues)。產品與合作請見 [OpenFate.ai](https://openfate.ai/zh-hant?utm_source=github&utm_medium=readme&utm_campaign=bazi_mcp)。 ## 授權 MIT