Skip to main content
Glama
bazi-true-solar-mcp

bazi-true-solar-mcp

README.md
# bazi-true-solar-mcp

[English](README.md) | [简体中文](README.zh-CN.md) | [繁體中文](README.zh-TW.md)

Zero-dependency **True Solar Time (真太阳时)**, **Chinese BaZi Four Pillars (八字排盘)**, **Day Master Synastry**, **Annual Transit**, and **Guanyin 100 Oracle Lots** library + **MCP & A2A server**.

Built and maintained by **[Wish by Wish (所愿)](https://mywishbywish.com)** — a modern bilingual Eastern metaphysics platform.

---

## Why True Solar Time & Deterministic BaZi Matter

Standard time zones use a single reference meridian (e.g. `120°E` across all of China), and many regions observe historical Daylight Saving Time (including mainland China 1986–1991, US, Europe, and Australia). LLMs frequently hallucinate solar math and Chinese stem-branch calendars; this package provides **100% deterministic, zero-dependency calculations** for AI agents and web apps.

Try the interactive web tools online:
- **[True Solar Time Calculator (450+ Cities)](https://mywishbywish.com/en/tools/true-solar-time)** | **[真太阳时换算器](https://mywishbywish.com/zh/tools/true-solar-time)**
- **[Free BaZi Four Pillars Chart](https://mywishbywish.com/en/bazi)** | **[免费八字排盘](https://mywishbywish.com/zh/bazi)**
- **[60 JiaZi Day Pillars & 10 Day Masters Almanac](https://mywishbywish.com/en/almanac)** | **[六十甲子与十天干图鉴](https://mywishbywish.com/zh/almanac)**
- **[55 Day Master Compatibility Pairings](https://mywishbywish.com/en/almanac/compatibility)** | **[55 组日主合盘对照](https://mywishbywish.com/zh/almanac/compatibility)**
- **[100 Guanyin Oracle Lots (Kau Cim)](https://mywishbywish.com/en/oracle/lots)** | **[观音百签全解](https://mywishbywish.com/zh/oracle/lots)**

---

## 6 Built-In MCP Tools

1. **`calculate_true_solar_time`** — Calibrates civil clock birth time to astronomical True Solar Time (`dayOffset`, Shichen branch, longitude offset, Equation of Time, historical DST).
2. **`calculate_bazi_chart`** — Computes full Four Pillars (or Three Pillars when birth hour is unknown), Ten Gods, Five-Element counts, missing elements, and optional True Solar Time calibration.
3. **`lookup_day_master_compatibility`** — Evaluates Heavenly Stem Five Combinations (天干五合) & Five-Element synastry between any two Day Masters.
4. **`analyze_annual_transit`** — Computes annual BaZi transit (流年运势, e.g. 2026 Bing-Wu / 2027 Ding-Wei) and Ten God dynamics for any Day Master.
5. **`lookup_birth_year_pillar`** — Resolves any birth year (1900–2100) into GanZhi, Five Element, Zodiac animal, NaYin, and 2027 Tai Sui status.
6. **`draw_guanyin_lot`** — Draws a random Guanyin 100 Oracle Lot (观音灵签 / Kau Cim) or looks up lot `1–100` with authentic Chinese poem, grade, and bilingual meaning.

---

## Option 1: Local Stdio MCP (Claude Desktop / Cursor / Windsurf)

Add to `claude_desktop_config.json` or `.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "bazi-true-solar": {
      "command": "npx",
      "args": ["-y", "github:buttonsprite/bazi-true-solar-mcp"]
    }
  }
}
```

## Option 2: Zero-Install Remote MCP & A2A (Agent-to-Agent)

External AI agents and apps can call our hosted zero-LLM deterministic endpoints directly over HTTPS:

- **Remote Streamable HTTP MCP**: `https://mywishbywish.com/api/mcp`
- **Google A2A Agent Card**: `https://mywishbywish.com/.well-known/agent.json`
- **Google A2A JSON-RPC Endpoint**: `https://mywishbywish.com/api/a2a`

Example Remote MCP call:
```bash
curl -X POST https://mywishbywish.com/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"calculate_bazi_chart","arguments":{"birthDate":"1963-02-17","birthTime":"12:00"}}}'
```

---

## Programmatic JavaScript / Node.js Usage

```bash
npm install github:buttonsprite/bazi-true-solar-mcp
```

```js
import {
  calculateTrueSolarTime,
  calculateBaziChart,
  lookupDayMasterCompatibility,
  analyzeAnnualTransit,
  lookupBirthYearPillar,
  drawGuanyinLot,
} from 'bazi-true-solar-mcp';

const chart = calculateBaziChart({
  birthDate: '1990-07-15',
  birthTime: '13:30',
  longitude: 104.0668,
  utcOffsetHours: 8,
  timezone: 'Asia/Shanghai',
});
console.log(chart.pillars.day.ganZhi, chart.pillars.hour.ganZhi);

const lot = drawGuanyinLot({ lotNumber: 1 });
console.log(lot.titleEn, lot.gradeEn);
```

## Development & Tests

```bash
npm test
```

## License

MIT © [Wish by Wish](https://mywishbywish.com)