get_zodiac_by_date
Determine your zodiac sign by entering your birth month and day. This tool calculates astrological signs based on date ranges for horoscope analysis.
Instructions
根据出生日期确定星座
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| month | Yes | 出生月份(1-12) | |
| day | Yes | 出生日期(1-31) |
Implementation Reference
- index.js:619-633 (handler)Core handler function that computes the zodiac sign based on birth month and day using if-else chains for date ranges.function getZodiacByDate(month, day) { if ((month === 3 && day >= 21) || (month === 4 && day <= 19)) return 'aries'; if ((month === 4 && day >= 20) || (month === 5 && day <= 20)) return 'taurus'; if ((month === 5 && day >= 21) || (month === 6 && day <= 21)) return 'gemini'; if ((month === 6 && day >= 22) || (month === 7 && day <= 22)) return 'cancer'; if ((month === 7 && day >= 23) || (month === 8 && day <= 22)) return 'leo'; if ((month === 8 && day >= 23) || (month === 9 && day <= 22)) return 'virgo'; if ((month === 9 && day >= 23) || (month === 10 && day <= 23)) return 'libra'; if ((month === 10 && day >= 24) || (month === 11 && day <= 22)) return 'scorpio'; if ((month === 11 && day >= 23) || (month === 12 && day <= 21)) return 'sagittarius'; if ((month === 12 && day >= 22) || (month === 1 && day <= 19)) return 'capricorn'; if ((month === 1 && day >= 20) || (month === 2 && day <= 18)) return 'aquarius'; if ((month === 2 && day >= 19) || (month === 3 && day <= 20)) return 'pisces'; return null; }
- index.js:499-520 (schema)Tool schema definition including input parameters for month and day with validation constraints.{ name: 'get_zodiac_by_date', description: '根据出生日期确定星座', inputSchema: { type: 'object', properties: { month: { type: 'integer', description: '出生月份(1-12)', minimum: 1, maximum: 12 }, day: { type: 'integer', description: '出生日期(1-31)', minimum: 1, maximum: 31 } }, required: ['month', 'day'] } },
- index.js:673-681 (registration)Registration of tools list handler which exposes the get_zodiac_by_date tool via the tools array.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: tools.map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })) }; });
- index.js:823-851 (handler)MCP tool call dispatcher case that handles the get_zodiac_by_date request, computes the zodiac, and returns formatted response.case 'get_zodiac_by_date': { const zodiacKey = getZodiacByDate(args.month, args.day); if (!zodiacKey) { throw new Error('日期无效'); } const zodiac = zodiacData[zodiacKey]; result = { content: [ { type: 'text', text: `# 生日星座查询结果 **出生日期:** ${args.month}月${args.day}日 **对应星座:** ${zodiac.symbol} ${zodiac.name} (${zodiac.english}) **日期范围:** ${zodiac.dateRange} **基本信息:** - 元素: ${zodiac.element} - 性质: ${zodiac.quality} - 守护星: ${zodiac.ruler} **性格特点:** ${zodiac.traits.map(trait => `- ${trait}`).join('\n')}` } ] }; break;