craftItems
Craft specified items in Minecraft using a crafting table or inventory. Provide the item name and count to automate item creation, enhancing in-game efficiency with the MCP Server.
Instructions
Craft items using a crafting table or inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | Number of items to craft | |
| item | Yes | The name of the item to craft |
Implementation Reference
- Main handler function for the 'craftItems' tool. Crafts specified items or opens the crafting interface if no item provided. Uses helpers like craftAnItem and updateCraftingInterface.export const craftItems = async ( bot: Bot, params: ISkillParams, serviceParams: ISkillServiceParams, ): Promise<boolean> => { const skillName = 'craftItems'; const requiredParams: string[] = []; const isParamsValid = validateSkillParams( params, requiredParams, skillName, ); if (!isParamsValid) { serviceParams.cancelExecution?.(); bot.emit( 'alteraBotEndObservation', `Mistake: You didn't provide all of the required parameters ${requiredParams.join(', ')} for the ${skillName} skill.`, ); return false; } const unpackedParams = { item: params.item || null, count: params.count || 1, signal: serviceParams.signal, getStatsData: serviceParams.getStatsData, setStatsData: serviceParams.setStatsData, }; const {item, count, setStatsData, getStatsData, signal} = unpackedParams; if (!item) { try { updateCraftingInterface(bot); // open the crafting interface // force choosing a new action after opening the crafting interface bot.emit( 'alteraBotEndObservation', `You have opened the crafting interface and should choose a new action.`, ); } catch (err) { return bot.emit( 'alteraBotEndObservation', `Error: something went wrong when trying to see the items you can craft.`, ); } } else { const [success, message] = await craftAnItem(bot, { name: item, count, setStatsData, getStatsData, signal, }); if (success) { return bot.emit( 'alteraBotEndObservation', `You have successfully finished crafting ${message}.`, ); } else { return bot.emit( 'alteraBotEndObservation', `You have failed to craft ${count} ${item} because ${message}`, ); } } };
- Input schema and metadata for the 'craftItems' tool, defining parameters, description, and required fields.craftItems: { description: "Craft items using a crafting table or inventory", params: { item: { type: "string", description: "The name of the item to craft" }, count: { type: "number", description: "Number of items to craft" } }, required: ["item", "count"] },
- mcp-server/src/skillRegistry.ts:353-364 (registration)Dynamic registration of 'craftItems' skill (along with others) into the SkillRegistry via loadSkills function, using metadata to create SkillDefinition.for (const [skillName, metadata] of Object.entries(SKILL_METADATA)) { skills.push({ name: skillName, description: metadata.description, inputSchema: { type: "object", properties: metadata.params, required: metadata.required }, execute: createSkillExecutor(skillName) }); }