bazi-engine
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
@mingjing-me/bazi-engine
八字排盘事实层引擎(TypeScript) — 明镜解ME(mingjing.me)线上站同源底座。
只做「排盘事实」:四柱、藏干、十神、纳音、旬空、十二长生、神煞、胎元胎息命宫身宫、大运起运细算、六爻装卦。不做吉凶判定——强弱、格局、喜用是各家体系的分水岭,不在本库。
为什么是事实层
排盘错一点,后面全错。而排盘恰恰是命理工程里最「可验证」的部分:交节时刻、五鼠遁、六十甲子,全部有标准答案。本库把这些答案钉死成代码 + 测试,并与独立历法库(Python lunar_python)交叉对照。
Related MCP server: mcp-luopan
安装
npm install @mingjing-me/bazi-engine给 AI 用(MCP)
本库自带 MCP server,AI 客户端(Claude / Kimi / Cursor 等)可直接调用排盘:
{ "mcpServers": { "bazi-engine": { "command": "npx", "args": ["@mingjing-me/bazi-engine"] } } }5 个工具(全部只读纯计算):build_chart(阳历排盘)、build_chart_lunar(农历排盘)、reverse_lookup(排盘反查)、cast_liuyao(六爻装卦)、list_places(城市经度表)。
已登记进 MCP 官方 Registry:io.github.mingjing-me/bazi-engine。
快速上手
import { buildChart, buildChartFromLunar, reverseLookup, castLiuYao } from '@mingjing-me/bazi-engine';
// 阳历排盘
const chart = buildChart(1990, 5, 20, 14, 30, '男');
console.log(chart.pillars.year.gan + chart.pillars.year.zhi); // 庚午
console.log(chart.daYunList.map(d => d.ganZhi)); // 大运序列
// 真太阳时:给城市名或经度
const c2 = buildChart(2000, 6, 1, 12, 30, '男', { place: '乌鲁木齐' });
console.log(c2.trueSolarText); // '2000-06-01 10:22'(钟表 12:30 → 真太阳时 10:22)
// 农历入口(闰月加 leapMonth)
const c3 = buildChartFromLunar(2023, 2, 15, 8, 0, '男', { leapMonth: true });
// 排盘反查:给任意柱组合,反推阳历日期
const hits = reverseLookup({ year: '己卯', month: '丙子', day: '戊午' }, { startYear: 1999, endYear: 2001 });
console.log(hits[0].solarText); // '2000-01-01'
// 六爻装卦(事实层:世应、纳甲、六亲、六神、旬空、伏神、进退神)
const gua = castLiuYao([7, 7, 7, 9, 8, 6], '甲子', '午');口径声明(重要)
排盘的「错」大半出在口径没说清。本库口径全部写死、全部可测:
1. 晚子时(23:00–23:59)换日
默认
ziHourStyle: 'next-day':晚子时日柱按次日排,时柱随次日日干起子。作者(东森)不认「分早晚子时」——同一夜的子时跨午夜必须同柱,这是本库默认且推荐的口径。ziHourStyle: 'same-day'仅为兼容不换日流派保留,结果由调用方自行负责。
2. 交节日修正
底层历法库(lunar-javascript)的月柱/起运按「交节日 0 点」切。生在节气当天、交节时刻之前的,本库自动把月柱与大运整体退回上一节。 (锚定案:1976-11-07 立冬 14:58——当天 10:00 出生月柱戊戌,16:00 出生月柱己亥。)
3. 起运细算
顺行数到下一个节、逆行数到上一个节,三天折一年、一天折四个月(72 小时 ↔ 360 天)。节气表自动扩到前后各 40 天,年初年末出生不会落入兜底。
4. 农历闰月
buildChartFromLunar(year, month, day, ...) 遇闰月传 { leapMonth: true }(底层历法库口径:闰月内部记为负月)。闰二月十五与二月十五是两个不同的日子,本库不会混排。
5. 真太阳时
place(内置约 48 城经度表)或 longitude 直接给经度;默认叠加均时差(useEot: false 可关)。交节判断与晚子时判定都以修正后时间为准。查不到的地名会抛错,不会静默按北京时间排。
6. 排盘反查精度
反查按「交节日 0 点」口径比对年/月柱(未细分交节时刻);交节日当天的临界盘请用 buildChart 复核。非法干支(含阴阳不配的「甲丑」一类)直接抛错。
年代范围
实测 1885–2150 正常出盘(测试覆盖),且与独立历法库 lunar_python 交叉验证一致。不做「1900 前 / 2100 后不能排」的人为限制。
数据层清单(每柱)
干支、十神(干/藏干/支本气)、藏干分层(本气/中气/余气)、纳音、所在旬、本柱旬空、星运(日主十二长生)、自坐(本干十二长生)、神煞(天乙贵人/文昌/桃花/驿马/华盖/羊刃/禄神/国印/金舆/天德/月德)、空亡标注;另有胎元、胎息、命宫、身宫四件套与大运序列(起运年、十神、五行)。
测试
npm test # tsc 构建 + node --test(14 例:交节临界/双口径/真太阳时/闰月/反查/边界/象法/六爻)依赖与致谢
历法换算依赖 lunar-javascript(作者 6tail,MIT 许可)。本库在其历法能力之上做口径修正、象法数据层与工程封装。
边界声明
本库是排盘底座,不是断命程序。输出的是「盘上写着什么」,不是「这个命好不好」。判定层(强弱、格局、喜用、断语)属明镜解ME 私有体系,不开源。
作者与许可
东森(明镜解ME) · https://mingjing.me · mingjing.oss@qq.com
Apache-2.0。可自由使用(含商用);引用请注明出处。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Deterministic BaZi and Chinese metaphysics tools for AI agents: charts, divination, almanac.
Read-only Bazi, True Solar Time, and Chinese almanac tools in English and Traditional Chinese.
BaZi, Zi Wei, Qi Zheng Si Yu, divination and almanac from a deterministic engine. Pay per call.
Accurate BaZi (Four Pillars) charts with time zones, DST, True Solar Time and solar terms.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables traditional Chinese fortune-telling through BaZi (Four Pillars) analysis, including solar/lunar date conversion, Five Element balance calculations, Ten Gods deduction, and destiny interpretation for metaphysics applications.MIT
- AlicenseAqualityDmaintenanceProvides tools for Bazi (Chinese astrology) chart calculation and analysis, enabling LLMs to generate accurate birth charts, determine patterns, and answer follow-up questions based on actual calculations rather than model knowledge.2MIT
- AlicenseAqualityCmaintenanceEnables AI agents to perform Chinese metaphysics calculations including BaZi charts, Tong Shu indicators, solar terms, and more, using a verified engine with 740+ tests.88MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to compute Chinese metaphysics charts and judgements — BaZi, Zi Wei Dou Shu, Qi Zheng Si Yu, plus hexagram, Qimen and Liuyao divination, date selection, synastry and almanac lookups — returning structured, deterministic results with scores, verdicts and timing windows. Tools are billed per call via API key credits, x402 USDC payments or an OAuth account, with free repeats of identical inputs and free discovery tools for pricing, balances and birth-data parsing.MIT