fetch_pokemon
Retrieve detailed Pokémon data, including stats, abilities, sprites, and battle mechanics, by entering the Pokémon's name or ID through the Pokédex MCP Server.
Instructions
Fetch detailed information about a Pokémon by name or ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name or ID of the Pokémon |
Implementation Reference
- src/tools.ts:21-28 (handler)The async handler function that implements the core logic of the fetch_pokemon tool: fetches Pokemon data via pokeAPI and formats the response.async ({ name }) => { try { const pokemon = await pokeAPI.getPokemon(name.toLowerCase().trim()); return formatPokemon(pokemon); } catch (error) { return formatCaughtError(error, "fetching Pokémon"); } },
- src/tools.ts:18-20 (schema)Zod schema defining the input parameter 'name' 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)Registration of the fetch_pokemon tool using McpServer.tool(), including 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"); } }, );
- src/client.ts:191-193 (helper)PokeAPI client method getPokemon() called by the tool handler to fetch raw Pokemon data from the API.async getPokemon(idOrName: string | number): Promise<Pokemon> { return this.fetchAPI<Pokemon>(`/pokemon/${idOrName}`); }
- src/formatters.ts:25-61 (helper)Helper function formatPokemon() that formats the raw Pokemon data into a structured 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}` : ""}`, }, ], }; }