unequip_item
Remove an equipped item from a character's slot and return it to inventory in the MCP Dungeon Game. Specify the slot (weapon, shield, armor, or accessory) and save key to manage equipment.
Instructions
特定のスロットからアイテムを外してインベントリに戻します。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slot | Yes | 装備スロット: weapon, shield, armor, または accessory | |
| save_key | Yes | セーブキー |
Implementation Reference
- src/tools/player.ts:237-279 (handler)The logic for the 'unequip_item' tool, which validates the player state, checks the equipment slot, moves the item back to the inventory, and saves the game data.
export async function unequipItem(slot: string, saveKey: string): Promise<string> { const data = await storage.load(saveKey); if (!data.player.name) { return "プレイヤーが見つかりません。先に'create_player'を実行してください。"; } if (data.player.state === 'exploring') { return "ダンジョン探索中は装備を変更できません。\n探索完了後に装備を整えてください。"; } const validSlots = ['weapon', 'shield', 'armor', 'accessory']; if (!validSlots.includes(slot)) { return `無効なスロットです。有効なスロット: ${validSlots.join(', ')}`; } const slotKey = slot as keyof typeof data.player.equipment; const item = data.player.equipment[slotKey]; if (!item) { return `${slot}スロットには何も装備されていません。`; } // Type guard: Ensure we only push Equipment to equipment inventory if (!('stats' in item)) { return `エラー: ${slot}スロットに装備アイテムがありません。`; } // インベントリに移動 data.player.inventory.push(item as Equipment); data.player.equipment[slotKey] = null; await storage.save(data, saveKey); const slotNames: { [key: string]: string } = { weapon: '武器', shield: '盾', armor: '防具', accessory: 'アクセサリ' }; return `${slotNames[slot]}スロットから${item.name}を外しました。`; } - src/index.ts:108-123 (registration)Registration of the 'unequip_item' tool including its input schema and description.
{ name: 'unequip_item', description: '特定のスロットからアイテムを外してインベントリに戻します。', inputSchema: { type: 'object', properties: { slot: { type: 'string', description: '装備スロット: weapon, shield, armor, または accessory', enum: ['weapon', 'shield', 'armor', 'accessory'], }, save_key: { type: 'string', description: 'セーブキー', }, },