Skip to main content
Glama

search_equipment

Search D&D 5e SRD equipment with filters for category, cost, weight, properties, armor type, and rarity. Find weapons, armor, and magic items quickly.

Instructions

Search D&D 5e SRD equipment, weapons, armor, and magic items. Filter by category, cost, weight, weapon properties, armor type, or rarity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch term for item name or description
categoryNoEquipment category (e.g. "Weapon", "Armor", "Adventuring Gear", "Tools")
cost_minNoMinimum cost in gold pieces
cost_maxNoMaximum cost in gold pieces
weight_maxNoMaximum weight in pounds
weapon_propertyNoWeapon property (e.g. "finesse", "heavy", "two-handed", "versatile")
armor_categoryNoArmor category (e.g. "Light", "Medium", "Heavy", "Shield")
rarityNoMagic item rarity (e.g. "common", "uncommon", "rare", "very rare", "legendary")
limitNoResults per page (max 50)
offsetNoOffset for pagination

Implementation Reference

  • The registerSearchEquipment function that implements the search_equipment tool handler. It registers the tool on the MCP server with Zod schema for input validation (query, category, cost_min, cost_max, weight_max, weapon_property, armor_category, rarity, limit, offset), calls searchEquipment from db.ts, and formats results using formatEquipmentItem or formatMagicItem.
    export function registerSearchEquipment(
      server: McpServer,
      db: Database.Database,
    ): void {
      server.registerTool(
        'search_equipment',
        {
          description:
            'Search D&D 5e SRD equipment, weapons, armor, and magic items. Filter by category, cost, weight, weapon properties, armor type, or rarity.',
          inputSchema: {
            query: z.string().optional().describe('Search term for item name or description'),
            category: z
              .string()
              .optional()
              .describe('Equipment category (e.g. "Weapon", "Armor", "Adventuring Gear", "Tools")'),
            cost_min: z.number().optional().describe('Minimum cost in gold pieces'),
            cost_max: z.number().optional().describe('Maximum cost in gold pieces'),
            weight_max: z.number().optional().describe('Maximum weight in pounds'),
            weapon_property: z
              .string()
              .optional()
              .describe('Weapon property (e.g. "finesse", "heavy", "two-handed", "versatile")'),
            armor_category: z
              .string()
              .optional()
              .describe('Armor category (e.g. "Light", "Medium", "Heavy", "Shield")'),
            rarity: z
              .string()
              .optional()
              .describe('Magic item rarity (e.g. "common", "uncommon", "rare", "very rare", "legendary")'),
            limit: z.number().min(1).max(50).default(10).describe('Results per page (max 50)'),
            offset: z.number().min(0).default(0).describe('Offset for pagination'),
          },
        },
        async ({
          query,
          category,
          cost_min,
          cost_max,
          weight_max,
          weapon_property,
          armor_category,
          rarity,
          limit,
          offset,
        }) => {
          const result = searchEquipment(db, {
            query,
            category,
            cost_min,
            cost_max,
            weight_max,
            weapon_property,
            armor_category,
            rarity,
            limit,
            offset,
          });
    
          if (result.rows.length === 0) {
            return {
              content: [
                {
                  type: 'text' as const,
                  text: 'No equipment found matching your criteria. Try a broader search — for example, remove some filters or use a partial name.',
                },
              ],
              isError: true,
            };
          }
    
          const start = (offset ?? 0) + 1;
          const end = (offset ?? 0) + result.rows.length;
          const header = `Found ${result.total} item${result.total === 1 ? '' : 's'} (showing ${start}-${end})\n`;
    
          const items = result.rows.map(formatEquipmentItem).join('\n\n---\n\n');
    
          return {
            content: [{ type: 'text' as const, text: header + '\n' + items }],
          };
        },
      );
  • EquipmentFilters interface defining all filter parameters accepted by the search_equipment tool: query, category, cost_min, cost_max, weight_max, weapon_property, armor_category, rarity, limit, offset.
    export interface EquipmentFilters {
      query?: string;
      category?: string;
      cost_min?: number;
      cost_max?: number;
      weight_max?: number;
      weapon_property?: string;
      armor_category?: string;
      rarity?: string;
      limit?: number;
      offset?: number;
    }
  • src/server.ts:48-48 (registration)
    Registration call: registerSearchEquipment(server, db) invoked in the createServer function to register the search_equipment tool.
    registerSearchEquipment(server, db);
  • sanitizeFtsQuery helper used to clean user query strings for FTS5 full-text search queries on equipment and magic_items tables.
    export function sanitizeFtsQuery(query: string): string {
      const cleaned = query.replace(/[*":()^~{}<>]/g, '');
      const tokens = cleaned.split(/\s+/).filter((t) => t.length > 0);
      return tokens.map((t) => `"${t}"`).join(' ');
    }
  • The searchEquipment database function that builds and executes SQL queries against the equipment table (or delegates to searchMagicItems if rarity filter is set). Returns SearchResult with rows and total count.
    export function searchEquipment(
      db: Database.Database,
      filters: EquipmentFilters,
    ): SearchResult<EquipmentRow | MagicItemRow> {
      // Search both equipment and magic_items tables
      if (filters.rarity) {
        // Rarity filter only applies to magic items
        return searchMagicItems(db, filters);
      }
    
      const conditions: string[] = [];
      const params: (string | number)[] = [];
    
      if (filters.query) {
        const ftsQuery = sanitizeFtsQuery(filters.query);
        if (ftsQuery.length > 0) {
          conditions.push(
            'e.id IN (SELECT rowid FROM equipment_fts WHERE equipment_fts MATCH ?)',
          );
          params.push(ftsQuery);
        }
      }
    
      if (filters.category) {
        conditions.push('LOWER(e.category) = LOWER(?)');
        params.push(filters.category);
      }
    
      if (filters.cost_min !== undefined) {
        conditions.push('e.cost_gp >= ?');
        params.push(filters.cost_min);
      }
    
      if (filters.cost_max !== undefined) {
        conditions.push('e.cost_gp <= ?');
        params.push(filters.cost_max);
      }
    
      if (filters.weight_max !== undefined) {
        conditions.push('e.weight <= ?');
        params.push(filters.weight_max);
      }
    
      if (filters.weapon_property) {
        conditions.push('LOWER(e.weapon_properties) LIKE LOWER(?)');
        params.push(`%${filters.weapon_property}%`);
      }
    
      if (filters.armor_category) {
        conditions.push('LOWER(e.armor_category) = LOWER(?)');
        params.push(filters.armor_category);
      }
    
      const where =
        conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : '';
      const limit = filters.limit ?? 20;
      const offset = filters.offset ?? 0;
    
      const countRow = db
        .prepare(`SELECT COUNT(*) as count FROM equipment e ${where}`)
        .get(...params) as { count: number };
    
      const rows = db
        .prepare(
          `SELECT e.* FROM equipment e ${where} ORDER BY e.name ASC LIMIT ? OFFSET ?`,
        )
        .all(...params, limit, offset) as EquipmentRow[];
    
      return { rows, total: countRow.count };
    }
Behavior3/5

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

With no annotations, the description must convey behavior. It states the tool searches and filters, but does not disclose pagination, return format, or whether it's read-only. The input schema hints at pagination via limit/offset parameters, but the description lacks explicit behavioral details.

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

Conciseness4/5

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

The description is a single sentence that efficiently conveys the tool's purpose and filter options. It is front-loaded and to the point, though it could be slightly more structured to separate the action from filters.

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?

Given the 10 parameters and no output schema, the description is minimal. It covers the search action and some filters but omits details about output behavior, pagination, and typical use cases. It is adequate but not complete.

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 coverage is 100%, so all parameters have descriptions. The description lists filter categories but adds no new semantic value beyond what is already in the schema. Baseline 3 is appropriate.

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 searches D&D 5e SRD equipment, weapons, armor, and magic items, and lists specific filters. This distinguishes it from sibling tools like search_monsters and search_spells, which have different domains.

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 implicitly indicates when to use this tool (for equipment-related searches) and the filtering options guide usage. It does not explicitly exclude other contexts, but the sibling tools cover other domains, making the intended use clear.

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/gregario/dnd-oracle'

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