Skip to main content
Glama

get_daily_horoscope

Retrieve today’s horoscope for a specific zodiac sign in categories like love, career, health, or wealth. Input the sign in English or Chinese to get tailored insights.

Instructions

获取指定星座的今日运势

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNo运势类别luck
zodiacYes星座名称(中文或英文)

Implementation Reference

  • Main handler function for executing get_daily_horoscope tool logic: resolves zodiac, fetches local random or remote horoscope via API, formats Markdown response.
    case 'get_daily_horoscope': { const zodiacKey = getZodiacKey(args.zodiac); if (!zodiacKey) throw new Error(`未找到星座: ${args.zodiac}`); const zodiac = zodiacData[zodiacKey]; const category = args.category || 'luck'; const source = args.source || 'local'; let horoscope; let text; if (source === 'remote') { const remote = await fetchRemoteHoroscope(zodiac.english.toLowerCase()); if (remote.error) { text = remote.error; } else { text = `# ${zodiac.symbol} ${zodiac.name} 今日运势(天行数据)\n\n` + `- 综合运势: ${remote.all}\n` + `- 爱情运势: ${remote.love}\n` + `- 事业学业: ${remote.work}\n` + `- 财富运势: ${remote.money}\n` + `- 健康运势: ${remote.health}\n` + `- 幸运颜色: ${remote.color}\n` + `- 幸运数字: ${remote.number}\n` + `- 速配星座: ${remote.QFriend}\n\n` + `${remote.summary}`; } } else { horoscope = getRandomHoroscope(category); const categoryNames = { love: '爱情运', career: '事业运', health: '健康运', wealth: '财运', luck: '综合运势' }; text = `# ${zodiac.symbol} ${zodiac.name} 今日${categoryNames[category]}\n\n` + `**运势指数:** ⭐⭐⭐⭐⭐\n\n` + `**今日运势:**\n${horoscope}\n\n` + `**建议:**\n- 保持积极心态\n- 注意身体健康\n- 与朋友多交流\n- 把握机会,勇敢尝试`; } result = { content: [ { type: 'text', text } ] }; break; }
  • Tool schema definition including name, description, input schema with properties for zodiac, category, source, and validation.
    { name: 'get_daily_horoscope', description: '获取指定星座的今日运势', inputSchema: { type: 'object', properties: { zodiac: { type: 'string', description: '星座名称(中文或英文)', enum: Object.keys(zodiacData).concat(Object.values(zodiacData).map(z => z.name)) }, category: { type: 'string', description: '运势类别', enum: ['love', 'career', 'health', 'wealth', 'luck'], default: 'luck' }, source: { type: 'string', description: '数据来源(local: 本地, remote: 天行数据)', enum: ['local', 'remote'], default: 'local' } }, required: ['zodiac'] } },
  • index.js:347-355 (registration)
    Registration of tool list handler for ListToolsRequestSchema, exposing get_daily_horoscope among other tools.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: tools.map(tool => ({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })) }; });
  • Supporting helper utility to fetch daily horoscope data from remote TianAPI service, used when source='remote'.
    export async function fetchRemoteHoroscope(zodiac) { try { const res = await axios.get(BASE_URL, { params: { key: API_KEY, astro: zodiac // 需传英文小写 } }); if (res.data && res.data.code === 200 && res.data.result) { return res.data.result; } throw new Error(res.data.msg || 'API返回异常'); } catch (e) { return { error: `远程运势获取失败: ${e.message}` }; } }

Other Tools

Related 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/jlankellii/star-mcp'

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