Skip to main content
Glama

get_pokemon_images

Retrieve Pokémon sprite images including front/back views, shiny variants, and official artwork for any Pokémon by name or ID number.

Instructions

ポケモンのスプライト画像(前面、後面、色違い、公式アートワーク)を取得

Input Schema

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

Implementation Reference

  • Core handler function that fetches Pokemon data via PokeAPI, extracts sprite URLs (front_default, front_shiny, back_default, back_shiny, official_artwork), formats as JSON, and returns in MCP content format. Handles errors gracefully.
    private async getPokemonImages(pokemon: string) {
      try {
        const data = await this.fetchPokemonData(pokemon);
    
        // 画像情報を整理
        const images = {
          name: data.name,
          id: data.id,
          sprites: {
            front_default: data.sprites.front_default,     // 通常の前面画像
            front_shiny: data.sprites.front_shiny,         // 色違いの前面画像
            back_default: data.sprites.back_default,       // 通常の後面画像
            back_shiny: data.sprites.back_shiny,           // 色違いの後面画像
            official_artwork: data.sprites.other["official-artwork"].front_default  // 公式アートワーク
          }
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(images, null, 2)
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `エラー: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • src/index.ts:97-110 (registration)
    Tool registration in ListTools handler: defines name, Japanese description, and input schema requiring 'pokemon' as string.
    {
      name: "get_pokemon_images",
      description: "ポケモンのスプライト画像(前面、後面、色違い、公式アートワーク)を取得",
      inputSchema: {
        type: "object",
        properties: {
          pokemon: {
            type: "string",
            description: "ポケモン名またはID番号",
          },
        },
        required: ["pokemon"],
      },
    },
  • Shared helper function to fetch raw Pokemon data from PokeAPI endpoint, used by getPokemonImages and other tools. Handles 404 and other errors.
    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)}`);
      }
    }
  • TypeScript interface defining PokemonData structure from PokeAPI, including sprites field crucial for image extraction in getPokemonImages.
    interface PokemonData {
      id: number;                    // ポケモンID
      name: string;                  // ポケモン名
      height: number;                // 身長
      weight: number;                // 体重
      base_experience: number;       // 基礎経験値
      stats: Array<{                 // ステータス配列
        base_stat: number;           // 基礎ステータス値
        stat: {
          name: string;              // ステータス名
        };
      }>;
      sprites: {                     // スプライト画像URL
        front_default: string | null;    // 通常の前面画像
        front_shiny: string | null;      // 色違いの前面画像
        back_default: string | null;     // 通常の後面画像
        back_shiny: string | null;       // 色違いの後面画像
        other: {
          "official-artwork": {
            front_default: string | null;  // 公式アートワーク
          };
        };
      };
      types: Array<{                 // タイプ配列
        type: {
          name: string;              // タイプ名
        };
      }>;
    }

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