Skip to main content
Glama

tossItem

Remove specific items from your Minecraft inventory by remotely commanding players to throw them, managing storage and item counts efficiently.

Instructions

Throw items from inventory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountNoAmount of items to throw
itemNameYesName of the item to throw

Implementation Reference

  • Handler function that locates the specified item in the bot's inventory and tosses the requested amount using bot.toss, with error handling for connection and missing items.
    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 input schema defining parameters for the tossItem tool: itemName (required string) and 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'), },
  • Registration of the tossItem MCP tool using server.tool, including name, description, schema, and handler within the registerInventoryManagementTools function.
    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) } } )

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/nacal/mcp-minecraft-remote'

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