Skip to main content
Glama
jimmcq
by jimmcq

sell_lemonade

Simulate running a lemonade stand by analyzing weather, pricing, and inventory to optimize daily sales results in the classic business game.

Instructions

Open for business and see today's results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gameIdYesThe game ID

Implementation Reference

  • The core handler function that implements the sell_lemonade tool logic: calculates recipe, potential customers, sales, revenue, costs, profit, updates game state.
    const handleSellLemonade = (gameState) => { const recipe = makeRecipe(gameState); const potentialCustomers = calculatePotentialCustomers(gameState.weather, gameState.pricePerCup); const actualSales = Math.min(potentialCustomers, recipe.maxCups); const revenue = actualSales * gameState.pricePerCup; const newInventory = { cups: gameState.inventory.cups - actualSales, lemons: gameState.inventory.lemons - recipe.lemonsUsed, sugar: gameState.inventory.sugar - recipe.sugarUsed, ice: 0 // ice melts every day }; // Calculate the actual cost per cup based on recipe const actualCostPerCup = calculateCostPerCup(); const dailyCost = actualSales * actualCostPerCup; const dailyProfit = revenue - dailyCost; return { success: true, dailyResults: { sales: actualSales, revenue: revenue, cost: dailyCost, profit: dailyProfit, costPerCup: actualCostPerCup, potentialCustomers: potentialCustomers, unsatisfiedCustomers: Math.max(0, potentialCustomers - actualSales) }, gameState: { ...gameState, money: gameState.money + revenue, // Revenue is added, not profit inventory: newInventory, status: 'reporting' } }; };
  • Input schema definition for the sell_lemonade tool in the ListTools response.
    { name: "sell_lemonade", description: "Open for business and see today's results", inputSchema: { type: "object", properties: { gameId: { type: "string", description: "The game ID" } }, required: ["gameId"] } },
  • server.js:351-368 (registration)
    Registration and dispatching of the sell_lemonade tool call in the CallToolRequestSchema handler switch statement, invoking the handleSellLemonade function.
    case 'sell_lemonade': { const sellGame = games.get(request.params.arguments?.gameId); if (!sellGame) { throw new McpError(ErrorCode.InvalidRequest, "Game not found"); } const sellResult = handleSellLemonade(sellGame); if (sellResult.success) { games.set(request.params.arguments.gameId, sellResult.gameState); } return { content: [{ type: "text", text: JSON.stringify(sellResult) }] }; }
  • Helper function used by handleSellLemonade to compute the recipe and maximum cups that can be made from inventory.
    const makeRecipe = (gameState) => { const cupsPerPitcher = 10; const lemonsPerPitcher = 4; const sugarPerPitcher = 4; const icePerPitcher = 15; const possiblePitchers = Math.min( Math.floor(gameState.inventory.lemons / lemonsPerPitcher), Math.floor(gameState.inventory.sugar / sugarPerPitcher), Math.floor(gameState.inventory.ice / icePerPitcher) ); const maxCups = Math.min( possiblePitchers * cupsPerPitcher, gameState.inventory.cups ); return { maxCups, lemonsUsed: Math.floor((maxCups / cupsPerPitcher) * lemonsPerPitcher), sugarUsed: Math.floor((maxCups / cupsPerPitcher) * sugarPerPitcher), iceUsed: Math.floor((maxCups / cupsPerPitcher) * icePerPitcher) }; };
  • Helper function used by handleSellLemonade to calculate the cost per cup of lemonade.
    const calculateCostPerCup = () => { const prices = { cups: 0.05, lemons: 0.10, sugar: 0.08, ice: 0.02 }; const cupsPerPitcher = 10; const lemonsPerPitcher = 4; const sugarPerPitcher = 4; const icePerPitcher = 15; // Calculate cost of ingredients per pitcher const pitcherCost = (lemonsPerPitcher * prices.lemons) + (sugarPerPitcher * prices.sugar) + (icePerPitcher * prices.ice); // Calculate cost per cup including the cup itself return (pitcherCost / cupsPerPitcher) + prices.cups; };

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/jimmcq/Lemonade-Stand-MCP-Server'

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