Skip to main content
Glama
bellsanct
by bellsanct

buy_item

Purchase items from the shop using gold to add them to your inventory. Use this tool to acquire equipment and supplies for dungeon exploration when not actively exploring.

Instructions

ショップからアイテムを購入します。ゴールドを消費してインベントリに追加されます。探索中は購入できません。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
item_idYes購入するアイテムのID(shop_inventoryで確認)
save_keyYesセーブキー

Implementation Reference

  • The core logic handler for the `buy_item` tool. It checks the player's status, verifies funds, and adds the purchased item or equipment to the inventory.
    export async function buyItem(itemId: string, saveKey: string): Promise<string> {
      const gameData = await storage.load(saveKey);
    
      // 探索中は購入不可
      if (gameData.player.state === 'exploring') {
        return '探索中はショップを利用できません。探索が終了するまでお待ちください。';
      }
    
      // 装備を探す
      const shopEquipment = getShopEquipmentById(itemId);
      if (shopEquipment) {
        // ゴールドチェック
        if (gameData.player.gold < shopEquipment.price) {
          return `ゴールドが足りません。必要: ${shopEquipment.price}G、所持: ${gameData.player.gold}G`;
        }
    
        // 購入処理
        gameData.player.gold -= shopEquipment.price;
        const purchasedEquipment = cloneEquipment(shopEquipment);
        gameData.player.inventory.push(purchasedEquipment);
    
        await storage.save(gameData, saveKey);
        return `${shopEquipment.name}を${shopEquipment.price}Gで購入しました。残りゴールド: ${gameData.player.gold}G`;
      }
    
      // 持ち物アイテムを探す
      const shopItem = getShopItemById(itemId);
      if (shopItem) {
        // ゴールドチェック
        if (gameData.player.gold < shopItem.price) {
          return `ゴールドが足りません。必要: ${shopItem.price}G、所持: ${gameData.player.gold}G`;
        }
    
        // 購入処理
        gameData.player.gold -= shopItem.price;
        const purchasedItem = cloneItem(shopItem);
        gameData.player.itemInventory.push(purchasedItem);
    
        await storage.save(gameData, saveKey);
        return `${shopItem.name}を${shopItem.price}Gで購入しました。残りゴールド: ${gameData.player.gold}G`;
      }
    
      return `アイテムID "${itemId}" は見つかりませんでした。`;
    }
  • src/index.ts:262-275 (registration)
    Registration of the `buy_item` tool within the MCP setup, including description and input schema.
    name: 'buy_item',
    description: 'ショップからアイテムを購入します。ゴールドを消費してインベントリに追加されます。探索中は購入できません。',
    inputSchema: {
      type: 'object',
      properties: {
        item_id: {
          type: 'string',
          description: '購入するアイテムのID(shop_inventoryで確認)',
        },
        save_key: {
          type: 'string',
          description: 'セーブキー',
        },
      },

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