search_pokemon_by_ability
Find all Pokemon that can have a specific ability. Use this tool to identify which Pokemon possess a particular ability for competitive battle strategy and team building.
Instructions
Find all Pokemon that can have a specific ability.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ability | Yes | Ability name to search for |
Implementation Reference
- src/pokemon_server.py:384-399 (handler)The handler logic within the @server.call_tool() function. Extracts the 'ability' argument, calls the loader's get_pokemon_with_ability method, formats a response listing matching Pokemon (up to 50), and returns it as TextContent.elif name == "search_pokemon_by_ability": ability = arguments["ability"] pokemon_list = loader.get_pokemon_with_ability(ability) if not pokemon_list: return [TextContent(type="text", text=f"No Pokemon found with ability '{ability}'.")] response = f"""## Pokemon with {ability.title()} Found {len(pokemon_list)} Pokemon: {', '.join(sorted(pokemon_list)[:50])} """ if len(pokemon_list) > 50: response += f"\n... and {len(pokemon_list) - 50} more." return [TextContent(type="text", text=response)]
- src/pokemon_server.py:274-287 (registration)Registers the tool in the list_tools() function, including name, description, and input schema requiring an 'ability' string parameter.Tool( name="search_pokemon_by_ability", description="Find all Pokemon that can have a specific ability.", inputSchema={ "type": "object", "properties": { "ability": { "type": "string", "description": "Ability name to search for" } }, "required": ["ability"] } ),
- src/pokemon_server.py:277-286 (schema)Input schema defining the tool's required parameter: an 'ability' string.inputSchema={ "type": "object", "properties": { "ability": { "type": "string", "description": "Ability name to search for" } }, "required": ["ability"] }
- src/data_loader.py:142-155 (helper)Helper method in PokemonDataLoader class that implements the search: iterates over all Pokemon data, checks if the normalized ability name matches any in the Pokemon's abilities dictionary, collects matching Pokemon names.def get_pokemon_with_ability(self, ability_name: str) -> list[str]: """Find all Pokemon that can have a specific ability.""" self.load_all() ability_lower = ability_name.lower() result = [] for poke_id, poke_data in self.pokemon.items(): abilities = poke_data.get("abilities", {}) for ability in abilities.values(): if ability.lower() == ability_lower: result.append(poke_data.get("name", poke_id)) break return result