set_price
Define the price per cup of lemonade in the Lemonade Stand game using the 'set_price' tool. Input the game ID and desired price to manage pricing strategies effectively.
Instructions
Set the price per cup of lemonade
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gameId | Yes | The game ID | |
| price | Yes | Price per cup in dollars |
Implementation Reference
- server.js:333-349 (handler)Handler function for the 'set_price' tool. Updates the game's pricePerCup based on input and sets status to 'selling', then persists the updated game state.case 'set_price': { const priceGame = games.get(request.params.arguments?.gameId); if (!priceGame) { throw new McpError(ErrorCode.InvalidRequest, "Game not found"); } priceGame.pricePerCup = parseFloat(request.params.arguments.price); priceGame.status = 'selling'; games.set(request.params.arguments.gameId, priceGame); return { content: [{ type: "text", text: JSON.stringify({ success: true, gameState: priceGame }) }] }; }
- server.js:263-270 (schema)Input schema for 'set_price' tool defining gameId and price parameters.inputSchema: { type: "object", properties: { gameId: { type: "string", description: "The game ID" }, price: { type: "number", description: "Price per cup in dollars" } }, required: ["gameId", "price"] }
- server.js:260-271 (registration)Registration of the 'set_price' tool in the ListTools response, including name, description, and schema.{ name: "set_price", description: "Set the price per cup of lemonade", inputSchema: { type: "object", properties: { gameId: { type: "string", description: "The game ID" }, price: { type: "number", description: "Price per cup in dollars" } }, required: ["gameId", "price"] } },