Skip to main content
Glama
glaucia86

Star Wars MCP Server

by glaucia86

Buscar Planetas

search_planets

Find Star Wars planets by name to get detailed information about their climate, terrain, and population from the official Star Wars API.

Instructions

Busca planetas do Star Wars por nome

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchYesNome do planeta para buscar

Implementation Reference

  • Handler function that searches for planets by name using the SWAPI API, processes the results, and returns formatted text output or handles errors.
      async ({ search }) => {
        try {
          const response = await this.axiosInstance.get<SearchResponse<Planets>>(
            "/planets/",
            {
              params: { search },
            }
          );
    
          if (response.data.results.length === 0) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Nenhum planeta encontrado com o nome "${search}".`,
                },
              ],
            };
          }
    
          const planetsInfo = response.data.results
            .map((planet) => {
              return `Nome: ${planet.name}
                Clima: ${planet.climate}
                Terreno: ${planet.terrain}
                População: ${planet.population}
                Diâmetro: ${planet.diameter}km
                Período de Rotação: ${planet.rotation_period}h
                Período Orbital: ${planet.orbital_period} dias
                `;
            })
            .join("\n---\n\n");
    
          return {
            content: [
              {
                type: "text" as const,
                text: `Encontrados ${response.data.results.length} planeta(s):\n\n${planetsInfo}`,
              },
            ],
          };
        } catch (error) {
          return this.handleError(error, "buscar planetas");
        }
      }
    );
  • Zod input schema defining the 'search' parameter as a string for the search_planets tool.
    inputSchema: {
      search: z.string().describe("Nome do planeta para buscar"),
    },
  • src/index.ts:87-95 (registration)
    Registration of the 'search_planets' tool on the MCP server, including name, title, description, and input schema.
    this.server.registerTool(
      "search_planets",
      {
        title: "Buscar Planetas",
        description: "Busca planetas do Star Wars por nome",
        inputSchema: {
          search: z.string().describe("Nome do planeta para buscar"),
        },
      },
  • TypeScript interface for the Planets type used in the SearchResponse within the handler.
    export interface Planets {
      name: string;
      diameter: string;
      rotation_period: string;
      orbital_period: string;
      gravity: string;
      population: string;
      climate: string;
      terrain: string;
      surface_water: string;
      residents: string[];
      films: string[];
      url: string;
      created: string;
      edited: string;
    }
  • Helper function for standardized error handling in tool executions, called by the search_planets handler.
    private handleError(error: unknown, operation: string) {
      if (axios.isAxiosError(error)) {
        const axiosError = error as AxiosError;
        return {
          content: [
            {
              type: "text" as const,
              text: `Erro ao ${operation}: ${
                axiosError.response?.data ||
                axiosError.message ||
                "Erro desconhecido"
              }`,
            },
          ],
          isError: true,
        };
      }
    
      return {
        content: [
          {
            type: "text" as const,
            text: `Erro inesperado ao ${operation}: ${error}`,
          },
        ],
        isError: true,
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the basic action (search by name) without mentioning what the search returns (e.g., list of planets, partial matches), how results are formatted, error conditions, or any rate limits. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence in Portuguese: 'Busca planetas do Star Wars por nome'. It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for a simple search tool with one parameter.

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's simplicity (1 parameter, 100% schema coverage) but lack of annotations and output schema, the description is incomplete. It doesn't explain what the search returns (e.g., planet details, list of matches), how results are structured, or any behavioral nuances. For a search tool, this leaves the agent guessing about the output format and search behavior.

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%, with the single parameter 'search' documented as 'Nome do planeta para buscar' (Name of the planet to search). The description adds no additional parameter semantics beyond what the schema provides, such as search syntax, case sensitivity, or wildcard support. With high schema coverage, the baseline score of 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 tool's purpose: 'Busca planetas do Star Wars por nome' (Searches Star Wars planets by name). It specifies the verb (busca/searches), resource (planetas/planets), and scope (Star Wars). However, it doesn't explicitly differentiate from sibling tools like search_characters or search_films, which follow similar patterns but target different resources.

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. It doesn't mention sibling tools like search_characters or search_films, nor does it explain when a planet search is appropriate versus character or film searches. There's no context about prerequisites, limitations, or typical use cases.

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