Skip to main content
Glama
baranwang

mcp-tung-shing

get-tung-shing

Retrieve Chinese almanac data including solar and lunar dates, auspicious and inauspicious activities, and zodiac clashes for a date range.

Instructions

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

Input Schema

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

Implementation Reference

  • src/server.ts:35-38 (registration)
    Tool registration listing 'get-tung-shing' with description and inputSchema in ListToolsRequestSchema handler.
      name: 'get-tung-shing',
      description: '获取通胜黄历,包括公历、农历、宜忌、吉凶、冲煞等信息',
      inputSchema: zodToJsonSchema(getTungShingParamsSchema),
    },
  • Handler for 'get-tung-shing' tool call: parses input (startDate, days, includeHours, tabooFilters), iterates through days calling getDailyAlmanac(), optionally filters by taboo, and returns JSON results.
    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),
      };
  • Input schema (Zod) for 'get-tung-shing' tool: startDate (string, default today), days (number/string, default 1), includeHours (boolean, default false), tabooFilters (array of {type, value}).
    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('多个筛选宜忌事项,条件之间为或关系'),
    });
  • getDailyAlmanac() helper that generates the daily almanac data (lunar calendar, recommends, avoids, zodiac, etc.) used by the handler.
    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;
    }
  • ContentType and TabooType enums used by the handler for filtering almanac content.
    export enum ContentType {
      宜 = '宜',
      忌 = '忌',
      吉凶 = '吉凶',
      五行 = '五行',
      冲煞 = '冲煞',
      值神 = '值神',
      建除十二神 = '建除十二神',
      二十八星宿 = '二十八星宿',
      吉神宜趋 = '吉神宜趋',
      凶煞宜忌 = '凶煞宜忌',
      彭祖百忌 = '彭祖百忌',
      方位 = '方位',
    }
    
    export enum TabooType {
      宜 = 1,
      忌 = 2,
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavioral traits. It only lists the types of information included, but does not mention any side effects, data volume, performance implications, or whether it requires network access. As a read operation, it is safe, but details are minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence in Chinese, front-loading the core purpose without any superfluous words. Every word adds value, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description should explain what the returned data looks like or its structure. It only vaguely mentions types of information but does not describe the format, nesting, or example output. For a tool with 4 parameters, more detail is needed for complete understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage with descriptions for all 4 parameters. The description adds no additional meaning beyond the schema, meeting the baseline of 3. It does not explain parameter relationships or provide examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves a Tong Sheng almanac with specific content (Gregorian, lunar, auspicious/inauspicious, conflicts, etc.). It uses a specific verb '获取' (get) and resource '通胜黄历', and since there are no sibling tools, no differentiation needed.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is used when almanac data is needed, but it does not provide explicit guidance on when to use it vs alternatives (none exist) or when not to use it. Lacks context on prerequisites or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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