Skip to main content
Glama
glaucia86

Star Wars MCP Server

by glaucia86

Obter Personagem por ID

get_character_by_id

Retrieve detailed character information from the Star Wars universe using a character ID to access comprehensive data about specific Star Wars characters.

Instructions

Obtém informações detalhadas de um personagem pelo ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesID do personagem

Implementation Reference

  • Executes the tool logic: fetches character details from SWAPI /people/{id} endpoint using axios, formats the response into a text string with key fields, and returns it as content. Catches errors and calls handleError.
    async ({ id }) => {
      try {
        const response = await this.axiosInstance.get<People>(
          `/people/${id}/`
        );
    
        const char = response.data;
        const characterInfo = `Nome: ${char.name}
          Altura: ${char.height}cm
          Massa: ${char.mass}kg
          Cor do Cabelo: ${char.hair_color}
          Cor dos Olhos: ${char.eye_color}
          Ano de Nascimento: ${char.birth_year}
          Gênero: ${char.gender}
          URL do Mundo Natal: ${char.homeworld}
          Número de Filmes: ${char.films.length}`;
    
        return {
          content: [
            {
              type: "text" as const,
              text: characterInfo,
            },
          ],
        };
      } catch (error) {
        return this.handleError(error, `obter personagem com ID ${id}`);
      }
    }
  • Input schema using Zod validation: requires a numeric 'id' parameter for the character ID.
    inputSchema: {
      id: z.number().describe("ID do personagem"),
    },
  • src/index.ts:197-235 (registration)
    Registers the 'get_character_by_id' tool with the MCP server, providing title, description, input schema, and the handler function.
    this.server.registerTool(
      "get_character_by_id",
      {
        title: "Obter Personagem por ID",
        description: "Obtém informações detalhadas de um personagem pelo ID",
        inputSchema: {
          id: z.number().describe("ID do personagem"),
        },
      },
      async ({ id }) => {
        try {
          const response = await this.axiosInstance.get<People>(
            `/people/${id}/`
          );
    
          const char = response.data;
          const characterInfo = `Nome: ${char.name}
            Altura: ${char.height}cm
            Massa: ${char.mass}kg
            Cor do Cabelo: ${char.hair_color}
            Cor dos Olhos: ${char.eye_color}
            Ano de Nascimento: ${char.birth_year}
            Gênero: ${char.gender}
            URL do Mundo Natal: ${char.homeworld}
            Número de Filmes: ${char.films.length}`;
    
          return {
            content: [
              {
                type: "text" as const,
                text: characterInfo,
              },
            ],
          };
        } catch (error) {
          return this.handleError(error, `obter personagem com ID ${id}`);
        }
      }
    );
  • TypeScript interface definition for 'People' used to type the SWAPI response in the get_character_by_id handler.
    export interface People {
      name: string;
      height: string;
      mass: string;
      hair_color: string;
      skin_color: string;
      eye_color: string;
      birth_year: string;
      gender: string;
      homeworld: string;
      films: string[];
      species: string[];
      vehicles: string[];
      starships: string[];
      created: string;
      edited: string;
      url: string;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it 'gets detailed information' without disclosing behavioral traits. It doesn't mention whether this is a read-only operation, potential error cases (e.g., invalid ID), rate limits, authentication needs, or what 'detailed information' entails. For a tool with zero annotation coverage, this is insufficient.

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 that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to understand quickly. Every part of the sentence contributes to clarifying the tool's function.

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 'informações detalhadas' includes in the return values, error handling, or other contextual details needed for effective use. For a tool with no output schema, more detail on returns is warranted.

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 'id' documented as 'ID do personagem'. The description adds no additional meaning beyond this, as it only repeats 'pelo ID'. According to guidelines, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

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 ('Obtém' - gets) and resource ('personagem' - character) with the specific mechanism ('pelo ID' - by ID). It distinguishes from siblings like 'search_characters' by focusing on retrieval of a single character rather than searching. However, it doesn't specify what 'informações detalhadas' includes, keeping it from a perfect score.

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 implies usage when you have a specific character ID, contrasting with 'search_characters' for broader queries. However, it doesn't explicitly state when to use this tool versus alternatives or mention any prerequisites like ID format or existence. The guidance is present but not comprehensive.

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