Skip to main content
Glama
hollanddd

Pokédex MCP Server

by hollanddd

fetch_pokemon

Retrieve detailed Pokémon data including stats, abilities, sprites, and battle mechanics by providing a name or ID. This tool accesses comprehensive information from the Pokédex MCP Server for AI agents.

Instructions

Fetch detailed information about a Pokémon by name or ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name or ID of the Pokémon

Implementation Reference

  • The async handler function for the 'fetch_pokemon' tool. It takes the 'name' parameter, fetches the Pokémon data using pokeAPI.getPokemon, formats it with formatPokemon, and handles errors with formatCaughtError.
    async ({ name }) => {
      try {
        const pokemon = await pokeAPI.getPokemon(name.toLowerCase().trim());
        return formatPokemon(pokemon);
      } catch (error) {
        return formatCaughtError(error, "fetching Pokémon");
      }
    },
  • The Zod input schema defining the 'name' parameter for the 'fetch_pokemon' tool.
    {
      name: z.string().min(1).describe("The name or ID of the Pokémon"),
    },
  • src/tools.ts:15-29 (registration)
    The MCP server.tool registration for 'fetch_pokemon', including name, description, schema, and inline handler.
    server.tool(
      "fetch_pokemon",
      "Fetch detailed information about a Pokémon by name or ID",
      {
        name: z.string().min(1).describe("The name or ID of the Pokémon"),
      },
      async ({ name }) => {
        try {
          const pokemon = await pokeAPI.getPokemon(name.toLowerCase().trim());
          return formatPokemon(pokemon);
        } catch (error) {
          return formatCaughtError(error, "fetching Pokémon");
        }
      },
    );
  • Helper function to format the fetched Pokémon data into a formatted MCP text response.
    export function formatPokemon(pokemon: Pokemon): MCPResponse {
      const stats = pokemon.stats
        .map((s) => `${s.stat.name}: ${s.base_stat}`)
        .join(", ");
      
      const types = pokemon.types.map((t) => t.type.name).join(", ");
      
      const abilities = pokemon.abilities
        .map((a) =>
          a.is_hidden ? `${a.ability.name} (hidden)` : a.ability.name,
        )
        .join(", ");
    
      const artworkUrl = pokemon.sprites.other?.["official-artwork"]?.front_default;
    
      return {
        content: [
          {
            type: "text",
            text: `**${pokemon.name}** (ID: ${pokemon.id})
    Height: ${pokemon.height} decimetres (${(pokemon.height / 10).toFixed(1)}m)
    Weight: ${pokemon.weight} hectograms (${(pokemon.weight / 10).toFixed(1)}kg)
    Base Experience: ${pokemon.base_experience || "N/A"}
    Order: ${pokemon.order || "N/A"}
    
    **Types:** ${types}
    **Abilities:** ${abilities}
    **Base Stats:** ${stats}
    
    **Sprites:**
    - Default: ${pokemon.sprites.front_default || "N/A"}
    - Shiny: ${pokemon.sprites.front_shiny || "N/A"}
    ${artworkUrl ? `- Artwork: ${artworkUrl}` : ""}`,
          },
        ],
      };
    }
  • The PokeAPIClient.getPokemon method called by the handler to fetch raw Pokémon data from the PokeAPI.
    async getPokemon(idOrName: string | number): Promise<Pokemon> {
      return this.fetchAPI<Pokemon>(`/pokemon/${idOrName}`);
    }

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/hollanddd/pokedex-mcp'

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