Skip to main content
Glama
bellsanct
by bellsanct

equip_item

Equip items from inventory to enhance character abilities in the MCP Dungeon Game. Use item IDs from view_inventory to select gear for dungeon exploration and battles.

Instructions

インベントリからアイテムを装備します。アイテムIDはview_inventoryで確認できます。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
item_idYes装備するアイテムのID(インベントリに表示)
save_keyYesセーブキー

Implementation Reference

  • The core logic that handles equipping an item from the inventory. It performs validation checks (player existence, current state, item existence), manages the equipment swap between inventory and equipment slots, and saves the game state.
    export async function equipItem(itemId: 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 itemIndex = data.player.inventory.findIndex(item => item.id === itemId);
      
      if (itemIndex === -1) {
        return `ID '${itemId}' のアイテムがインベントリに見つかりません。`;
      }
    
      const item = data.player.inventory[itemIndex];
      const slot = item.type as keyof typeof data.player.equipment;
    
      // 現在装備中のアイテムがあれば外す
      const currentItem = data.player.equipment[slot];
      if (currentItem && 'stats' in currentItem) {
        // Type guard: Only push Equipment items to equipment inventory
        data.player.inventory.push(currentItem as Equipment);
      }
    
      // 新しいアイテムを装備
      data.player.equipment[slot] = item;
      data.player.inventory.splice(itemIndex, 1);
    
      await storage.save(data, saveKey);
    
      const slotNames: { [key: string]: string } = {
        weapon: '武器',
        shield: '盾',
        armor: '防具',
        accessory: 'アクセサリ'
      };
    
      return `${item.name}を${slotNames[slot]}スロットに装備しました!\n\n'view_status'で更新されたステータスを確認できます。`;
    }
  • src/index.ts:91-105 (registration)
    Registration of the 'equip_item' tool, including its schema definition and input requirements.
    name: 'equip_item',
    description: 'インベントリからアイテムを装備します。アイテムIDはview_inventoryで確認できます。',
    inputSchema: {
      type: 'object',
      properties: {
        item_id: {
          type: 'string',
          description: '装備するアイテムのID(インベントリに表示)',
        },
        save_key: {
          type: 'string',
          description: 'セーブキー',
        },
      },
      required: ['item_id', 'save_key'],

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/bellsanct/mcp-dungeon-game'

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