@xzkcz/iztro-mcp-server
Version:
MCP server exposing iztro astrology methods for Zi Wei Dou Shu astrolabe generation and horoscope analysis
34 lines • 1.41 kB
JavaScript
import { existsSync, mkdirSync, writeFileSync } from "fs";
import { join } from "path";
import { getAstroYear } from "./getAstroYear.js";
import { getCircularReplacer } from "./utils/getCircularReplacer.js";
import { hourToTimeIndex } from "./utils/hourToTimeIndex.js";
export function genAndSaveAstrolabe(options) {
const { date, hour, gender, path, fixLeap = true, locale = 'zh-CN' } = options;
// Ensure directory exists
if (!existsSync(path)) {
mkdirSync(path, { recursive: true });
}
const timeIndex = hourToTimeIndex(hour);
const result = getAstroYear({
solarBirthDate: date,
timeIndex,
gender,
fixLeap,
locale
});
const { astrolabe, decadePeriods, agePeriods, yearPeriods } = result;
// Save astrolabe.json
writeFileSync(join(path, 'astrolabe.json'), JSON.stringify(astrolabe, getCircularReplacer(), 2));
// Save decades.json
writeFileSync(join(path, 'decades.json'), JSON.stringify(decadePeriods, null, 2));
// Save ages.json
writeFileSync(join(path, 'ages.json'), JSON.stringify(agePeriods, null, 2));
// Save years.json
writeFileSync(join(path, 'years.json'), JSON.stringify(yearPeriods, null, 2));
return {
success: true,
files: ['astrolabe.json', 'decades.json', 'ages.json', 'years.json'].map(f => join(path, f))
};
}
//# sourceMappingURL=genFullAstro.js.map