Skip to main content
Glama
hjsh200219

Saju Fortune-Telling MCP Server

by hjsh200219

get_fortune_by_period

Analyze Korean Saju fortune-telling for specific time periods using birth details to provide personalized destiny insights based on year, month, hour, or multi-year cycles.

Instructions

시간대별 운세 (year/month/hour/multi-year)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
birthDateYes
birthTimeYes
calendarNosolar
isLeapMonthNo
genderYes
periodTypeYesyear:YYYY | month:YYYY-MM | hour:YYYY-MM-DD HH:mm | multi-year:연속
targetNo기간 (periodType에 맞는 형식)
countNomulti-year용

Implementation Reference

  • Main handler function executing the tool logic for different fortune periods (year, multi-year, month, hour) using saju analysis.
    export function handleGetFortuneByPeriod(args: GetFortuneByPeriodArgs): string {
      const {
        birthDate,
        birthTime,
        calendar = 'solar',
        isLeapMonth = false,
        gender,
        periodType,
        target,
        count = 5,
      } = args;
    
      // 사주 계산
      const sajuData = calculateSaju(birthDate, birthTime, calendar, isLeapMonth, gender);
    
      switch (periodType) {
        case 'year': {
          if (!target) {
            throw new Error('year 조회 시 target (YYYY) 필수');
          }
          const year = parseInt(target, 10);
          if (isNaN(year)) {
            throw new Error(`유효하지 않은 연도: ${target}`);
          }
          const seUn = analyzeSeUn(sajuData, year);
          return JSON.stringify(seUn);
        }
    
        case 'multi-year': {
          const startYear = target ? parseInt(target, 10) : new Date().getFullYear();
          if (isNaN(startYear)) {
            throw new Error(`유효하지 않은 연도: ${target}`);
          }
          const seUnList = getMultipleSeUn(sajuData, startYear, count);
          return JSON.stringify({ years: seUnList, count: seUnList.length });
        }
    
        case 'month': {
          if (!target) {
            throw new Error('month 조회 시 target (YYYY-MM) 필수');
          }
          const parts = target.split('-');
          if (parts.length !== 2) {
            throw new Error(`잘못된 월 형식: ${target}. YYYY-MM 형식 사용`);
          }
          const year = parseInt(parts[0]!, 10);
          const month = parseInt(parts[1]!, 10);
          if (isNaN(year) || isNaN(month) || month < 1 || month > 12) {
            throw new Error(`유효하지 않은 월: ${target}`);
          }
          // 해당 연도의 세운 분석하여 yearStem 가져오기
          const seUn = analyzeSeUn(sajuData, year);
          const wolUn = analyzeWolUn(sajuData, year, month, seUn.stem);
          return JSON.stringify(wolUn);
        }
    
        case 'hour': {
          if (!target) {
            throw new Error('hour 조회 시 target (YYYY-MM-DD HH:mm) 필수');
          }
          const parts = target.split(' ');
          if (parts.length !== 2) {
            throw new Error(`잘못된 일시 형식: ${target}. YYYY-MM-DD HH:mm 형식 사용`);
          }
          const timePart = parts[1];
          const hour = parseInt(timePart!.split(':')[0]!, 10);
          if (isNaN(hour) || hour < 0 || hour > 23) {
            throw new Error(`유효하지 않은 시간: ${hour}`);
          }
          // analyzeIljin은 Date와 SajuData를 받음
          const targetDate = new Date(target.replace(' ', 'T'));
          const ilJin = analyzeIljin(targetDate, sajuData);
          return JSON.stringify(ilJin);
        }
    
        default:
          throw new Error(`알 수 없는 periodType: ${periodType}`);
      }
    }
  • TypeScript interface defining input parameters for the get_fortune_by_period handler.
    export interface GetFortuneByPeriodArgs {
      birthDate: string;
      birthTime: string;
      calendar?: CalendarType;
      isLeapMonth?: boolean;
      gender: Gender;
      periodType: PeriodType;
      target?: string; // YYYY (year), YYYY-MM (month), YYYY-MM-DD HH:mm (hour)
      count?: number; // multi-year용 조회 개수
    }
  • MCP tool schema definition including name, description, and input schema for get_fortune_by_period.
    get_fortune_by_period: () => ({
      name: 'get_fortune_by_period',
      description: '시간대별 운세 (year/month/hour/multi-year)',
      inputSchema: {
        type: 'object',
        properties: {
          birthDate: { type: 'string' },
          birthTime: { type: 'string' },
          calendar: { type: 'string', enum: ['solar', 'lunar'], default: 'solar' },
          isLeapMonth: { type: 'boolean', default: false },
          gender: { type: 'string', enum: ['male', 'female'] },
          periodType: {
            type: 'string',
            enum: ['year', 'month', 'hour', 'multi-year'],
            description: 'year:YYYY | month:YYYY-MM | hour:YYYY-MM-DD HH:mm | multi-year:연속',
          },
          target: { type: 'string', description: '기간 (periodType에 맞는 형식)' },
          count: { type: 'number', default: 5, description: 'multi-year용' },
        },
        required: ['birthDate', 'birthTime', 'gender', 'periodType'],
      },
    }),
  • Dispatch/registration of the get_fortune_by_period tool call to its handler function.
    case 'get_fortune_by_period':
      return handleGetFortuneByPeriod(args as Parameters<typeof handleGetFortuneByPeriod>[0]);
  • Re-export of the handler function enabling its import in tool-handler.
    export { handleGetFortuneByPeriod } from './get_fortune_by_period.js';

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/hjsh200219/fortuneteller'

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