Skip to main content
Glama
baranwang

mcp-tung-shing

get-tung-shing

Retrieve Chinese Tung Shing almanac data including Gregorian and lunar dates, auspicious activities, taboos, and celestial impacts for accurate daily planning and decision-making.

Instructions

获取通胜黄历,包括公历、农历、宜忌、吉凶、冲煞等信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo要获取的连续天数
includeHoursNo是否包含时辰信息
startDateNo开始日期,格式为"YYYY-MM-DD"的字符串2025-08-18
tabooFiltersNo多个筛选宜忌事项,条件之间为或关系

Implementation Reference

  • src/server.ts:34-38 (registration)
    Tool registration defining name, description, and input schema in ListToolsRequestSchema handler.
    { name: 'get-tung-shing', description: '获取通胜黄历,包括公历、农历、宜忌、吉凶、冲煞等信息', inputSchema: zodToJsonSchema(getTungShingParamsSchema), },
  • Zod schema defining input parameters for the get-tung-shing tool: startDate, days, includeHours, tabooFilters.
    export const getTungShingParamsSchema = z.object({ startDate: z .string() .optional() .default(new Date().toISOString().split('T')[0]) .describe('开始日期,格式为"YYYY-MM-DD"的字符串'), days: z .union([ z.number().int().min(1), z .string() .regex(/^\d+$/) .transform((val) => Number.parseInt(val)), ]) .optional() .default(1) .describe('要获取的连续天数'), includeHours: z .boolean() .optional() .default(false) .describe('是否包含时辰信息'), tabooFilters: z .array(tabooFilterSchema) .optional() .describe('多个筛选宜忌事项,条件之间为或关系'), });
  • Main handler for 'get-tung-shing' tool: validates input, generates almanac for multiple days, applies optional taboo filters, returns JSON content.
    case 'get-tung-shing': { const { startDate, days, includeHours, tabooFilters = [], } = getTungShingParamsSchema.parse(request.params.arguments); const start = dayjs(startDate); if (!start.isValid()) { return { content: [ { type: 'text', text: 'Invalid date', }, ], isError: true, }; } return { content: Array.from({ length: days }, (_, i) => { const almanac = getDailyAlmanac(start.add(i, 'day'), includeHours); // 如果没有指定taboo过滤,直接返回结果 if (!tabooFilters.length) { return { type: 'text', text: JSON.stringify(almanac), }; } // 提取宜忌内容 const recommends = (almanac.当日[ContentType.宜] as string[]) || []; const avoids = (almanac.当日[ContentType.忌] as string[]) || []; // 根据tabooFilters进行过滤,条件之间为或的关系 const hasMatch = tabooFilters.some((filter) => { // 宜事项过滤 if (filter.type === TabooType.宜) { return recommends.includes(filter.value); } // 忌事项过滤 if (filter.type === TabooType.忌) { return avoids.includes(filter.value); } return false; }); if (hasMatch) { return { type: 'text', text: JSON.stringify(almanac), }; } return null; }).filter(Boolean), }; }
  • Helper function that generates the detailed Tung Shing almanac data for a specific date, including lunar info, auspicious/inauspicious activities, optionally with hourly breakdowns.
    export function getDailyAlmanac( date: dayjs.Dayjs, includeHours = false, ): DailyAlmanac { const parsedDate = dayjs(date); if (!parsedDate.isValid()) { throw new Error('Invalid date'); } const lunarDay = parsedDate.toLunarDay(); const solarDay = lunarDay.getSolarDay(); const sixtyCycle = lunarDay.getSixtyCycle(); const earthBranch = sixtyCycle.getEarthBranch(); const twentyEightStar = lunarDay.getTwentyEightStar(); const gods = lunarDay.getGods().reduce( (acc, god) => { const category = god.getLuck().getName() === '吉' ? 'auspicious' : 'inauspicious'; acc[category].push(god.getName()); return acc; }, { auspicious: [] as string[], inauspicious: [] as string[] }, ); const result: DailyAlmanac = { 公历: parsedDate.locale('zh-cn').format('YYYY 年 M 月 D日(ddd)'), 农历: parsedDate.format('LY年LMLD'), 节日: lunarDay.getFestival()?.getName(), 节气: solarDay.getTermDay().toString(), 七十二候: solarDay.getPhenologyDay().toString(), 当日: { [ContentType.宜]: lunarDay.getRecommends().map((item) => item.getName()), [ContentType.忌]: lunarDay.getAvoids().map((item) => item.getName()), [ContentType.吉凶]: lunarDay .getTwelveStar() .getEcliptic() .getLuck() .toString(), [ContentType.五行]: sixtyCycle.getSound().toString(), [ContentType.冲煞]: `冲${earthBranch.getOpposite().getZodiac()}煞${earthBranch.getOminous()}`, [ContentType.值神]: lunarDay.getTwelveStar().toString(), [ContentType.建除十二神]: lunarDay.getDuty().toString(), [ContentType.二十八星宿]: `${twentyEightStar}${twentyEightStar.getSevenStar()}${twentyEightStar.getAnimal()}(${twentyEightStar.getLuck()})`, [ContentType.吉神宜趋]: gods.auspicious, [ContentType.凶煞宜忌]: gods.inauspicious, [ContentType.彭祖百忌]: `${sixtyCycle.getHeavenStem().getPengZuHeavenStem()} ${earthBranch.getPengZuEarthBranch()}`, }, }; if (includeHours) { result.分时 = {}; for (let i = 0; i < 12; i++) { const hour = parsedDate.addLunar(i, 'dual-hour'); result.分时[hour.format('LH')] = getHourlyAlmanac(hour); } } return result; }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baranwang/mcp-tung-shing'

If you have feedback or need assistance with the MCP directory API, please join our Discord server