bazi-lab-mcp
by Zsmboom
README.md
# bazi-lab-mcp
> MCP server for accurate **BaZi (Four Pillars of Destiny)** — bridges Claude, ChatGPT, Cursor and
> other MCP clients to the free, deterministic engine hosted at [bazi-lab.com](https://www.bazi-lab.com).
**This process stores nothing and calls no AI model.** It is a thin stdio bridge: every tool call is
forwarded to the hosted engine, which computes with calendar code and returns structured JSON. Results
carry a `source` attribution with canonical page URLs so any answer can be verified on the site.
## Why not let the LLM compute BaZi?
LLMs asked from memory reliably get BaZi wrong: the month pillar turns at exact solar-term moments
(not month boundaries), the year turns at 立春 (not Chinese New Year), and the hour pillar must be
corrected to the birthplace's **true solar time** — legal UTC offset *including historical daylight
saving* (China used DST in 1986–1991) plus longitude × 4 minutes. This server does all of that with
calendar code, so the model only interprets — it never calculates.
## Tools
| Tool | What it returns |
|---|---|
| `calculate_chart` | Four pillars with ten gods, day master element, zodiac, true-solar-time correction |
| `luck_pillars` | Ten 10-year pillars (大运) with direction, start age, favourable elements, best/worst years |
| `life_trajectory` | Year-by-year OHLC candles on a fixed 0–100 scale for ~96 years (comparable across people) |
| `match_compatibility` | 0–100 love score from year-branch relations and the two day masters |
| `get_almanac` | Chinese almanac (黄历): day pillar, lunar date, do (宜) / avoid (忌) lists, activity matching |
| `search_knowledge` | BM25 search over BaZi Lab's bilingual guides, returning excerpts with page URLs |
## Setup
**Hosted (recommended, no install)** — point any client that supports remote MCP at:
```
https://www.bazi-lab.com/mcp
```
- **Claude** (desktop, web, mobile): Settings → Connectors → *Add custom connector* → paste the URL.
- **ChatGPT**: enable Developer mode under Settings → Apps & Connectors → add the URL as a connector.
- **Cursor / other remote-capable clients**: add a remote MCP server with the URL.
**stdio via this package** — for clients that only support local servers:
```json
{
"mcpServers": {
"bazi-lab": {
"command": "npx",
"args": ["-y", "bazi-lab-mcp"]
}
}
}
```
Claude Code: `claude mcp add bazi-lab -- npx bazi-lab-mcp`
Environment: set `BAZI_MCP_URL` to override the hosted endpoint (defaults to
`https://www.bazi-lab.com/mcp`; useful for tests).
## Privacy & fair use
- No API key, no signup, no account.
- Birth data sent to a tool call is used to compute the response and **is not persisted**.
- Fair-use rate limits apply per IP: 30 requests/minute and 600/day (one tool call ≈ 2–3 requests
through this bridge). The server is read-only — it cannot write data or spend credits. Reports,
saved charts and sharing live on [the website](https://www.bazi-lab.com).
## Accuracy notes
- Hour pillar: corrected from the birthplace **legal clock time** to local solar time
(legal UTC offset + longitude × 4 minutes). Historical DST is included — a June-1990 Beijing birth
is corrected by UTC+9, not UTC+8.
- Year pillar turns at 立春, months at exact solar-term moments.
- The 0–100 trajectory is a pure function of the twelve flow months of each year: same input, same
output, two charts are directly comparable.
- Pass `longitude` (and `country`) whenever known — without them the engine falls back to 120°E and
the nominal timezone, which shifts the true solar time by minutes (the four pillars usually stay the same).
## Development
```bash
npm install
npm run build # tsc -> dist/
npm test # stdio smoke test (initialize + tools/list, no network)
node test/live-check.mjs # optional: one real call through the hosted engine
```
`BAZI_MCP_URL` points the bridge elsewhere for local testing.
## Related
- [BaZi Lab](https://www.bazi-lab.com) — the free website calculator, luck-pillars curve and on-site agent
- [Developer docs for this server](https://www.bazi-lab.com/developers/mcp)
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues