find-item
Locate a specific item in the bot's Minecraft inventory by specifying its name or type using the MCP server's inventory search tool.
Instructions
Find a specific item in the bot's inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nameOrType | Yes | Name or type of item to find |
Implementation Reference
- src/bot.ts:293-308 (handler)The handler function for the 'find-item' tool. It retrieves all inventory items, finds the first one whose name includes the provided nameOrType (case-insensitive), and returns details including count and slot, or a not-found message.async ({ nameOrType }): Promise<McpResponse> => { try { const items = bot.inventory.items(); const item = items.find((item: any) => item.name.includes(nameOrType.toLowerCase()) ); if (item) { return createResponse(`Found ${item.count} ${item.name} in inventory (slot ${item.slot})`); } else { return createResponse(`Couldn't find any item matching '${nameOrType}' in inventory`); } } catch (error) { return createErrorResponse(error as Error); } }
- src/bot.ts:290-292 (schema)Zod input schema for the 'find-item' tool, defining the required 'nameOrType' string parameter.{ nameOrType: z.string().describe("Name or type of item to find") },
- src/bot.ts:287-309 (registration)The server.tool call that registers the 'find-item' tool on the MCP server, including its name, description, input schema, and handler function.server.tool( "find-item", "Find a specific item in the bot's inventory", { nameOrType: z.string().describe("Name or type of item to find") }, async ({ nameOrType }): Promise<McpResponse> => { try { const items = bot.inventory.items(); const item = items.find((item: any) => item.name.includes(nameOrType.toLowerCase()) ); if (item) { return createResponse(`Found ${item.count} ${item.name} in inventory (slot ${item.slot})`); } else { return createResponse(`Couldn't find any item matching '${nameOrType}' in inventory`); } } catch (error) { return createErrorResponse(error as Error); } } );