Skip to main content
Glama
lis186

Taiwan Holiday MCP Server

by lis186

get_holiday_stats

Retrieve Taiwan holiday statistics for a specific year or month to analyze holiday distribution and plan schedules effectively.

Instructions

獲取指定年份或年月的台灣假期統計資訊

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes要查詢的年份
monthNo要查詢的月份(可選),1-12

Implementation Reference

  • Core handler function that implements the get_holiday_stats tool logic: fetches holidays for the specified year, optionally filters by month, validates input, and delegates to calculateStats.
    async getHolidayStats(year: number, month?: number): Promise<HolidayStats> {
      const holidays = await this.getHolidaysForYear(year);
      
      let filteredHolidays = holidays;
      
      // 如果指定月份,進行篩選
      if (month !== undefined) {
        if (month < 1 || month > 12) {
          throw new HolidayServiceError(
            `無效的月份: ${month},月份必須在 1-12 之間`,
            ErrorType.INVALID_MONTH
          );
        }
        
        const monthStr = month.toString().padStart(2, '0');
        filteredHolidays = holidays.filter(holiday => {
          const holidayMonth = holiday.date.substring(4, 6);
          return holidayMonth === monthStr;
        });
      }
    
      return this.calculateStats(year, filteredHolidays);
    }
  • MCP server handler for the get_holiday_stats tool: validates arguments, calls HolidayService.getHolidayStats, and formats the JSON response.
    private async handleGetHolidayStats(args: any) {
      const { year, month } = args;
      
      if (!year || typeof year !== 'number') {
        throw new Error('缺少必要參數:year');
      }
    
      const stats = await this.holidayService.getHolidayStats(year, month);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              data: {
                year: year,
                month: month,
                statistics: stats,
                summary: month 
                  ? `${year} 年 ${month} 月共有 ${stats.totalHolidays} 個假期`
                  : `${year} 年共有 ${stats.totalHolidays} 個假期`
              },
              timestamp: new Date().toISOString(),
              tool: 'get_holiday_stats'
            }, null, 2),
          },
        ],
      };
    }
  • src/server.ts:112-134 (registration)
    Tool registration in ListToolsRequestSchema handler: defines name, description, and input schema for get_holiday_stats.
    {
      name: 'get_holiday_stats',
      description: '獲取指定年份或年月的台灣假期統計資訊',
      inputSchema: {
        type: 'object',
        properties: {
          year: {
            type: 'integer',
            description: '要查詢的年份',
            minimum: 2017,
            maximum: 2026
          },
          month: {
            type: 'integer',
            description: '要查詢的月份(可選),1-12',
            minimum: 1,
            maximum: 12
          }
        },
        required: ['year'],
        additionalProperties: false,
      },
    } as Tool,
  • Type definition for HolidayStats, the return type of the get_holiday_stats tool.
    export interface HolidayStats {
      /** 年份 */
      year: number;
      /** 總假日天數 */
      totalHolidays: number;
      /** 國定假日天數 */
      nationalHolidays: number;
      /** 補假天數 */
      compensatoryDays: number;
      /** 調整放假天數 */
      adjustedHolidays: number;
      /** 補班天數 */
      workingDays: number;
      /** 假日類型分布 */
      holidayTypes: Record<string, number>;
    }
  • Helper function that processes holiday data to compute detailed statistics by type and category.
    private calculateStats(year: number, holidays: Holiday[]): HolidayStats {
      const holidayTypes: Record<string, number> = {};
      let totalHolidays = 0;
      let nationalHolidays = 0;
      let compensatoryDays = 0;
      let adjustedHolidays = 0;
      let workingDays = 0;
    
      for (const holiday of holidays) {
        if (holiday.isHoliday) {
          totalHolidays++;
          
          // 分析假日類型
          const description = holiday.description.toLowerCase();
          
          if (description.includes('補假')) {
            compensatoryDays++;
            holidayTypes[HOLIDAY_TYPES.COMPENSATORY] = (holidayTypes[HOLIDAY_TYPES.COMPENSATORY] || 0) + 1;
          } else if (description.includes('調整放假')) {
            adjustedHolidays++;
            holidayTypes[HOLIDAY_TYPES.ADJUSTED] = (holidayTypes[HOLIDAY_TYPES.ADJUSTED] || 0) + 1;
          } else {
            nationalHolidays++;
            holidayTypes[HOLIDAY_TYPES.NATIONAL] = (holidayTypes[HOLIDAY_TYPES.NATIONAL] || 0) + 1;
          }
          
          // 記錄具體假日類型
          if (holiday.description) {
            holidayTypes[holiday.description] = (holidayTypes[holiday.description] || 0) + 1;
          }
        } else if (holiday.description.includes('補行上班')) {
          workingDays++;
          holidayTypes[HOLIDAY_TYPES.WORKING] = (holidayTypes[HOLIDAY_TYPES.WORKING] || 0) + 1;
        }
      }
    
      return {
        year,
        totalHolidays,
        nationalHolidays,
        compensatoryDays,
        adjustedHolidays,
        workingDays,
        holidayTypes
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does (retrieve holiday statistics) but lacks details on behavioral traits such as whether it's read-only, any rate limits, authentication needs, or what the output format might be (e.g., counts, lists, or aggregated data). This leaves significant gaps for an agent to understand how to handle the tool effectively.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence contributes to understanding the tool's function.

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 complexity of a tool that retrieves statistical information, the description is incomplete. With no annotations and no output schema, it fails to explain what '統計資訊' (statistics information) entails—such as the type of data returned (e.g., counts, percentages, or detailed breakdowns). This lack of context makes it harder for an agent to use the tool correctly without additional information.

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 schema description coverage is 100%, with clear descriptions for both parameters ('year' and 'month') including constraints. The description adds minimal value beyond the schema by mentioning '指定年份或年月' (specified year or year-month), which aligns with the schema but doesn't provide additional semantic context or usage examples. Baseline 3 is appropriate as the schema handles most of the parameter documentation.

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

Purpose4/5

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

The description clearly states the action ('獲取' meaning 'get' or 'retrieve') and the resource ('台灣假期統計資訊' meaning 'Taiwan holiday statistics information'), specifying it's for a given year or year-month. However, it doesn't explicitly differentiate from sibling tools like 'check_holiday' or 'get_holidays_in_range', which might have overlapping purposes but different scopes or outputs.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus the sibling tools 'check_holiday' or 'get_holidays_in_range'. It mentions the parameters (year or year-month) but doesn't clarify the context or alternatives, leaving the agent to infer usage based on tool names alone.

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/lis186/taiwan-holiday-mcp'

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