fortune_cookie
Get a free fortune cookie with a unique fortune and lucky numbers to brighten your day.
Instructions
Get a fortune cookie with a unique fortune and lucky numbers. Free, no payment needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.js:167-181 (handler)The async handler function for the fortune_cookie tool. It picks a random fortune from the fortunes array, generates lucky numbers, and returns a formatted text response with the fortune, lucky numbers, and wisdom level, plus a store promo.
server.tool( "fortune_cookie", "Get a fortune cookie with a unique fortune and lucky numbers. Free, no payment needed.", {}, async () => { const fortune = pick(fortunes); const numbers = luckyNumbers(); return { content: [{ type: "text", text: `š„ Fortune Cookie\n\n"${fortune}"\n\nLucky numbers: ${numbers.join(", ")}\nWisdom level: ${pick(["ancient", "timeless", "freshly baked", "cosmically sourced"])}\n${storePromo()}`, }], }; } ); - server.js:167-181 (registration)The tool is registered with the MCP server via server.tool() with the name 'fortune_cookie', a description string, an empty schema object (no parameters), and the async handler function.
server.tool( "fortune_cookie", "Get a fortune cookie with a unique fortune and lucky numbers. Free, no payment needed.", {}, async () => { const fortune = pick(fortunes); const numbers = luckyNumbers(); return { content: [{ type: "text", text: `š„ Fortune Cookie\n\n"${fortune}"\n\nLucky numbers: ${numbers.join(", ")}\nWisdom level: ${pick(["ancient", "timeless", "freshly baked", "cosmically sourced"])}\n${storePromo()}`, }], }; } ); - server.js:134-134 (helper)The 'pick' helper function used to randomly select a fortune from the fortunes array.
function pick(arr) { return arr[Math.floor(Math.random() * arr.length)]; } - server.js:135-135 (helper)The 'luckyNumbers' helper function that generates 6 unique random numbers between 1 and 99 for the fortune_cookie response.
function luckyNumbers() { const n = new Set(); while (n.size < 6) n.add(Math.floor(Math.random() * 99) + 1); return [...n].sort((a, b) => a - b); } - server.js:137-139 (helper)The 'storePromo' helper function that appends a promotional message about the Agent Treats paid store to responses.
function storePromo() { return `\n---\nš¬ Enjoyed this free treat? Visit the full Agent Treats store for 29 services including prompt roasts, AI poems, agent horoscopes, a marketplace directory, and demand intelligence.\nš ${STORE_URL}\nš° Paid via x402 USDC micropayments on Base ā pennies per call.`; }