bazi_forecast
Generate personalized fortune forecasts for career, wealth, relationships, and health based on traditional Chinese Bazi astrology, using your birth chart and specified time periods.
Instructions
预测未来运势
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chart | Yes | 八字命盘数据 | |
| start_date | Yes | 预测起始日期 | |
| end_date | Yes | 预测结束日期 | |
| aspects | Yes | 预测方面 | |
| resolution | No | 预测精度 |
Implementation Reference
- src/engines/bazi-engine.js:260-307 (handler)Core handler function that executes the bazi_forecast tool logic, handling different period types and generating forecast results.async forecastLuck({ chart, period_type, start_date, end_date, focus_aspects = [] }) { try { this.logger.info('开始运势预测', { period_type, start_date, end_date }); const currentDate = start_date ? moment(start_date) : moment(); let forecast = {}; switch (period_type) { case 'monthly': forecast = await this.forecastMonthly(chart, currentDate, focus_aspects); break; case 'yearly': forecast = await this.forecastYearly(chart, currentDate, focus_aspects); break; case 'decade': forecast = await this.forecastDecade(chart, currentDate, focus_aspects); break; case 'custom': if (!start_date || !end_date) { throw new Error('自定义预测需要提供开始和结束日期'); } forecast = await this.forecastCustomPeriod(chart, start_date, end_date, focus_aspects); break; default: throw new Error(`不支持的预测周期类型: ${period_type}`); } const result = { timestamp: new Date().toISOString(), period_type: period_type, forecast_period: { start: start_date || currentDate.format('YYYY-MM-DD'), end: end_date || this.calculateEndDate(currentDate, period_type) }, focus_aspects: focus_aspects, forecast: forecast, key_periods: this.identifyKeyPeriods(chart, forecast), overall_trend: this.analyzeOverallTrend(forecast), actionable_advice: this.generateActionableAdvice(forecast, focus_aspects) }; this.logger.info('运势预测完成'); return result; } catch (error) { this.logger.error('运势预测失败', { error: error.message }); throw error; } }
- src/index.js:430-442 (registration)Tool dispatch/registration in the main CallToolRequest handler switch statement.case 'bazi_forecast': // 转换参数格式以匹配BaziEngine期望的格式 // 处理嵌套的params结构 const params = args.params || args; const forecastArgs = { chart: params.chart, period_type: this.mapResolutionToPeriodType(params.resolution), start_date: params.start_date, end_date: params.end_date, focus_aspects: params.aspects || [] }; result = await baziEngine.forecastLuck(forecastArgs); break;
- src/index.js:221-256 (schema)MCP tool schema definition registered in ListToolsRequestHandler.name: 'bazi_forecast', description: '预测未来运势', inputSchema: { type: 'object', properties: { chart: { type: 'object', description: '八字命盘数据' }, start_date: { type: 'string', format: 'date', description: '预测起始日期' }, end_date: { type: 'string', format: 'date', description: '预测结束日期' }, aspects: { type: 'array', items: { type: 'string', enum: ['overall', 'career', 'wealth', 'relationship', 'health'] }, description: '预测方面' }, resolution: { type: 'string', enum: ['year', 'month', 'day'], description: '预测精度' } }, required: ['chart', 'start_date', 'end_date', 'aspects'] } },
- src/utils/validator.js:176-186 (schema)Joi validation schema used by validateToolInput for bazi_forecast parameters.function createBaziForecastSchema() { return Joi.object({ chart: Joi.object().required(), start_date: Joi.date().iso().default(() => new Date()), end_date: Joi.date().iso().min(Joi.ref('start_date')), aspects: Joi.array().items( Joi.string().valid('career', 'wealth', 'relationship', 'health', 'general') ).single().default(['general']), resolution: Joi.string().valid('year', 'month', 'day').default('month') }); }