Skip to main content
Glama

get_pokemon_stats

Retrieve base Pokémon statistics including HP, attack, defense, special attack, special defense, and speed by providing a Pokémon name or ID number.

Instructions

ポケモンの基礎ステータス(HP、こうげき、ぼうぎょ、とくこう、とくぼう、すばやさ)を取得

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pokemonYesポケモン名またはID番号

Implementation Reference

  • The core handler function that fetches Pokemon data from the PokeAPI, extracts and formats the base stats (HP, attack, defense, special-attack, special-defense, speed), includes additional info like name, id, types, and base_experience, and returns it as MCP-formatted content or an error.
    private async getPokemonStats(pokemon: string) {
      try {
        const data = await this.fetchPokemonData(pokemon);
    
        // ステータス情報を初期化
        const stats: PokemonStats = {
          hp: 0,
          attack: 0,
          defense: 0,
          "special-attack": 0,
          "special-defense": 0,
          speed: 0
        };
    
        // APIから取得したステータスデータを整形
        data.stats.forEach(stat => {
          const statName = stat.stat.name as keyof PokemonStats;
          if (statName in stats) {
            stats[statName] = stat.base_stat;
          }
        });
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                name: data.name,
                id: data.id,
                stats: stats,
                types: data.types.map(t => t.type.name),
                base_experience: data.base_experience
              }, null, 2)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `エラー: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • src/index.ts:83-96 (registration)
    Tool registration in the listTools response, including name, description, and input schema.
    {
      name: "get_pokemon_stats",
      description: "ポケモンの基礎ステータス(HP、こうげき、ぼうぎょ、とくこう、とくぼう、すばやさ)を取得",
      inputSchema: {
        type: "object",
        properties: {
          pokemon: {
            type: "string",
            description: "ポケモン名またはID番号",
          },
        },
        required: ["pokemon"],
      },
    },
  • Input schema definition for the get_pokemon_stats tool, specifying the required 'pokemon' string parameter.
    inputSchema: {
      type: "object",
      properties: {
        pokemon: {
          type: "string",
          description: "ポケモン名またはID番号",
        },
      },
      required: ["pokemon"],
    },
  • TypeScript interface defining the structure of Pokemon stats used in the handler.
    interface PokemonStats {
      hp: number;                    // HP(ヒットポイント)
      attack: number;                // こうげき
      defense: number;               // ぼうぎょ
      "special-attack": number;      // とくこう
      "special-defense": number;     // とくぼう
      speed: number;                 // すばやさ
    }
  • Helper function to fetch raw Pokemon data from PokeAPI, used by the getPokemonStats handler.
    private async fetchPokemonData(pokemon: string): Promise<PokemonData> {
      try {
        const response = await axios.get(`https://pokeapi.co/api/v2/pokemon/${pokemon.toLowerCase()}`);
        return response.data;
      } catch (error) {
        if (axios.isAxiosError(error) && error.response?.status === 404) {
          throw new Error(`ポケモン "${pokemon}" が見つかりません`);
        }
        throw new Error(`ポケモンデータの取得に失敗しました: ${error instanceof Error ? error.message : String(error)}`);
      }
    }

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/t-daiki96/poke_mcp'

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