get_pokemon
Retrieve competitive Pokemon data including base stats, types, abilities, weight, and tier for battle strategy analysis.
Instructions
Look up a Pokemon by name. Returns base stats, types, abilities with descriptions, weight, and competitive tier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Pokemon name (e.g., 'pikachu', 'slaking', 'charizard') |
Implementation Reference
- src/pokemon_server.py:310-314 (handler)The main handler logic for the 'get_pokemon' tool within the @server.call_tool() function. It retrieves the Pokemon data using the loader and formats it into a response, or returns a not found message.if name == "get_pokemon": pokemon = loader.get_pokemon(arguments["name"]) if pokemon: return [TextContent(type="text", text=format_pokemon_response(pokemon))] return [TextContent(type="text", text=f"Pokemon '{arguments['name']}' not found.")]
- src/pokemon_server.py:185-198 (registration)Registration of the 'get_pokemon' tool in the @server.list_tools() function, including name, description, and input schema.Tool( name="get_pokemon", description="Look up a Pokemon by name. Returns base stats, types, abilities with descriptions, weight, and competitive tier.", inputSchema={ "type": "object", "properties": { "name": { "type": "string", "description": "Pokemon name (e.g., 'pikachu', 'slaking', 'charizard')" } }, "required": ["name"] } ),
- src/data_loader.py:58-71 (helper)Core helper function in PokemonDataLoader that normalizes the Pokemon name and retrieves data from the loaded pokedex.json dictionary.def get_pokemon(self, name: str) -> dict | None: """ Get Pokemon data by name. Args: name: Pokemon name (case-insensitive) Returns: Pokemon data dict or None if not found """ self.load_all() key = name.lower().replace(" ", "").replace("-", "") return self.pokemon.get(key)
- src/pokemon_server.py:35-75 (helper)Helper function that formats the raw Pokemon data into a user-friendly markdown string, including stats, types, tier, weight, and ability descriptions fetched from the loader.def format_pokemon_response(pokemon: dict) -> str: """Format Pokemon data into a readable response.""" name = pokemon.get("name", "Unknown") types = pokemon.get("types", []) stats = pokemon.get("baseStats", {}) abilities = pokemon.get("abilities", {}) weight = pokemon.get("weightkg", 0) tier = pokemon.get("tier", "Unknown") # Get ability descriptions loader = get_loader() ability_details = [] for key, ability_name in abilities.items(): ability_data = loader.get_ability(ability_name) if ability_data: desc = ability_data.get("shortDesc") or ability_data.get("desc", "") slot = "Hidden" if key == "H" else f"Slot {int(key) + 1}" ability_details.append(f" - {ability_name} ({slot}): {desc}") else: slot = "Hidden" if key == "H" else f"Slot {int(key) + 1}" ability_details.append(f" - {ability_name} ({slot})") response = f"""## {name} **Types:** {', '.join(types)} **Tier:** {tier} **Weight:** {weight}kg ### Base Stats - HP: {stats.get('hp', '?')} - Attack: {stats.get('atk', '?')} - Defense: {stats.get('def', '?')} - Sp. Attack: {stats.get('spa', '?')} - Sp. Defense: {stats.get('spd', '?')} - Speed: {stats.get('spe', '?')} - **Total:** {sum(stats.values())} ### Abilities {chr(10).join(ability_details)} """ return response