Skip to main content
Glama

get_type_effectiveness

Retrieve detailed type effectiveness data for Pokémon, including strengths, weaknesses, and resistances, to optimize battle strategies using a specific type name or ID.

Instructions

Get type effectiveness information including strengths, weaknesses, and resistances

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name or ID of the type

Implementation Reference

  • src/tools.ts:32-48 (registration)
    Registers the 'get_type_effectiveness' MCP tool with the server, specifying name, description, input schema, and 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"); } }, );
  • Handler function that executes the tool logic: fetches type effectiveness data via PokeAPI client and formats the response, handling errors.
    async ({ name }) => { try { const effectiveness = await pokeAPI.getTypeEffectiveness( name.toLowerCase().trim(), ); return formatTypeEffectiveness(effectiveness); } catch (error) { return formatCaughtError(error, "fetching type information"); } },
  • Zod input schema validating the 'name' parameter for the tool.
    { name: z.string().min(1).describe("The name or ID of the type"), },
  • PokeAPI client method that fetches type data and computes effectiveness categories (strong, weak, immune, etc.).
    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), }; }
  • Formatter function that converts type effectiveness data into a formatted MCP text response.
    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}`, }, ], };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hollanddd/pokedex-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server