Skip to main content
Glama
jimmcq
by jimmcq

buy_supplies

Purchase cups, lemons, sugar, and ice to manage inventory for a lemonade stand business simulation game.

Instructions

Purchase supplies for the lemonade stand

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gameIdYesThe game ID
cupsNoNumber of cups to buy
lemonsNoNumber of lemons to buy
sugarNoAmount of sugar to buy
iceNoAmount of ice to buy

Implementation Reference

  • server.js:62-98 (handler)
    The main handler function for the buy_supplies tool. It calculates the total cost of purchases based on fixed item prices, updates the inventory and money in the game state if sufficient funds are available, and tracks purchase history.
    const handleBuySupplies = (gameState, purchases) => { const prices = { cups: 0.05, lemons: 0.10, sugar: 0.08, ice: 0.02 }; let totalCost = 0; const newInventory = { ...gameState.inventory }; const purchaseRecord = { ...purchases, date: gameState.day }; for (const item of ['cups', 'lemons', 'sugar', 'ice']) { const amount = purchases[item] || 0; const cost = amount * prices[item]; totalCost += cost; newInventory[item] += amount; purchaseRecord[`${item}Cost`] = cost; } if (totalCost > gameState.money) { return { success: false, message: "Not enough money!" }; } purchaseRecord.totalCost = totalCost; return { success: true, gameState: { ...gameState, money: gameState.money - totalCost, inventory: newInventory, purchaseHistory: [...gameState.purchaseHistory, purchaseRecord], status: 'pricing' } }; };
  • Defines the tool metadata including name, description, and input schema for validation of arguments (gameId required, optional quantities for cups, lemons, sugar, ice).
    { name: "buy_supplies", description: "Purchase supplies for the lemonade stand", inputSchema: { type: "object", properties: { gameId: { type: "string", description: "The game ID" }, cups: { type: "number", description: "Number of cups to buy" }, lemons: { type: "number", description: "Number of lemons to buy" }, sugar: { type: "number", description: "Amount of sugar to buy" }, ice: { type: "number", description: "Amount of ice to buy" } }, required: ["gameId"] } },
  • server.js:315-331 (registration)
    Registers and dispatches the buy_supplies tool call: validates game existence, invokes the handleBuySupplies function, persists updated game state, and returns the result as JSON.
    case 'buy_supplies': { const buyGame = games.get(request.params.arguments?.gameId); if (!buyGame) { throw new McpError(ErrorCode.InvalidRequest, "Game not found"); } const result = handleBuySupplies(buyGame, request.params.arguments); if (result.success) { games.set(request.params.arguments.gameId, result.gameState); } return { content: [{ type: "text", text: JSON.stringify(result) }] }; }

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