Skip to main content
Glama

search_traits

Find TFT traits by name or description to access accurate game data. Search or list all traits to prevent AI hallucinations about Teamfight Tactics.

Instructions

Search TFT traits by name or description. Omit the query to list all traits in the current set.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoFree-text search across trait name and description (uses FTS5)
limitNoMax results to return, 1-100 (default: 50)

Implementation Reference

  • The main logic for searching traits using FTS5 or simple listing.
    export function searchTraits(
      db: Database.Database,
      input: SearchTraitsInputType,
    ): SearchTraitsResult {
      const limit = input.limit ?? 50;
    
      let rows: Array<{ name: string; description: string | null; breakpoints: string | null }>;
    
      if (input.query) {
        rows = db
          .prepare(
            `SELECT t.name, t.description, t.breakpoints
             FROM traits_fts fts
             JOIN traits t ON t.rowid = fts.rowid
             WHERE traits_fts MATCH ?
             ORDER BY fts.rank
             LIMIT ?`,
          )
          .all(input.query, limit) as typeof rows;
      } else {
        rows = db
          .prepare(
            `SELECT name, description, breakpoints
             FROM traits
             ORDER BY name
             LIMIT ?`,
          )
          .all(limit) as typeof rows;
      }
    
      const traits: TraitSummary[] = rows.map((row) => ({
        name: row.name,
        description: truncate(row.description, 100),
        breakpointCount: parseBreakpoints(row.breakpoints).length,
      }));
    
      return { traits, total: traits.length };
    }
  • Zod schema defining the input for the search_traits tool.
    export const SearchTraitsInput = z.object({
      query: z
        .string()
        .optional()
        .describe('Free-text search across trait name and description (uses FTS5)'),
      limit: z
        .number()
        .min(1)
        .max(100)
        .optional()
        .default(50)
        .describe('Max results to return, 1-100 (default: 50)'),
    });
  • src/server.ts:87-97 (registration)
    Registration of the search_traits tool in the MCP server.
    // 3. search_traits
    server.tool(
      'search_traits',
      'Search TFT traits by name or description. Omit the query to list all traits in the current set.',
      SearchTraitsInput.shape,
      async (params) => {
        try {
          const result = searchTraits(db, params);
          return {
            content: [{ type: 'text' as const, text: formatSearchTraits(result) }],
          };

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