Skip to main content
Glama
glaucia86

Star Wars MCP Server

by glaucia86

Buscar Filmes

search_films

Search for Star Wars films by title to find specific movies from the saga and access their details through the SWAPI database.

Instructions

Busca filmes do Star Wars por título

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchYesTítulo do filme para buscar

Implementation Reference

  • Executes the search_films tool: queries SWAPI /films endpoint with search param, formats and returns results as text or error message.
    async ({ search }) => {
      try {
        const response = await this.axiosInstance.get<SearchResponse<Films>>(
          "/films/",
          {
            params: { search },
          }
        );
    
        if (response.data.results.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Nenhum filme encontrado com o título "${search}".`,
              },
            ],
          };
        }
    
        const filmsInfo = response.data.results
          .map((film) => {
            return `Título: ${film.title}
              Episódio: ${film.episode_id}
              Diretor: ${film.director}
              Produtor: ${film.producer}
              Data de Lançamento: ${film.release_date}
              Abertura: ${film.opening_crawl}`;
          })
          .join("\n---\n\n");
    
        return {
          content: [
            {
              type: "text" as const,
              text: `Encontrados ${response.data.results.length} filme(s):\n\n${filmsInfo}`,
            },
          ],
        };
      } catch (error) {
        return this.handleError(error, "buscar filmes");
      }
    }
  • Input schema and metadata (title, description) for the search_films tool, using Zod for validation.
    {
      title: "Buscar Filmes",
      description: "Busca filmes do Star Wars por título",
      inputSchema: {
        search: z.string().describe("Título do filme para buscar"),
      },
    },
  • src/index.ts:143-195 (registration)
    Registers the search_films tool on the MCP server with name, schema, and handler function.
    this.server.registerTool(
      "search_films",
      {
        title: "Buscar Filmes",
        description: "Busca filmes do Star Wars por título",
        inputSchema: {
          search: z.string().describe("Título do filme para buscar"),
        },
      },
      async ({ search }) => {
        try {
          const response = await this.axiosInstance.get<SearchResponse<Films>>(
            "/films/",
            {
              params: { search },
            }
          );
    
          if (response.data.results.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Nenhum filme encontrado com o título "${search}".`,
                },
              ],
            };
          }
    
          const filmsInfo = response.data.results
            .map((film) => {
              return `Título: ${film.title}
                Episódio: ${film.episode_id}
                Diretor: ${film.director}
                Produtor: ${film.producer}
                Data de Lançamento: ${film.release_date}
                Abertura: ${film.opening_crawl}`;
            })
            .join("\n---\n\n");
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Encontrados ${response.data.results.length} filme(s):\n\n${filmsInfo}`,
              },
            ],
          };
        } catch (error) {
          return this.handleError(error, "buscar filmes");
        }
      }
    );
  • TypeScript interface for Film objects returned from SWAPI, used to type the API response in the handler.
    export interface Films {
      title: string;
      episode_id: number;
      opening_crawl: string;
      director: string;
      producer: string;
      release_date: string;
      species: string[];
      starships: string[];
      vehicles: string[];
      characters: string[];
      planets: string[];
      url: string;
      created: string;
      edited: string;
  • Generic type for SWAPI search responses, used as SearchResponse<Films> in the handler.
    export interface SearchResponse<T> {
      count: number;
      next: string | null;
      previous: string | null;
      results: T[];
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It only states the basic function without mentioning any behavioral traits: no information about rate limits, authentication requirements, response format, pagination, error conditions, or what happens with no results. For a search tool with zero annotation coverage, this leaves significant behavioral gaps.

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 extremely concise - a single sentence in Portuguese that directly states the tool's function. There's zero wasted language, and the information is front-loaded. Every word earns its place, making this maximally efficient while still communicating the core purpose.

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 lack of annotations and output schema, the description is incomplete for effective tool use. While the purpose is clear, there's no information about what the tool returns (film objects, IDs, metadata), how results are structured, or any behavioral constraints. For a search tool that presumably returns data, the absence of output information creates significant uncertainty 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?

The schema description coverage is 100%, with the single parameter 'search' already documented as 'Título do filme para buscar'. The description adds no additional parameter semantics beyond what the schema provides - it doesn't clarify search syntax, case sensitivity, language support, or special characters. With complete schema coverage, the baseline 3 is appropriate.

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 action ('Busca' - search) and resource ('filmes do Star Wars' - Star Wars films) with a specific scope ('por título' - by title). It distinguishes from sibling tools that search characters or planets, but doesn't explicitly differentiate from potential other film search tools. The purpose is specific but could be more precise about what makes this search unique.

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?

The description provides no guidance on when to use this tool versus alternatives. While it's clear this searches films while siblings search characters/planets, there's no mention of when to prefer this over other search methods, what types of searches it supports (exact match, partial, fuzzy), or any prerequisites for use. The context is implied but not explicit.

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/glaucia86/swapi-mcp-server-app'

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