Skip to main content
Glama

trakt_search

Search Trakt.tv to find movies and shows by query, type, or year, returning up to 100 results.

Instructions

Search for movies and shows on Trakt.tv

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
typeNoOptional media type filter
yearNoOptional year filter
limitNoMax results to return (default: 100)

Implementation Reference

  • The main handler function `traktSearch()` that executes the tool logic. It calls `this.traktClient.search(query, type, year)`, maps results (movies/shows), truncates overviews, and returns a success/error response.
    /**
     * MCP Function: trakt_search
     * Search for content on Trakt
     */
    async traktSearch(query: string, type?: 'movie' | 'show', year?: number, limit?: number): Promise<Record<string, unknown>> {
      if (!this.isInitialized) {
        this.initializeTraktClient();
      }
    
      const effectiveLimit = limit || TRAKT_PREVIEW_LIMIT;
      try {
        const results = await this.traktClient.search(query, type, year);
    
        return {
          success: true,
          query,
          type: type || 'all',
          year,
          results: results.slice(0, effectiveLimit).map(result => {
            const media = result.type === 'movie' ? result.movie : result.show;
            return {
              type: result.type,
              score: result.score,
              [result.type]: {
                title: media?.title,
                year: media?.year,
                ids: media?.ids,
                overview: media?.overview ? truncate(media.overview, SUMMARY_PREVIEW_LENGTH) : undefined
              }
            };
          }),
          totalResults: results.length,
          showing: Math.min(effectiveLimit, results.length)
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Search failed'
        };
      }
    }
  • Input schema definition for trakt_search tool. Defines properties: query (string, required), type (enum: movie|show, optional), year (number, optional), limit (number, optional, default: 100).
    {
      name: "trakt_search",
      description: "Search for movies and shows on Trakt.tv",
      inputSchema: {
        type: "object" as const,
        properties: {
          query: { type: "string", description: "Search query" },
          type: { type: "string", enum: ["movie", "show"], description: "Optional media type filter" },
          year: { type: "number", description: "Optional year filter" },
          limit: { type: "number", description: "Max results to return (default: 100)", default: 100 },
        },
        required: ["query"],
      },
    },
  • Registration of the 'trakt_search' tool in the registry, wiring up args to the traktFunctions.traktSearch() call.
    registry.register("trakt_search", (args) =>
      traktFunctions.traktSearch(
        args.query as string,
        args.type as "movie" | "show" | undefined,
        args.year as number | undefined,
        args.limit as number | undefined,
      ).then(wrapResponse)
    );
  • Type definition `TraktSearchResult` interface with type, score, movie (optional TraktMovie), show (optional TraktShow) used by the client search method.
    export interface TraktSearchResult {
      type: string;
      score: number;
      movie?: TraktMovie;
      show?: TraktShow;
    }
  • The TraktClient.search() method that makes the HTTP GET request to the Trakt API /search endpoint.
    async search(query: string, type?: 'movie' | 'show', year?: number): Promise<TraktSearchResult[]> {
      const params = new URLSearchParams({ query });
      if (type) params.append('type', type);
      if (year) params.append('year', year.toString());
    
      const response = await this.http.get(`/search/${type || 'movie,show'}?${params.toString()}`);
      return response.data;
    }
Behavior2/5

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

No annotations exist, and the description does not disclose behavioral traits such as authentication requirements, rate limits, or result format. Agents are left guessing about side effects or constraints.

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?

A single sentence with no unnecessary words. The key information is front-loaded and efficiently communicated.

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?

Without output schema or annotations, the description is too minimal. It does not explain return values, pagination, or integration with other Trakt tools (e.g., authentication), leaving the agent underinformed.

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%, and parameters are largely self-evident. The description does not enrich understanding beyond what the schema already provides, earning a baseline score of 3.

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 verb (search) and resource (movies and shows on Trakt.tv), distinguishing it from sibling tools that manage libraries or perform other actions. However, it could be more specific about the scope (e.g., full catalog vs personal lists).

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'search_media', 'sonarr_search', or 'radarr_search'. The description lacks context on prerequisites or exclusions.

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/niavasha/plex-mcp-server'

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