Skip to main content
Glama

search_items

Find TFT items by searching names, descriptions, or components to get accurate game data and prevent AI hallucinations.

Instructions

Search TFT items by name, description, or component. Use componentsOnly to see base components, or the component filter to find what a component builds into.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoFree-text search across item name and description (uses FTS5)
componentNoFilter by component name (shows completed items that use this component)
componentsOnlyNoShow only base components (not completed items)
limitNoMax results to return, 1-50 (default: 20)

Implementation Reference

  • The implementation of the search_items tool.
    export function searchItems(
      db: Database.Database,
      input: SearchItemsInputType,
    ): SearchItemsResult {
      const params: unknown[] = [];
      const conditions: string[] = [];
      const useFts = !!input.query;
    
      // componentsOnly filter
      if (input.componentsOnly) {
        conditions.push('i.isComponent = 1');
      }
    
      // component filter: find items whose composition contains this component's apiName
      if (input.component) {
        // First resolve the component name to its apiName
        const componentRow = db
          .prepare('SELECT apiName FROM items WHERE LOWER(name) = LOWER(?) AND isComponent = 1')
          .get(input.component) as { apiName: string } | undefined;
    
        if (componentRow) {
          conditions.push("i.composition LIKE '%' || ? || '%'");
          params.push(componentRow.apiName);
        } else {
          // Try partial match
          const fuzzyRow = db
            .prepare('SELECT apiName FROM items WHERE LOWER(name) LIKE LOWER(?) AND isComponent = 1')
            .get(`%${input.component}%`) as { apiName: string } | undefined;
    
          if (fuzzyRow) {
            conditions.push("i.composition LIKE '%' || ? || '%'");
            params.push(fuzzyRow.apiName);
          } else {
            // No matching component — return empty
            return { items: [], total: 0 };
          }
        }
      }
    
      const limit = input.limit ?? 20;
    
      let sql: string;
      const allParams: unknown[] = [];
    
      if (useFts) {
        allParams.push(input.query);
        allParams.push(...params);
        allParams.push(limit);
    
        const whereClause =
          conditions.length > 0 ? ' AND ' + conditions.join(' AND ') : '';
    
        sql = `
          SELECT i.name, i.description, i.isComponent, i.composition
          FROM items_fts fts
          JOIN items i ON i.rowid = fts.rowid
          WHERE items_fts MATCH ?${whereClause}
          ORDER BY fts.rank
          LIMIT ?
        `;
      } else {
        allParams.push(...params);
        allParams.push(limit);
    
        const whereClause =
          conditions.length > 0 ? 'WHERE ' + conditions.join(' AND ') : '';
    
        sql = `
          SELECT i.name, i.description, i.isComponent, i.composition
          FROM items i
          ${whereClause}
          ORDER BY i.name
          LIMIT ?
        `;
      }
    
      const rows = db.prepare(sql).all(...allParams) as Array<{
        name: string;
        description: string | null;
        isComponent: number;
        composition: string | null;
      }>;
    
      const items: ItemSummary[] = rows.map((row) => ({
        name: row.name,
        description: truncate(row.description),
        isComponent: row.isComponent === 1,
        composition: compositionSummary(db, row.composition),
      }));
    
      return { items, total: items.length };
    }
  • Input schema for search_items tool using Zod.
    export const SearchItemsInput = z.object({
      query: z
        .string()
        .optional()
        .describe('Free-text search across item name and description (uses FTS5)'),
      component: z
        .string()
        .optional()
        .describe('Filter by component name (shows completed items that use this component)'),
      componentsOnly: z
        .boolean()
        .optional()
        .describe('Show only base components (not completed items)'),
      limit: z
        .number()
        .min(1)
        .max(50)
        .optional()
        .default(20)
        .describe('Max results to return, 1-50 (default: 20)'),
    });
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions search functionality and filtering options but lacks critical details like whether this is a read-only operation, potential rate limits, authentication needs, error conditions, or what the output format looks like (especially since there's no output schema).

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 concise with two sentences that efficiently convey core functionality. It's front-loaded with the main purpose, though it could be slightly more structured by separating search scope from filter explanations.

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

Completeness2/5

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

Given the tool has 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (item data structure, fields included), error handling, or behavioral constraints, leaving significant gaps for an AI agent to understand how to use it effectively.

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 all parameters thoroughly. The description adds minimal value by briefly explaining the purpose of 'componentsOnly' and the 'component' filter, but doesn't provide additional syntax, format details, or examples beyond what's in the schema descriptions.

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

Purpose4/5

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

The description clearly states the tool searches TFT items by name, description, or component, which is a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling tools like 'get_item_recipe' or 'search_augments' beyond mentioning TFT items, leaving some ambiguity about its unique scope.

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

Usage Guidelines3/5

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

The description provides implied usage guidance by explaining when to use 'componentsOnly' or the 'component' filter, but it doesn't explicitly state when to choose this tool over alternatives like 'get_item_recipe' or 'search_champions'. No exclusions or prerequisites are mentioned.

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/tft-oracle'

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