get_type_effectiveness
Retrieve type effectiveness data for Pokémon battles, including strengths, weaknesses, and resistances, to inform strategic decisions.
Instructions
Get type effectiveness information including strengths, weaknesses, and resistances
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name or ID of the type |
Implementation Reference
- src/tools.ts:32-48 (registration)Registers the 'get_type_effectiveness' MCP tool with server.tool(), including description, input schema using zod, and inline handler function.server.tool( "get_type_effectiveness", "Get type effectiveness information including strengths, weaknesses, and resistances", { name: z.string().min(1).describe("The name or ID of the type"), }, async ({ name }) => { try { const effectiveness = await pokeAPI.getTypeEffectiveness( name.toLowerCase().trim(), ); return formatTypeEffectiveness(effectiveness); } catch (error) { return formatCaughtError(error, "fetching type information"); } }, );
- src/tools.ts:38-47 (handler)The tool handler function that executes the core logic: normalizes type name, fetches effectiveness data from pokeAPI, formats the response, and handles errors.async ({ name }) => { try { const effectiveness = await pokeAPI.getTypeEffectiveness( name.toLowerCase().trim(), ); return formatTypeEffectiveness(effectiveness); } catch (error) { return formatCaughtError(error, "fetching type information"); } },
- src/tools.ts:35-37 (schema)Input schema definition using Zod for the tool parameter 'name'.{ name: z.string().min(1).describe("The name or ID of the type"), },
- src/client.ts:248-266 (helper)PokeAPI client method that fetches type data and computes effectiveness multipliers (strong, weak, immune, etc.) from damage_relations.async getTypeEffectiveness(typeName: string): Promise<{ type: Type; strongAgainst: string[]; weakAgainst: string[]; immuneTo: string[]; resistantTo: string[]; vulnerableTo: string[]; }> { const type = await this.getType(typeName); return { type, strongAgainst: type.damage_relations.double_damage_to.map(t => t.name), weakAgainst: type.damage_relations.half_damage_to.map(t => t.name), immuneTo: type.damage_relations.no_damage_to.map(t => t.name), resistantTo: type.damage_relations.half_damage_from.map(t => t.name), vulnerableTo: type.damage_relations.double_damage_from.map(t => t.name), }; }
- src/formatters.ts:66-102 (helper)Helper function to format the type effectiveness data into a user-friendly MCP text response with categorized lists.export function formatTypeEffectiveness(effectiveness: { type: Type; strongAgainst: string[]; weakAgainst: string[]; immuneTo: string[]; resistantTo: string[]; vulnerableTo: string[]; }): MCPResponse { const formatList = (list: string[]) => list.length > 0 ? list.join(", ") : "None"; const pokemonList = effectiveness.type.pokemon .slice(0, 10) .map((p) => p.pokemon.name) .join(", "); const moreCount = effectiveness.type.pokemon.length > 10 ? ` and ${effectiveness.type.pokemon.length - 10} more...` : ""; return { content: [ { type: "text", text: `**${effectiveness.type.name.toUpperCase()} Type Effectiveness** **Strong Against (2x damage to):** ${formatList(effectiveness.strongAgainst)} **Weak Against (0.5x damage to):** ${formatList(effectiveness.weakAgainst)} **No Effect Against (0x damage to):** ${formatList(effectiveness.immuneTo)} **Resistant To (0.5x damage from):** ${formatList(effectiveness.resistantTo)} **Vulnerable To (2x damage from):** ${formatList(effectiveness.vulnerableTo)} **Pokémon with this type:** ${pokemonList}${moreCount}`, }, ], };