tossItem
Throw items from your Minecraft inventory to discard or share them. Specify the item name and quantity to remove items from your player's inventory.
Instructions
Throw items from inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| itemName | Yes | Name of the item to throw | |
| amount | No | Amount of items to throw |
Implementation Reference
- src/tools/inventoryManagement.ts:134-170 (registration)Registration of the 'tossItem' MCP tool, including schema (itemName: string, amount: number optional default 1) and inline handler function that locates the item in inventory and uses bot.toss to throw it.server.tool( 'tossItem', 'Throw items from inventory', { itemName: z.string().describe('Name of the item to throw'), amount: z .number() .optional() .default(1) .describe('Amount of items to throw'), }, async ({ itemName, amount }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the item in inventory const item = botState.bot.inventory .items() .find((item) => item.name.toLowerCase() === itemName.toLowerCase()) if (!item) { return createSuccessResponse( `Item "${itemName}" not found in inventory.` ) } // Since tossItem doesn't exist in the API, we have a few alternatives: // 1. Drop the item at the bot's current position await botState.bot.toss(item.type, null, amount) return createSuccessResponse(`Successfully threw ${amount} ${itemName}`) } catch (error) { return createErrorResponse(error) } } )
- src/tools/inventoryManagement.ts:145-169 (handler)The core handler logic for tossItem: validates connection, finds matching item by name (case-insensitive), tosses the specified amount using bot.toss(item.type, null, amount), handles errors.async ({ itemName, amount }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the item in inventory const item = botState.bot.inventory .items() .find((item) => item.name.toLowerCase() === itemName.toLowerCase()) if (!item) { return createSuccessResponse( `Item "${itemName}" not found in inventory.` ) } // Since tossItem doesn't exist in the API, we have a few alternatives: // 1. Drop the item at the bot's current position await botState.bot.toss(item.type, null, amount) return createSuccessResponse(`Successfully threw ${amount} ${itemName}`) } catch (error) { return createErrorResponse(error) } }
- Zod schema defining inputs for tossItem tool: itemName (required string), amount (optional number, defaults to 1).{ itemName: z.string().describe('Name of the item to throw'), amount: z .number() .optional() .default(1) .describe('Amount of items to throw'), },