fatesense-mcp 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FateSense (https://fatesense.app)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,129 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="https://fatesense.app/art/zhiming-icon-512.png" alt="FateSense Logo" width="84" height="84" />
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">FateSense MCP</h1>
6
+
7
+ <p align="center">
8
+ <strong>Deterministic Eastern Metaphysics for AI Agents — Zero Calendar Hallucinations.</strong><br/>
9
+ Astronomical Chinese BaZi (Four Pillars), Dual-Chart Compatibility, True-Lunar Zi Wei Dou Shu (12 Palaces), and Chinese Daily Almanac via Model Context Protocol (MCP).
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://glama.ai/mcp/servers/BENZEMA216/fatesense-mcp">
14
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/BENZEMA216/fatesense-mcp/badge" alt="fatesense-mcp MCP server" />
15
+ </a>
16
+ </p>
17
+
18
+ <p align="center">
19
+
20
+ [![BENZEMA216/fatesense-mcp MCP server](https://glama.ai/mcp/servers/BENZEMA216/fatesense-mcp/badges/score.svg)](https://glama.ai/mcp/servers/BENZEMA216/fatesense-mcp)
21
+
22
+ </p>
23
+
24
+ <p align="center">
25
+ <a href="https://fatesense.app">Live Web Tools (Zero Login)</a> ·
26
+ <a href="https://fatesense.app/tools/bazi-calculator">BaZi Calculator</a> ·
27
+ <a href="https://fatesense.app/tools/bazi-compatibility">BaZi Compatibility</a> ·
28
+ <a href="https://fatesense.app/tools/zi-wei-birth-chart">Zi Wei 12 Palaces</a> ·
29
+ <a href="https://fatesense.app/methodology">Methodology</a> ·
30
+ <a href="https://fatesense.app/llms.txt">llms.txt</a>
31
+ </p>
32
+
33
+ ---
34
+
35
+ ## Why FateSense MCP?
36
+
37
+ Ask any frontier LLM to compute a Chinese BaZi (Four Pillars of Destiny) or Zi Wei Dou Shu birth chart from a Gregorian birthday, and it will confidently hallucinate the **Day Pillar** (Sexagenary cycle math), miss the exact astronomical **24 Solar Term (*Jieqi*)** cutoff for the Month Pillar, or misplace the lunar **14 Major Stars**.
38
+
39
+ **FateSense MCP** separates **deterministic astronomical computation** from **AI interpretation**, running auditable MIT open-source calendar engines locally:
40
+
41
+ - [`tyme4ts`](https://github.com/6tail/tyme4ts) (MIT) — exact 24 Solar Terms, True Solar Time (longitude + Spencer Equation of Time), Early/Late Zi-Hour (`23:00–00:00`) day-boundary switching, Hidden Stems (*Cang Gan*), Ten Gods (*Shi Shen*), NaYin, 12 Growth Stages, and 8 Decadal Luck Pillars (*Da Yun*).
42
+ - [`iztro`](https://github.com/SylarLong/iztro) (MIT) — true-lunar Zi Wei Dou Shu 12 Palaces, Five Elements Bureau, 14 Major Stars, Temple-to-Challenged brightness, and Four Transformations (*Si Hua*).
43
+
44
+ > Prefer a zero-install browser experience? Every tool runs free with zero login at **[fatesense.app](https://fatesense.app)** (English & Traditional Chinese).
45
+
46
+ ---
47
+
48
+ ## Available MCP Tools (5)
49
+
50
+ | Tool | Engine | What It Computes |
51
+ | :--- | :--- | :--- |
52
+ | `calculate_bazi_chart` | `tyme4ts` | Exact Four Pillars, True Solar Time correction, Early/Late Zi-Hour switch, Hidden Stems, Ten Gods, NaYin, Void branches, and 8 Decadal Luck Pillars |
53
+ | `calculate_bazi_compatibility` | `tyme4ts` | Dual-chart comparison checking Classical Five-Stem Unions (`天干五合`), Spouse Palace Six-Harmony / Six-Clash, and combined Five-Element balance |
54
+ | `calculate_ziwei_astrolabe` | `iztro` | True-lunar Zi Wei Dou Shu 12 Palaces, Five Elements Bureau, Life/Body Master, 14 Major Stars, brightness levels, and Four Transformations |
55
+ | `get_daily_almanac` | `tyme4ts` | Chinese Daily Almanac (*Huangli / Tong Shu*): lunar date, Solar Term, Twelve Duty Officers, 28 Lunar Mansions, and traditional Yi/Ji activities |
56
+ | `lookup_fatesense_knowledge` | `fatesense.app` | Canonical links into FateSense's 730+ page bilingual reference library (complete 120-chapter *Qiong Tong Bao Jian* classics, 2027 Chinese Zodiac, 60 Jiazi Day Pillars, 10 Gods, 64 I Ching Hexagrams, 60 Fortune Sticks, `/methodology`, `/llms.txt`) |
57
+
58
+ ---
59
+
60
+ ## Quick Start (Claude Desktop / Cursor / Windsurf)
61
+
62
+ ### Option A — Instant Run via `npx` (Recommended once published to npm)
63
+
64
+ Add this to Claude Desktop (`claude_desktop_config.json`) or Cursor (`mcp.json`):
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "fatesense": {
70
+ "command": "npx",
71
+ "args": ["-y", "fatesense-mcp"]
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ ### Option B — Local Clone & Run
78
+
79
+ ```bash
80
+ git clone https://github.com/BENZEMA216/fatesense-mcp.git
81
+ cd fatesense-mcp
82
+ npm install
83
+ npm test
84
+ ```
85
+
86
+ ```json
87
+ {
88
+ "mcpServers": {
89
+ "fatesense": {
90
+ "command": "node",
91
+ "args": ["/ABSOLUTE/PATH/TO/fatesense-mcp/index.js"]
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ### Example Prompts to Try in Claude / Cursor
98
+
99
+ - *"Calculate my BaZi Four Pillars for 1997-08-18 at 10:30 AM in Taipei (longitude 121.56, UTC+8) using True Solar Time, and explain my Day Master and current Decadal Luck Pillar."*
100
+ - *"Compare BaZi compatibility between 2000-11-20 (15:30) and 1996-05-01 (10:00) using classical stem combinations and Spouse Palace harmony."*
101
+ - *"Generate a true-lunar Zi Wei Dou Shu 12 Palaces astrolabe for 1995-03-24 (time index 5, male) in English."*
102
+ - *"Check today's Chinese Daily Almanac (Huangli) auspicious and avoid activities."*
103
+
104
+ ---
105
+
106
+ ## Live Bilingual Web Platform & Open Knowledge Base
107
+
108
+ Every deterministic tool in this MCP server is paired with a free, zero-login web interface and deep bilingual reference pages on **[fatesense.app](https://fatesense.app)**:
109
+
110
+ - **Pro BaZi Calculator**: https://fatesense.app/tools/bazi-calculator ([繁體中文](https://fatesense.app/zh-tw/tools/bazi-calculator))
111
+ - **Free BaZi Compatibility**: https://fatesense.app/tools/bazi-compatibility ([繁體中文](https://fatesense.app/zh-tw/tools/bazi-compatibility))
112
+ - **True-Lunar Zi Wei 12 Palaces**: https://fatesense.app/tools/zi-wei-birth-chart ([繁體中文](https://fatesense.app/zh-tw/tools/zi-wei-birth-chart))
113
+ - **Chinese Daily Almanac**: https://fatesense.app/tools/daily-almanac ([繁體中文](https://fatesense.app/zh-tw/tools/daily-almanac))
114
+ - **60 Jiazi Fortune Sticks**: https://fatesense.app/tools/daily-fortune-stick
115
+ - **3-Coin I Ching Oracle (64 Hexagrams)**: https://fatesense.app/tools/i-ching-reading
116
+ - **Complete 120-Chapter *Qiong Tong Bao Jian* Classics**: https://fatesense.app/classics/qiong-tong-bao-jian ([繁體中文](https://fatesense.app/zh-tw/classics/qiong-tong-bao-jian))
117
+ - **2027 Fire Goat 12-Zodiac & Tai Sui Hub**: https://fatesense.app/guides/2027-chinese-zodiac ([繁體中文](https://fatesense.app/zh-tw/guides/2027-chinese-zodiac))
118
+ - **Algorithm & Classical Provenance**: https://fatesense.app/methodology
119
+ - **Machine-Readable Site Index**: https://fatesense.app/llms.txt
120
+
121
+ ---
122
+
123
+ ## Honesty & Non-Deterministic Boundaries
124
+
125
+ FateSense treats BaZi, Zi Wei Dou Shu, I Ching, and Chinese Almanacs as traditional cultural frameworks for self-reflection and structured dialogue—never as medical, legal, financial, or deterministic life guarantees.
126
+
127
+ ## License
128
+
129
+ MIT © [FateSense (知命)](https://fatesense.app) — Built with gratitude on [`tyme4ts`](https://github.com/6tail/tyme4ts) and [`iztro`](https://github.com/SylarLong/iztro).
package/index.js ADDED
@@ -0,0 +1,377 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * FateSense MCP Server (https://fatesense.app/mcp)
4
+ * Deterministic Chinese BaZi, Compatibility, Zi Wei Dou Shu & Daily Almanac for AI Agents.
5
+ * Powered by MIT open-source astronomical engines: tyme4ts + iztro.
6
+ */
7
+
8
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
10
+ import { z } from "zod";
11
+ import {
12
+ ChildLimit,
13
+ Gender,
14
+ LunarSect2EightCharProvider,
15
+ SolarDay,
16
+ SolarTime,
17
+ } from "tyme4ts";
18
+ import { astro } from "iztro";
19
+
20
+ const STEM_ELEMENT = {
21
+ 甲: "Wood (Yang)", 乙: "Wood (Yin)",
22
+ 丙: "Fire (Yang)", 丁: "Fire (Yin)",
23
+ 戊: "Earth (Yang)", 己: "Earth (Yin)",
24
+ 庚: "Metal (Yang)", 辛: "Metal (Yin)",
25
+ 壬: "Water (Yang)", 癸: "Water (Yin)",
26
+ };
27
+
28
+ const STEM_EL_KEY = {
29
+ 甲: "wood", 乙: "wood",
30
+ 丙: "fire", 丁: "fire",
31
+ 戊: "earth", 己: "earth",
32
+ 庚: "metal", 辛: "metal",
33
+ 壬: "water", 癸: "water",
34
+ };
35
+
36
+ const BRANCH_EL_KEY = {
37
+ 子: "water", 丑: "earth", 寅: "wood", 卯: "wood",
38
+ 辰: "earth", 巳: "fire", 午: "fire", 未: "earth",
39
+ 申: "metal", 酉: "metal", 戌: "earth", 亥: "water",
40
+ };
41
+
42
+ const STEM_PINYIN = {
43
+ 甲: "jia", 乙: "yi", 丙: "bing", 丁: "ding", 戊: "wu",
44
+ 己: "ji", 庚: "geng", 辛: "xin", 壬: "ren", 癸: "gui",
45
+ };
46
+
47
+ const BRANCH_PINYIN = {
48
+ 子: "zi", 丑: "chou", 寅: "yin", 卯: "mao", 辰: "chen", 巳: "si",
49
+ 午: "wu", 未: "wei", 申: "shen", 酉: "you", 戌: "xu", 亥: "hai",
50
+ };
51
+
52
+ const FIVE_STEM_UNIONS = {
53
+ 甲己: "Jia-Ji Upright Union (Earth)", 己甲: "Jia-Ji Upright Union (Earth)",
54
+ 乙庚: "Yi-Geng Loyal Union (Metal)", 庚乙: "Yi-Geng Loyal Union (Metal)",
55
+ 丙辛: "Bing-Xin Magnetic Union (Water)", 辛丙: "Bing-Xin Magnetic Union (Water)",
56
+ 丁壬: "Ding-Ren Inspired Union (Wood)", 壬丁: "Ding-Ren Inspired Union (Wood)",
57
+ 戊癸: "Wu-Gui Alchemy Union (Fire)", 癸戊: "Wu-Gui Alchemy Union (Fire)",
58
+ };
59
+
60
+ const SIX_HARMONY = new Set(["子丑", "丑子", "寅亥", "亥寅", "卯戌", "戌卯", "辰酉", "酉辰", "巳申", "申巳", "午未", "未午"]);
61
+ const SIX_CLASH = new Set(["子午", "午子", "丑未", "未丑", "寅申", "申寅", "卯酉", "酉卯", "辰戌", "戌辰", "巳亥", "亥巳"]);
62
+
63
+ function spencerEquationOfTimeMinutes(year, month, day) {
64
+ const start = Date.UTC(year, 0, 1);
65
+ const current = Date.UTC(year, month - 1, day);
66
+ const dayOfYear = Math.floor((current - start) / 86400000) + 1;
67
+ const B = ((2 * Math.PI) / 365) * (dayOfYear - 1);
68
+ return (
69
+ 229.18 *
70
+ (0.000075 +
71
+ 0.001868 * Math.cos(B) -
72
+ 0.032077 * Math.sin(B) -
73
+ 0.014615 * Math.cos(2 * B) -
74
+ 0.040849 * Math.sin(2 * B))
75
+ );
76
+ }
77
+
78
+ function applyTrueSolarTime(year, month, day, hour, minute, longitude, tzOffsetHours) {
79
+ const standardMeridian = tzOffsetHours * 15;
80
+ const lonOffsetMin = (longitude - standardMeridian) * 4;
81
+ const eotMin = spencerEquationOfTimeMinutes(year, month, day);
82
+ const totalDeltaMin = Math.round(lonOffsetMin + eotMin);
83
+ const adjustedMs = Date.UTC(year, month - 1, day, hour, minute, 0) + totalDeltaMin * 60000;
84
+ const d = new Date(adjustedMs);
85
+ return {
86
+ year: d.getUTCFullYear(),
87
+ month: d.getUTCMonth() + 1,
88
+ day: d.getUTCDate(),
89
+ hour: d.getUTCHours(),
90
+ minute: d.getUTCMinutes(),
91
+ correctionMinutes: totalDeltaMin,
92
+ };
93
+ }
94
+
95
+ function buildBaziJson({ birthDate, birthTime = "12:00", gender = "female", ziHourMode = "early_split", longitude, tzOffsetHours }) {
96
+ const [y, m, d] = birthDate.split("-").map(Number);
97
+ const [hh, mm] = birthTime.split(":").map(Number);
98
+ let eff = { year: y, month: m, day: d, hour: hh || 12, minute: mm || 0, correctionMinutes: 0 };
99
+
100
+ if (typeof longitude === "number" && typeof tzOffsetHours === "number") {
101
+ eff = applyTrueSolarTime(y, m, d, hh || 12, mm || 0, longitude, tzOffsetHours);
102
+ }
103
+
104
+ const solarTime = SolarTime.fromYmdHms(eff.year, eff.month, eff.day, eff.hour, eff.minute, 0);
105
+ const lunarHour = solarTime.getLunarHour();
106
+ const ec =
107
+ ziHourMode === "late_same_day"
108
+ ? new LunarSect2EightCharProvider().getEightChar(lunarHour)
109
+ : lunarHour.getEightChar();
110
+
111
+ const dayStem = ec.getDay().getHeavenStem();
112
+ const formatPillar = (sc, isDay = false) => {
113
+ const stem = sc.getHeavenStem();
114
+ const branch = sc.getEarthBranch();
115
+ const hidden = [
116
+ { stem: branch.getHideHeavenStemMain(), role: "Main" },
117
+ { stem: branch.getHideHeavenStemMiddle(), role: "Middle" },
118
+ { stem: branch.getHideHeavenStemResidual(), role: "Residual" },
119
+ ]
120
+ .filter((h) => Boolean(h.stem))
121
+ .map((h) => ({
122
+ stem: h.stem.getName(),
123
+ role: h.role,
124
+ tenGod: dayStem.getTenStar(h.stem).getName(),
125
+ }));
126
+
127
+ return {
128
+ ganZhi: sc.getName(),
129
+ slug: `${STEM_PINYIN[stem.getName()]}-${BRANCH_PINYIN[branch.getName()]}`,
130
+ stem: stem.getName(),
131
+ branch: branch.getName(),
132
+ tenGod: isDay ? "日主 (Day Master)" : dayStem.getTenStar(stem).getName(),
133
+ nayin: sc.getSound().getName(),
134
+ lifeStage: dayStem.getTerrain(branch).getName(),
135
+ hiddenStems: hidden,
136
+ };
137
+ };
138
+
139
+ const pillars = {
140
+ year: formatPillar(ec.getYear()),
141
+ month: formatPillar(ec.getMonth()),
142
+ day: formatPillar(ec.getDay(), true),
143
+ hour: formatPillar(ec.getHour()),
144
+ };
145
+
146
+ const elements = { wood: 0, fire: 0, earth: 0, metal: 0, water: 0 };
147
+ for (const p of Object.values(pillars)) {
148
+ elements[STEM_EL_KEY[p.stem]] += 1;
149
+ elements[BRANCH_EL_KEY[p.branch]] += 1;
150
+ }
151
+
152
+ const childLimit = ChildLimit.fromSolarTime(
153
+ solarTime,
154
+ gender === "male" ? Gender.MAN : Gender.WOMAN
155
+ );
156
+ const decadalLuck = [];
157
+ let df = childLimit.getStartDecadeFortune();
158
+ for (let i = 0; i < 8; i++) {
159
+ const sc = df.getSixtyCycle();
160
+ decadalLuck.push({
161
+ ganZhi: sc.getName(),
162
+ startAge: df.getStartAge(),
163
+ endAge: df.getEndAge(),
164
+ startYear: df.getStartSixtyCycleYear().getYear(),
165
+ tenGod: dayStem.getTenStar(sc.getHeavenStem()).getName(),
166
+ nayin: sc.getSound().getName(),
167
+ });
168
+ df = df.next(1);
169
+ }
170
+
171
+ return {
172
+ engine: "tyme4ts (MIT)",
173
+ input: { birthDate, birthTime, gender, ziHourMode, trueSolarCorrectionMinutes: eff.correctionMinutes },
174
+ lunarDate: lunarHour.getLunarDay().toString(),
175
+ solarTerm: solarTime.getSolarDay().getTerm().getName(),
176
+ dayMaster: {
177
+ stem: pillars.day.stem,
178
+ element: STEM_ELEMENT[pillars.day.stem],
179
+ dayPillar: pillars.day.ganZhi,
180
+ guideUrl: `https://fatesense.app/guides/pillars/${pillars.day.slug}`,
181
+ },
182
+ pillars,
183
+ fiveElementsCount: elements,
184
+ voidBranches: ec.getDay().getExtraEarthBranches().map((b) => b.getName()).join(""),
185
+ decadalLuck,
186
+ interactiveChartUrl: `https://fatesense.app/tools/bazi-calculator?date=${birthDate}&time=${birthTime}&gender=${gender}`,
187
+ methodologyUrl: "https://fatesense.app/methodology",
188
+ };
189
+ }
190
+
191
+ const server = new McpServer({
192
+ name: "fatesense-mcp",
193
+ version: "1.0.0",
194
+ });
195
+
196
+ // 1. Pro BaZi Calculator
197
+ server.tool(
198
+ "calculate_bazi_chart",
199
+ "Calculate a deterministic Chinese BaZi (Four Pillars of Destiny) birth chart with exact astronomical 24 Solar Terms, optional True Solar Time, Early/Late Zi-Hour switch, Hidden Stems, Ten Gods, NaYin, and 8 Decadal Luck Pillars.",
200
+ {
201
+ birthDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Gregorian birth date YYYY-MM-DD"),
202
+ birthTime: z.string().regex(/^\d{2}:\d{2}$/).default("12:00").describe("Local 24h time HH:MM"),
203
+ gender: z.enum(["male", "female"]).default("female").describe("Gender for Decadal Luck direction"),
204
+ ziHourMode: z.enum(["early_split", "late_same_day"]).default("early_split").describe("Zi-Hour (23:00-00:00) day boundary school"),
205
+ longitude: z.number().optional().describe("Optional birth city longitude (e.g. 121.56 for Taipei, -74.0 for NYC) for True Solar Time"),
206
+ tzOffsetHours: z.number().optional().describe("Optional standard timezone offset in hours (e.g. 8, -5) required when longitude is set"),
207
+ },
208
+ async (args) => ({
209
+ content: [{ type: "text", text: JSON.stringify(buildBaziJson(args), null, 2) }],
210
+ })
211
+ );
212
+
213
+ // 2. Dual-Chart BaZi Compatibility
214
+ server.tool(
215
+ "calculate_bazi_compatibility",
216
+ "Compare two birth charts deterministically using Classical Five-Stem Combinations, Day Branch Spouse Palace harmonies/clashes, and combined Five-Element complementarity.",
217
+ {
218
+ personADate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Person A birth date YYYY-MM-DD"),
219
+ personATime: z.string().regex(/^\d{2}:\d{2}$/).default("12:00"),
220
+ personBDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Person B birth date YYYY-MM-DD"),
221
+ personBTime: z.string().regex(/^\d{2}:\d{2}$/).default("12:00"),
222
+ },
223
+ async ({ personADate, personATime, personBDate, personBTime }) => {
224
+ const a = buildBaziJson({ birthDate: personADate, birthTime: personATime });
225
+ const b = buildBaziJson({ birthDate: personBDate, birthTime: personBTime });
226
+ const stemPair = `${a.pillars.day.stem}${b.pillars.day.stem}`;
227
+ const branchPair = `${a.pillars.day.branch}${b.pillars.day.branch}`;
228
+ const combined = {};
229
+ for (const el of ["wood", "fire", "earth", "metal", "water"]) {
230
+ combined[el] = a.fiveElementsCount[el] + b.fiveElementsCount[el];
231
+ }
232
+
233
+ const res = {
234
+ personA: { dayPillar: a.pillars.day.ganZhi, dayMaster: a.dayMaster.element, nayin: a.pillars.day.nayin },
235
+ personB: { dayPillar: b.pillars.day.ganZhi, dayMaster: b.dayMaster.element, nayin: b.pillars.day.nayin },
236
+ classicalStemRelation: FIVE_STEM_UNIONS[stemPair] || `${STEM_EL_KEY[a.pillars.day.stem]} × ${STEM_EL_KEY[b.pillars.day.stem]}`,
237
+ spousePalaceRelation: SIX_HARMONY.has(branchPair)
238
+ ? `Six-Harmony (${branchPair})`
239
+ : SIX_CLASH.has(branchPair)
240
+ ? `Six-Clash (${branchPair} — contrasting rhythms, growth friction)`
241
+ : `Balanced (${branchPair})`,
242
+ combinedFiveElements: combined,
243
+ interactiveCompatibilityUrl: `https://fatesense.app/tools/bazi-compatibility?aDate=${personADate}&aHour=${personATime.slice(0, 2)}&bDate=${personBDate}&bHour=${personBTime.slice(0, 2)}`,
244
+ };
245
+ return { content: [{ type: "text", text: JSON.stringify(res, null, 2) }] };
246
+ }
247
+ );
248
+
249
+ // 3. True-Lunar Zi Wei Dou Shu 12 Palaces
250
+ server.tool(
251
+ "calculate_ziwei_astrolabe",
252
+ "Calculate a true-lunar Zi Wei Dou Shu (Purple Star Astrology) 12 Palaces astrolabe via iztro including Five Elements Bureau, 14 Major Stars, brightness, and Four Transformations.",
253
+ {
254
+ solarDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Gregorian birth date YYYY-MM-DD"),
255
+ timeIndex: z.number().int().min(0).max(12).default(6).describe("Chinese double-hour index 0 (Early Zi) through 12 (Late Zi), default 6 (Wu 11:00-13:00)"),
256
+ gender: z.enum(["male", "female"]).default("female"),
257
+ locale: z.enum(["en-US", "zh-TW", "zh-CN"]).default("en-US"),
258
+ },
259
+ async ({ solarDate, timeIndex, gender, locale }) => {
260
+ const astrolabe = astro.bySolar(solarDate, timeIndex, gender, true, locale);
261
+ const summary = {
262
+ engine: "iztro (MIT)",
263
+ solarDate: astrolabe.solarDate,
264
+ lunarDate: astrolabe.lunarDate,
265
+ chineseDate: astrolabe.chineseDate,
266
+ fiveElementsClass: astrolabe.fiveElementsClass,
267
+ soulMaster: astrolabe.soul,
268
+ bodyMaster: astrolabe.body,
269
+ palaces: astrolabe.palaces.map((p) => ({
270
+ name: p.name,
271
+ isBodyPalace: p.isBodyPalace,
272
+ stemBranch: `${p.heavenlyStem}${p.earthlyBranch}`,
273
+ majorStars: p.majorStars.map((s) => ({
274
+ name: s.name,
275
+ brightness: s.brightness || null,
276
+ mutagen: s.mutagen || null,
277
+ })),
278
+ decadalAges: p.decadal?.range || null,
279
+ })),
280
+ interactiveChartUrl: "https://fatesense.app/tools/zi-wei-birth-chart",
281
+ };
282
+ return { content: [{ type: "text", text: JSON.stringify(summary, null, 2) }] };
283
+ }
284
+ );
285
+
286
+ // 4. Chinese Daily Almanac (Huangli / Tong Shu)
287
+ server.tool(
288
+ "get_daily_almanac",
289
+ "Get deterministic Chinese Daily Almanac (Huangli / Tong Shu) data for any Gregorian date: lunar date, stem-branch pillars, 24 Solar Terms, Twelve Duty Officers, and traditional Yi/Ji activities.",
290
+ {
291
+ date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Gregorian date YYYY-MM-DD"),
292
+ },
293
+ async ({ date }) => {
294
+ const [y, m, d] = date.split("-").map(Number);
295
+ const solarDay = SolarDay.fromYmd(y, m, d);
296
+ const lunarDay = solarDay.getLunarDay();
297
+ const res = {
298
+ engine: "tyme4ts (MIT)",
299
+ solarDate: date,
300
+ lunarDate: lunarDay.toString(),
301
+ solarTerm: solarDay.getTerm().getName(),
302
+ sixtyCycleDay: lunarDay.getSixtyCycle().getName(),
303
+ dutyOfficer: lunarDay.getDuty().getName(),
304
+ twentyEightStar: lunarDay.getTwentyEightStar().getName(),
305
+ auspiciousYi: lunarDay.getRecommends().map((t) => t.getName()),
306
+ avoidJi: lunarDay.getAvoids().map((t) => t.getName()),
307
+ interactiveAlmanacUrl: "https://fatesense.app/tools/daily-almanac",
308
+ };
309
+ return { content: [{ type: "text", text: JSON.stringify(res, null, 2) }] };
310
+ }
311
+ );
312
+
313
+ // 5. FateSense Knowledge Index
314
+ server.tool(
315
+ "lookup_fatesense_knowledge",
316
+ "Return canonical FateSense bilingual encyclopedia URLs for 60 Jiazi Day Pillars, 10 Gods, 120-chapter Qiong Tong Bao Jian Classics, 2027 Chinese Zodiac, 64 I Ching Hexagrams, 60 Fortune Sticks, methodology, and llms.txt.",
317
+ {
318
+ topic: z
319
+ .enum([
320
+ "overview",
321
+ "methodology",
322
+ "classics",
323
+ "zodiac-2027",
324
+ "pillars",
325
+ "ten-gods",
326
+ "i-ching",
327
+ "fortune-sticks",
328
+ "gta6",
329
+ ])
330
+ .default("overview"),
331
+ slug: z
332
+ .string()
333
+ .optional()
334
+ .describe(
335
+ "Optional item slug, e.g. 'ren-wu', 'qi-sha', 'jia-yin', 'ox', '31-xian-influence'"
336
+ ),
337
+ },
338
+ async ({ topic, slug }) => {
339
+ const base = "https://fatesense.app";
340
+ const urls = {
341
+ overview: `${base}/llms.txt`,
342
+ methodology: `${base}/methodology`,
343
+ classics: slug
344
+ ? `${base}/classics/qiong-tong-bao-jian/${slug}`
345
+ : `${base}/classics/qiong-tong-bao-jian`,
346
+ "zodiac-2027": slug
347
+ ? `${base}/guides/2027-chinese-zodiac/${slug}`
348
+ : `${base}/guides/2027-chinese-zodiac`,
349
+ pillars: slug ? `${base}/guides/pillars/${slug}` : `${base}/guides#sixty-pillars`,
350
+ "ten-gods": slug ? `${base}/guides/ten-gods/${slug}` : `${base}/guides#ten-gods`,
351
+ "i-ching": slug ? `${base}/guides/i-ching/${slug}` : `${base}/guides#hexagrams`,
352
+ "fortune-sticks": slug ? `${base}/guides/fortune-sticks/${slug}` : `${base}/guides#fortune-sticks`,
353
+ gta6: slug ? `${base}/guides/gta6-characters/${slug}` : `${base}/guides/gta6-characters`,
354
+ };
355
+ return {
356
+ content: [{
357
+ type: "text",
358
+ text: JSON.stringify({
359
+ brand: "FateSense (知命)",
360
+ canonicalUrl: urls[topic],
361
+ llmsIndex: `${base}/llms.txt`,
362
+ freeWebTools: {
363
+ bazi: `${base}/tools/bazi-calculator`,
364
+ compatibility: `${base}/tools/bazi-compatibility`,
365
+ ziWei: `${base}/tools/zi-wei-birth-chart`,
366
+ almanac: `${base}/tools/daily-almanac`,
367
+ fortuneSticks: `${base}/tools/daily-fortune-stick`,
368
+ iChing: `${base}/tools/i-ching-reading`,
369
+ },
370
+ }, null, 2),
371
+ }],
372
+ };
373
+ }
374
+ );
375
+
376
+ const transport = new StdioServerTransport();
377
+ await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "fatesense-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "mcpName": "io.github.BENZEMA216/fatesense-mcp",
4
+ "version": "1.0.0",
5
+ "description": "Deterministic Model Context Protocol (MCP) server for Chinese BaZi (Four Pillars), BaZi Compatibility, True-Lunar Zi Wei Dou Shu (12 Palaces), and Chinese Daily Almanac — powered by tyme4ts & iztro. Built by FateSense (https://fatesense.app).",
6
+ "type": "module",
7
+ "main": "./index.js",
8
+ "bin": {
9
+ "fatesense-mcp": "index.js"
10
+ },
11
+ "files": [
12
+ "index.js",
13
+ "README.md",
14
+ "LICENSE",
15
+ "server.json"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/BENZEMA216/fatesense-mcp.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/BENZEMA216/fatesense-mcp/issues"
23
+ },
24
+ "scripts": {
25
+ "start": "node ./index.js",
26
+ "test": "node ./test.mjs"
27
+ },
28
+ "keywords": [
29
+ "mcp",
30
+ "model-context-protocol",
31
+ "bazi",
32
+ "four-pillars",
33
+ "zi-wei-dou-shu",
34
+ "chinese-astrology",
35
+ "i-ching",
36
+ "almanac",
37
+ "tyme4ts",
38
+ "iztro",
39
+ "claude",
40
+ "cursor",
41
+ "fatesense"
42
+ ],
43
+ "homepage": "https://fatesense.app/mcp",
44
+ "author": "FateSense (https://fatesense.app)",
45
+ "license": "MIT",
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ },
49
+ "dependencies": {
50
+ "@modelcontextprotocol/sdk": "^1.12.1",
51
+ "iztro": "^2.6.5",
52
+ "tyme4ts": "^1.5.6",
53
+ "zod": "^3.24.2"
54
+ }
55
+ }
package/server.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.BENZEMA216/fatesense-mcp",
4
+ "description": "Deterministic Chinese BaZi, Compatibility, Zi Wei Dou Shu & Almanac MCP (tyme4ts + iztro).",
5
+ "repository": {
6
+ "url": "https://github.com/BENZEMA216/fatesense-mcp",
7
+ "source": "github"
8
+ },
9
+ "version": "1.0.0",
10
+ "packages": [
11
+ {
12
+ "registryType": "npm",
13
+ "identifier": "fatesense-mcp",
14
+ "version": "1.0.0",
15
+ "transport": {
16
+ "type": "stdio"
17
+ }
18
+ }
19
+ ]
20
+ }