Skip to main content
Glama
lis186

Taiwan Holiday MCP Server

by lis186

get_holidays_in_range

Retrieve all Taiwanese holidays within a specified date range to plan schedules and avoid conflicts.

Instructions

獲取指定日期範圍內的所有台灣假期

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes開始日期,支援格式:YYYY-MM-DD 或 YYYYMMDD
end_dateYes結束日期,支援格式:YYYY-MM-DD 或 YYYYMMDD

Implementation Reference

  • Handler for executing the get_holidays_in_range tool. Validates parameters, fetches holidays using HolidayService, filters actual holidays (isHoliday: true), and returns formatted JSON response.
    private async handleGetHolidaysInRange(args: any) {
      const { start_date, end_date } = args;
      
      if (!start_date || typeof start_date !== 'string') {
        throw new Error('缺少必要參數:start_date');
      }
      
      if (!end_date || typeof end_date !== 'string') {
        throw new Error('缺少必要參數:end_date');
      }
    
      const holidays = await this.holidayService.getHolidaysInRange(start_date, end_date);
      
      // 只返回實際的假期(isHoliday: true)
      const actualHolidays = holidays.filter(h => h.isHoliday);
      
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              data: {
                startDate: start_date,
                endDate: end_date,
                holidays: actualHolidays,
                totalCount: actualHolidays.length,
                summary: `在 ${start_date} 到 ${end_date} 期間共有 ${actualHolidays.length} 個假期`
              },
              timestamp: new Date().toISOString(),
              tool: 'get_holidays_in_range'
            }, null, 2),
          },
        ],
      };
    }
  • Tool schema definition in ListTools response, including name, description, and input schema with validation for start_date and end_date parameters.
      name: 'get_holidays_in_range',
      description: '獲取指定日期範圍內的所有台灣假期',
      inputSchema: {
        type: 'object',
        properties: {
          start_date: {
            type: 'string',
            description: '開始日期,支援格式:YYYY-MM-DD 或 YYYYMMDD',
            pattern: '^(\\d{4}-\\d{2}-\\d{2}|\\d{8})$'
          },
          end_date: {
            type: 'string',
            description: '結束日期,支援格式:YYYY-MM-DD 或 YYYYMMDD',
            pattern: '^(\\d{4}-\\d{2}-\\d{2}|\\d{8})$'
          }
        },
        required: ['start_date', 'end_date'],
        additionalProperties: false,
      },
    } as Tool,
  • Core implementation that parses start and end dates, validates range, fetches holidays for each year in range using getHolidaysForYear, filters those within range using isDateInRange, sorts by date, and handles errors.
    async getHolidaysInRange(startDate: string, endDate: string): Promise<Holiday[]> {
      try {
        const start = parseDate(startDate);
        const end = parseDate(endDate);
        
        // 驗證日期範圍
        if (start.year > end.year || 
            (start.year === end.year && start.month > end.month) ||
            (start.year === end.year && start.month === end.month && start.day > end.day)) {
          throw new HolidayServiceError(
            `開始日期 ${startDate} 不能晚於結束日期 ${endDate}`,
            ErrorType.INVALID_DATE
          );
        }
    
        const result: Holiday[] = [];
        
        // 處理跨年度的情況
        for (let year = start.year; year <= end.year; year++) {
          const holidays = await this.getHolidaysForYear(year);
          
          for (const holiday of holidays) {
            const holidayDate = parseDate(holiday.date);
            
            // 檢查是否在範圍內
            if (this.isDateInRange(holidayDate, start, end)) {
              result.push(holiday);
            }
          }
        }
        
        // 按日期排序
        return result.sort((a, b) => a.date.localeCompare(b.date));
      } catch (error) {
        if (error instanceof DateParseError) {
          throw new HolidayServiceError(
            `日期解析錯誤: ${error.message}`,
            error.type,
            error
          );
        }
        throw error;
      }
    }
  • src/server.ts:148-149 (registration)
    Dispatch registration in the CallToolRequestSchema switch statement that routes to the specific handler.
    case 'get_holidays_in_range':
      return await this.handleGetHolidaysInRange(args);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states what the tool does but lacks behavioral details: no mention of permissions needed, rate limits, whether it returns structured data or raw text, error handling, or pagination. For a read operation with no annotation coverage, this leaves significant gaps in understanding how it behaves.

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?

Extremely concise with a single sentence that directly states the purpose. No wasted words or redundant information. It's front-loaded and efficiently communicates the core functionality without unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (date-range query), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose but lacks details on output format, error cases, or behavioral traits. It meets the bare minimum for a read operation but doesn't provide enough context for robust agent use without additional assumptions.

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?

Schema description coverage is 100%, with both parameters ('start_date', 'end_date') fully documented in the schema regarding format and patterns. The description adds no additional parameter semantics beyond implying a date range, which is already clear from the schema. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('獲取' - get/fetch) and resource ('台灣假期' - Taiwan holidays) with scope ('指定日期範圍內' - within a specified date range). It distinguishes from sibling 'check_holiday' (likely checks a single date) and 'get_holiday_stats' (likely provides statistics), though not explicitly. The purpose is specific but lacks explicit sibling differentiation.

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?

No guidance on when to use this tool versus alternatives like 'check_holiday' or 'get_holiday_stats'. The description implies usage for fetching multiple holidays in a range, but doesn't state exclusions or prerequisites. It's minimal, relying on inference from the name and description 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