get_pokemon_encounters
Retrieve detailed encounter locations for any Pokémon by name or ID. Access specific wild encounter data to track Pokémon habitats and spawn areas.
Instructions
Get location encounter information for a Pokémon
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name or ID of the Pokémon |
Implementation Reference
- src/tools.ts:51-65 (registration)MCP server.tool registration for 'get_pokemon_encounters', including description, Zod input schema {name: string}, and inline async handler that fetches encounters via pokeAPI and formats the response.server.tool( "get_pokemon_encounters", "Get location encounter information for a Pokémon", { name: z.string().min(1).describe("The name or ID of the Pokémon") }, async ({ name }) => { try { const { pokemon, encounters } = await pokeAPI.getPokemonWithEncounters( name.toLowerCase().trim(), ); return formatPokemonEncounters(pokemon, encounters); } catch (error) { return formatCaughtError(error, "fetching encounter information"); } }, );
- src/tools.ts:55-64 (handler)The core handler function for the tool: extracts name, calls pokeAPI.getPokemonWithEncounters, formats with formatPokemonEncounters or handles error.async ({ name }) => { try { const { pokemon, encounters } = await pokeAPI.getPokemonWithEncounters( name.toLowerCase().trim(), ); return formatPokemonEncounters(pokemon, encounters); } catch (error) { return formatCaughtError(error, "fetching encounter information"); } },
- src/client.ts:236-246 (helper)PokeAPI helper getPokemonWithEncounters that parallel fetches pokemon details and encounters, returning both.async getPokemonWithEncounters(idOrName: string | number): Promise<{ pokemon: Pokemon; encounters: LocationAreaEncounter[]; }> { const [pokemon, encounters] = await Promise.all([ this.getPokemon(idOrName), this.getPokemonEncounters(idOrName) ]); return { pokemon, encounters }; }
- src/client.ts:195-197 (helper)PokeAPIClient method getPokemonEncounters: fetches raw encounters data from /pokemon/{idOrName}/encounters endpoint.async getPokemonEncounters(idOrName: string | number): Promise<LocationAreaEncounter[]> { return this.fetchAPI<LocationAreaEncounter[]>(`/pokemon/${idOrName}/encounters`); }
- src/formatters.ts:108-154 (helper)formatPokemonEncounters helper: formats pokemon and encounters into MCP text response with location areas, versions, methods, levels, and chances.export function formatPokemonEncounters( pokemon: Pokemon, encounters: LocationAreaEncounter[] ): MCPResponse { if (encounters.length === 0) { return { content: [ { type: "text", text: `**${pokemon.name}** has no recorded wild encounters. This Pokémon might be: - A starter Pokémon - Obtained through evolution - A legendary/mythical Pokémon - Only available through special events`, }, ], }; } const locationInfo = encounters .map((encounter) => { const locationName = encounter.location_area.name.replace("-", " "); const versions = encounter.version_details .map((vd) => { const encounterMethods = vd.encounter_details .map( (ed) => `${ed.method.name} (Lv.${ed.min_level}-${ed.max_level}, ${ed.chance}% chance)`, ) .join(", "); return `${vd.version.name}: ${encounterMethods}`; }) .join("\n "); return `**${locationName}:**\n ${versions}`; }) .join("\n\n"); return { content: [ { type: "text", text: `**${pokemon.name} Encounter Locations:**\n\n${locationInfo}`, }, ], }; }