Skip to main content
Glama
shunshi-ai

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: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Powered by Shunshi.AI](https://img.shields.io/badge/powered%20by-Shunshi.AI-purple)](https://shunshi.ai)
[![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](#)

> ๐Ÿ‡ฏ๐Ÿ‡ต **ๆ—ฅๆœฌใฎ้–‹็™บ่€…ใฎๆ–นใธ**: ใ“ใ‚Œใฏไธญๅ›ฝใฎใ€Œๅ…ซๅญ— (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