shunshi-bazi-mcp
by shunshi-ai
README.md
# bazi-reader-mcp
> ๐จ๐ณ **ไธญๅฝๅ
ซๅญ (Four Pillars of Destiny)** ใป ๐ฏ๐ต **ๅๆฑๆจๅฝ (ใใกใ
ใใใใใ)** ใป ๐ฐ๐ท **์ฌ์ฃผํ์ (ๅๆฑๅ
ซๅญ)**
>
> The calculation engine (and MCP server) behind [Shunshi.AI](https://shunshi.ai) / ้กบๆถ, open-sourced.
[](LICENSE)
[](https://shunshi.ai)
[](#)
> ๐ฏ๐ต **ๆฅๆฌใฎ้็บ่
ใฎๆนใธ**: ใใใฏไธญๅฝใฎใๅ
ซๅญ (bฤzรฌ)ใโ ๆฅๆฌใง่จใ **ๅๆฑๆจๅฝ** ใฎ่จ็ฎใจใณใธใณ + MCP ใตใผใใผใงใใ็ๅนดๆๆฅใปๅบ็ๆๅปใปๅบ็ๅฐใใๅๆฑ / ๅ็ฅ / ๅคง้ / ไบ่กใใฉใณในใ่จ็ฎใงใใพใใ**็ๅคช้ฝๆ๏ผๅๆๅทฎ๏ผ่ฃๆญฃใซใๅฏพๅฟ**ใใฆใใใAI ใจใผใธใงใณใ (Claude / Cursor / Cline ใชใฉ) ใใ็ดๆฅๅผใณๅบใใพใใ
>
> ๐ฐ๐ท **ํ๊ตญ ๊ฐ๋ฐ์๋ถ๋ค๊ป**: ์ค๊ตญ์ "ๅ
ซๅญ (bฤzรฌ)" โ ํ๊ตญ์์๋ **์ฌ์ฃผํ์**๋ผ๊ณ ๋ถ๋ฅด๋ ๋ช
๋ฆฌํ์ ๊ณ์ฐ ์์ง + MCP ์๋ฒ์
๋๋ค. ์๋
์์ผยท์ถ์์๊ฐยท์ถ์์ง๋ก๋ถํฐ ์ฌ์ฃผ / ์ญ์ฑ / ๋์ด / ์คํ ๊ท ํ์ ๊ณ์ฐํฉ๋๋ค. **์งํ์์ ๋ณด์ **๋ ์ง์ํ๋ฉฐ, AI ์์ด์ ํธ (Claude / Cursor / Cline ๋ฑ) ์์ ๋ฐ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค.
---
## This repository is a monorepo with two published npm packages:
| Package | What it is | Install |
|---|---|---|
| **[`shunshi-bazi-core`](./packages/bazi-core)** | Pure TypeScript calculation library. Zero framework deps. Use it from any Node.js / browser app. | `npm install shunshi-bazi-core` |
| **[`shunshi-bazi-mcp`](./packages/bazi-mcp)** | Thin [Model Context Protocol](https://modelcontextprotocol.io/) server wrapping the core library. Drop-in tool for Claude Desktop / Cursor / Cline / any MCP client. | `npx -y shunshi-bazi-mcp` |
Both packages share the **same calculation engine** that powers [Shunshi.AI](https://shunshi.ai)'s production backend. Both are parity-tested on every release.
---
## Why this exists
Most existing open-source Bazi libraries (in any language) have at least one of these problems:
1. **No true solar time correction.** Clock time gets used as-is, which gives wrong charts for births far from the timezone's standard meridian (ๆฐ็ / ้ป้พๆฑ / the U.S. West Coast / ๅๆตท้). A 30-minute error shifts the whole hour pillar.
2. **Inconsistent ๅญๆถ handling.** Some libraries put 23:00-23:59 in "yesterday's" day pillar, others in "tomorrow's". If you don't pick, your charts disagree with professional reference tools.
3. **No parity baseline.** You compute a chart locally, compare against a paid service, get different numbers, and have no way to tell who's right.
4. **Raw data only, no multilingual context.** Output is Chinese-centric, hard to wire into JP/KR/EN AI assistants.
`shunshi-bazi-core` + `shunshi-bazi-mcp` fix all four:
- โ
**True solar time built-in**, default on (just pass `city` or `longitude/latitude`).
- โ
**Default `sect=1`** (23:00 = tomorrow's day pillar), matching [้ฎ็ๅ
ซๅญ](https://www.buyaolian.cn/).
- โ
**Parity-tested** against Shunshi.AI's Python backend (5/5 golden cases) **and** `cantian-tymext`'s `calculateRelation()` (5/5 on ๅๅฒๅไผ pair-wise subset).
- โ
**Multilingual discoverability** via keywords (bazi / ๅ
ซๅญ / ๅๆฑๆจๅฝ / ์ฌ์ฃผํ์ / saju / shichu-suimei) so JP/KR/EN developers can find the package.
---
## Quick start
### If you're embedding Bazi calc in your own app
```bash
npm install shunshi-bazi-core
```
```typescript
import { getBaziChart } from 'shunshi-bazi-core';
const chart = getBaziChart({
year: 1990, month: 3, day: 24, hour: 10, minute: 28,
gender: 1, // 0 = ๅฅณ, 1 = ็ท
city: 'ๅนฟๅท', // triggers true solar time correction
});
console.log(chart.ๅ
ซๅญ.ๅๆฑ); // "ๅบๅ ๅทฑๅฏ ๆๅญ ไธๅทณ"
console.log(chart.็ๅคช้ณๆถ?.ไฟฎๆญฃๅ้); // -33.85 (minutes of correction applied)
```
โ Full API and output reference: [`packages/bazi-core/README.md`](./packages/bazi-core/README.md)
### If you want Claude / Cursor / Cline to compute Bazi charts
Add this to your MCP config (e.g. `claude_desktop_config.json`):
```jsonc
{
"mcpServers": {
"shunshi-bazi": {
"command": "npx",
"args": ["-y", "shunshi-bazi-mcp"]
}
}
}
```
Then restart the client and ask your AI agent in natural language:
> *"ๅธฎๆ็ฎไธไธ 1990 ๅนด 3 ๆ 24 ๆฅ ไธๅ 10 ็น 28 ๅๅบ็ๅจๅนฟๅท็็ท็็ๅ
ซๅญใ"*
The server exposes two tools:
- **`getBaziChart`** โ full Bazi (Four Pillars) chart with true-solar-time correction, ๅคง่ฟ, ๅๅฒๅไผ, ็ฅ็
.
- **`getHuangli`** โ ้ปๅ (่้ปๅ / Chinese almanac) for any day: ๅฎ/ๅฟ, ๅฝญ็ฅ็พๅฟ, ็ฅ็
, ๅปบ้ค, ไบๅๅ
ซๅฎฟ, ๅ็ฅๆนไฝ, 12 ๆถ่พฐๅฎๅฟ. Accepts ๅ
ฌๅ or ๅๅ input; omit the date for today.
> *"ไปๅคฉ็้ปๅๅฎๅฟๆฏไปไน๏ผ"*
โ Full MCP tool docs, alternate client configs, troubleshooting: [`packages/bazi-mcp/README.md`](./packages/bazi-mcp/README.md)
---
## Repository layout
```
bazi-reader-mcp/
โโโ package.json # npm workspace root (private)
โโโ tsconfig.base.json # shared TypeScript config
โโโ LICENSE # MIT
โโโ README.md # you are here
โโโ packages/
โโโ bazi-core/ # โ publishes as "shunshi-bazi-core"
โ โโโ src/
โ โ โโโ index.ts
โ โ โโโ lib/{bazi,relations,shensha,solarTime,cityCache}.ts
โ โโโ tests/{parity,relations-vs-cantian,smoke}.ts
โ โโโ package.json
โ โโโ README.md
โโโ bazi-mcp/ # โ publishes as "shunshi-bazi-mcp"
โโโ src/{mcp,stdio}.ts
โโโ tests/smoke-stdio.ts
โโโ package.json
โโโ README.md
```
---
## Development
```bash
# install deps for both packages
npm install
# build both packages
npm run build
# run bazi-core tests (parity + relations-vs-cantian)
npm test
# run the MCP server locally via tsx (no build required)
npm run dev:mcp
# stdio smoke test for the MCP (spawns the built dist/stdio.js)
cd packages/bazi-mcp && npm run smoke
```
### Test coverage
- **`packages/bazi-core/tests/parity.test.ts`** โ 5 golden cases hand-labeled from screenshots of [้ฎ็ๅ
ซๅญ](https://www.buyaolian.cn/), cross-checked against Shunshi.AI's Python backend on ๅๆฑ / ๅ็ฅ / ็ฉบไบก / ็บณ้ณ / ่ๅนฒ.
- **`packages/bazi-core/tests/relations-vs-cantian.test.ts`** โ 5/5 match vs `cantian-tymext`'s `calculateRelation()` on ๅๅฒๅไผ (pair-wise subset: ๅ / ๅฒ / ๅ / ๅฎณ / ็ ด / ๅ
).
- **`packages/bazi-mcp/tests/smoke-stdio.ts`** โ End-to-end stdio handshake + `tools/list` + `tools/call`, asserts the real `ๅๆฑ` output and the `ๆฐๆฎๆฅๆบ` attribution block. Uses the real MCP SDK client so it exercises the exact same code path as Claude Desktop.
---
## Related projects
- **[`tyme4ts`](https://github.com/6tail/tyme4ts)** by 6tail โ the TypeScript lunar/solar calendar primitives this library builds on.
- **[`cantian-ai/bazi-mcp`](https://github.com/cantian-ai/bazi-mcp)** โ pioneering open-source Bazi MCP. We use their `cantian-tymext` as a dev dependency for relations parity testing. The two MCPs are **complementary, not competing** โ we made different defaults (sect=1, true solar time on by default) based on what matches professional practice in the Chinese-speaking world.
---
## About Shunshi.AI
๐ **Website**: [https://shunshi.ai](https://shunshi.ai)
๐ฆ **X / Twitter**: [@shunshiai2026](https://x.com/shunshiai2026)
๐ **Product Hunt**: [Shunshi.AI](https://www.producthunt.com/products/shunshi-ai)
[Shunshi.AI (้กบๆถ)](https://shunshi.ai) is an AI-powered Bazi reading platform supporting English, ไธญๆ, ๆฅๆฌ่ช, and ํ๊ตญ์ด. Free to try, no credit card required.
We open-sourced the calculation engine behind our production backend so:
- Any developer can compute Bazi charts with the same accuracy as our paid product.
- The ็ๅคช้ณๆถ / ๅญๆถ edge cases get solved once and for all, instead of each project getting them wrong in a slightly different way.
- JP/KR/EN developers finally have a TypeScript library that speaks their terminology (ๅๆฑๆจๅฝ / ์ฌ์ฃผํ์).
---
## License
[MIT](LICENSE) ยฉ 2026 [Shunshi.AI](https://shunshi.ai)
TDQS
A4.6/5.0
Scored across 1 tool
Disambiguation5/5
Only one tool exists, so no possibility of confusion between tools.
Naming Consistency5/5
With a single tool, naming is inherently consistent.
Tool Count4/5
A single tool is appropriate for a focused server that computes a full Bazi chart, but slightly thin if additional related functionalities were expected.
Completeness4/5
The tool provides comprehensive Bazi chart computation (ๅๆฑ, ๅ็ฅ, ๅคง่ฟ, etc.), covering the core domain. Minor gaps like chart interpretation are not strictly necessary.
Maintenance
ActivityInactive
ResponsivenessUnresponsive