Skip to main content
Glama
jimmcq
by jimmcq

sell_lemonade

Process daily sales transactions in the Lemonade Stand simulation to calculate revenue, manage inventory, and track business performance based on weather conditions and pricing strategies.

Instructions

Open for business and see today's results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gameIdYesThe game ID

Implementation Reference

  • The main handler function that executes the sell_lemonade tool logic: calculates recipe, potential customers, sales, revenue, costs, profit, updates inventory and 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, requiring gameId.
    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)
    MCP server registration and dispatch for sell_lemonade tool call, retrieves game state, invokes handler, updates state, and returns results.
    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 to compute the maximum cups that can be made from current inventory and ingredients used.
    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 to calculate the cost per cup of lemonade based on ingredient prices.
    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; };

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