Skip to main content
Glama
README.md
<div align="center">

# Xuanqing MCP (`xuanqing-mcp`)

### Verifiable BaZi & Ziwei Dou Shu MCP Server, Agent Skill, Classical Provenance Auditor & Ink Poster Generator

**Zero Charting Hallucination × Zero Fabricated Citations**

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

[![CI](https://github.com/bobobo2026/xuanqing-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/bobobo2026/xuanqing-mcp/actions/workflows/ci.yml)
[![Code License: MIT](https://img.shields.io/badge/Code-MIT-2D6A4F.svg)](LICENSE)
[![Data License: CC BY-SA 4.0](https://img.shields.io/badge/Classical%20Excerpts-CC%20BY--SA%204.0-B08946.svg)](LICENSE-DATA.md)
[![Node >= 22](https://img.shields.io/badge/Node-%3E%3D22-1B1917.svg)](package.json)

[**Live Interactive Playground ↗**](https://bobobo2026.github.io/xuanqing-mcp/) · [**Try Full Web App (DaoKeDao 道可道) ↗**](https://spacebit.qzz.io/dao/guide) · [**Auditable Corpus & Benchmark ↗**](https://github.com/bobobo2026/xuanqing-tianji-knowledge) · [**Book Distillation Framework ↗**](https://github.com/bobobo2026/evidence-distill)

</div>

---

Most AI astrology MCP servers and skills solve **charting hallucination** (stopping LLMs from miscalculating pillars or stars), yet still let models **fabricate classical book quotes**, **confuse branch interactions** (e.g. calling *Zi-Mao* a "Harm" when it is a "Punishment"), and **flatten disagreeing schools into one dogmatic verdict**.

**`xuanqing-mcp`** adds the missing second line of defense:

1. **Deterministic Dual-Engine Charting + True Solar Time Cross-Shichen Guard** (`@openfate/bazi-engine` + `@openfate/true-solar-time` + `iztro`), issuing stable `fact_id` registries and `SHA-256` hashes.
2. **Classical Claim Verifier** backed by **278 CC BY-SA 4.0 Chinese Wikisource short excerpts** across 8 classical volumes (*Yuanhai Ziping*, *Sanming Tonghui*, *Ditian Sui Chanwei*, *Ziwei Doushu Quanshu*) + **13 audited deterministic reference tables**.
3. **4-Tier Anti-Hallucination Reading Auditor** (`fact` / `source` / `interpretation` / `uncertain`) that rejects fabricated `entry_id`s and downgrades unverified or example-generalized claims.
4. **New-Chinese Ink-Gold HTML/SVG Poster Generator** (`render_chart_poster`) with an inline SVG Four-Pillar Branch Relation Field and traditional 12-Palace Ziwei grid.

<p align="center">
  <img src="docs/assets/playground-preview.png" alt="Xuanqing MCP Interactive Playground & Claim Verifier" width="88%" />
</p>

<details>
<summary><b>Preview: Self-contained New-Chinese Ink-Gold Dual Chart &amp; Relation Field Poster (click to expand)</b></summary>
<p align="center">
  <img src="docs/assets/ink-poster-preview.png" alt="Xuanqing Ink-Gold BaZi & Ziwei Chart Poster" width="82%" />
</p>
</details>

---

## 30-Second Quickstart

### 1. MCP Server (Claude Desktop / Cursor / Windsurf / Cline)

Add to your MCP config (`claude_desktop_config.json`, `.cursor/mcp.json`, etc.):

```json
{
  "mcpServers": {
    "xuanqing": {
      "command": "npx",
      "args": ["-y", "github:bobobo2026/xuanqing-mcp"]
    }
  }
}
```

### 2. Agent Skill (Claude Code / OpenClaw / TypingMind / Codex)

```bash
npx skills add https://github.com/bobobo2026/xuanqing-mcp --skill xuanqing-fate
```

Or copy [`skills/xuanqing-fate/SKILL.md`](skills/xuanqing-fate/SKILL.md) into your agent's `skills/` directory.

### 3. CLI (Zero-Setup Terminal Check)

```bash
# Intercept a false branch-relation claim (Zi-Mao is Punishment, not Harm!)
npx -y github:bobobo2026/xuanqing-mcp verify "子卯害"

# Inspect cross-classic disagreement (Sanming Tonghui vs Ditian Sui on Storage Clash)
npx -y github:bobobo2026/xuanqing-mcp verify "墓库开库"

# Cast BaZi with True Solar Time cross-shichen detection (Urumqi 87.62°E)
npx -y github:bobobo2026/xuanqing-mcp bazi --date 1990-05-15 --time 14:30 --gender male --city 乌鲁木齐

# Render a self-contained New-Chinese Ink-Gold Dual Chart Poster
npx -y github:bobobo2026/xuanqing-mcp poster --date 1995-08-22 --time 09:15 --gender female --city 北京 --mode dual --out poster.html
```

---

## Why Xuanqing? (Landscape Comparison)

| Capability | Raw LLM | Typical BaZi/Ziwei MCP or Skill | **`xuanqing-mcp`** |
|---|---|---|---|
| BaZi + Ziwei Dual Deterministic Engines | Mental math (frequent errors) | Single or dual engine | **Dual (`@openfate/bazi-engine` + `iztro`) + `facts_sha256`** |
| True Solar Time Cross-Shichen Alert | None | Silent override or ignored | **Explicit cross-shichen / cross-day boundary warning** |
| Branch-Relation Trap Interception (`子卯害`) | Often agrees with user | Not checked | **Intercepted deterministically against truth tables** |
| Classical Provenance (Wikisource URL + SHA-256) | Fabricates quotes | Uncited summary prompts | **278 CC BY-SA 4.0 excerpts (8 volumes) with permalinks** |
| Cross-Classic Disagreement Preservation | Flattens into one voice | Single-school prompt | **Side-by-side conflicts (e.g. *Sanming* vs *Ditian Sui*)** |
| Automated 4-Tier Reading Audit Validator | None | None | **`fact` / `source` / `interpretation` / `uncertain` gate** |
| Offline Ink-Gold Relation Field + 12-Palace Poster | Text only | Basic HTML | **Zero-CDN SVG Relation Arcs + 12-Palace Grid (`--no-branding`)** |
| Copyright & Privacy Boundary | N/A | Often scrapes copyrighted courses | **Strict Fail-Closed Allowlist (MIT code + CC BY-SA 4.0 data)** |

---

## MCP Tools, Resources & Prompts

| Tool | Purpose |
|---|---|
| `cast_bazi_chart` | Deterministic Four Pillars, True Solar Time check, hidden stems, Ten Gods, NaYin, 12 Growth Stages, branch interactions (presence-only), core ShenSha, DaYun, `fact_registry`, `facts_sha256` |
| `cast_ziwei_chart` | Deterministic 12-Palace Ziwei astrolabe (`iztro@2.6.0`), True Solar Time cross-shichen boundary check, natal SiHua (四化), decadal cycles, `fact_registry`, `facts_sha256` |
| `cross_verify_charts` | Casts both BaZi & Ziwei, checks cross-engine True Solar Time consistency, aligns DaYun vs DaXian on a shared age/year timeline without conflating traditions |
| `verify_classical_claim` | Fact-checks claims against 13 deterministic tables, reviewed cross-classic conflicts, and 278 CC BY-SA 4.0 excerpts; explicitly returns `unverified_in_public_corpus` when unsupported |
| `audit_reading_response` | Audits AI reading drafts against `valid_fact_ids` & `valid_entry_ids`, blocks fabricated citations, downgrades `background_only` / example-only / high-risk absolute claims |
| `render_chart_poster` | Generates a self-contained New-Chinese Ink-Gold HTML/SVG chart & branch relation field poster (`mode: dual | bazi | ziwei`, supports `no_branding: true`) |

Also exposes MCP Resources (`xuanqing://corpus/overview`, `xuanqing://reference-tables/index`) and Prompt (`verifiable_dual_reading`).

---

## Xuanqing Open-Source Ecosystem

- **[`xuanqing-mcp`](https://github.com/bobobo2026/xuanqing-mcp)** *(this repo)* — Verifiable BaZi & Ziwei MCP Server, Agent Skill & Ink Poster Generator.
- **[`xuanqing-tianji-knowledge`](https://github.com/bobobo2026/xuanqing-tianji-knowledge)** — Dual-System CC BY-SA 4.0 Auditable Classical Corpus + **`Fate-Hallucination-Bench` v1.0** (60-question anti-hallucination benchmark for LLMs).
- **[`evidence-distill`](https://github.com/bobobo2026/evidence-distill)** — Domain-agnostic **Audit-Grade Book & Long-Corpus Distillation Framework** for AI Agents (Prompt-Injection Firewall, Multi-School Isolation, Zero-Weight Dedup, Release Gates & Incremental Concept Dossiers).
- **[DaoKeDao (道可道) Web App](https://spacebit.qzz.io/dao/guide)** — Looking for a zero-setup mobile/web experience with persistent multi-chart archives, interactive concept atlas, and deep topic QA? Try DaoKeDao online.

---

## Licenses & Research Boundary

- **Code**: [MIT License](LICENSE).
- **Bundled Classical Excerpts (`data/*.jsonl`)**: [CC BY-SA 4.0](LICENSE-DATA.md) derived from Chinese Wikisource (`<= 180` Unicode code points per excerpt, `full_text_included: false`). Zero proprietary course transcripts, personal birth archives, or unverified web articles are included.
- **Boundary**: Provided strictly for traditional cultural research, deterministic calendar computation, and AI hallucination auditing. Not medical, legal, financial, or scientific prediction advice.