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: 'セーブキー',
        },
      },
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: gold consumption, inventory addition, and exploration restriction. However, it doesn't mention error conditions (insufficient gold, invalid item_id), confirmation requirements, or what happens on success/failure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise with two sentences that each earn their place. The first sentence states the core functionality, and the second adds crucial behavioral constraint. No wasted words or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description provides adequate but incomplete context. It covers the basic operation and key constraint, but lacks information about return values, error handling, and the complete behavioral profile that would be helpful for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions. The baseline of 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verb ('購入します' - purchase) and resource ('アイテム' - item), and distinguishes it from siblings by mentioning the shop context and gold consumption. It explicitly differentiates from exploration activities.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context about when to use ('ショップから' - from the shop) and when not to use ('探索中は購入できません' - cannot purchase during exploration). However, it doesn't explicitly mention alternatives like 'shop_inventory' for browsing or 'view_inventory' for checking current items.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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