get_pokemon_cry
Retrieve Pokémon cry audio file URLs by providing the Pokémon name or ID number. Use this tool to access authentic Pokémon sounds for applications or analysis.
Instructions
ポケモンの鳴き声音声ファイルのURLを取得
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pokemon | Yes | ポケモン名またはID番号 |
Implementation Reference
- src/index.ts:284-324 (handler)The handler function that implements the get_pokemon_cry tool. It fetches Pokemon data from PokeAPI, constructs the cry URL using the Pokemon's ID, verifies the URL exists, and returns the cry information as JSON.private async getPokemonCry(pokemon: string) { try { const data = await this.fetchPokemonData(pokemon); // 鳴き声ファイルのURL(PokeAPI/cries リポジトリから) const cryUrl = `https://raw.githubusercontent.com/PokeAPI/cries/main/cries/pokemon/latest/${data.id}.ogg`; // URLが有効かチェック const response = await axios.head(cryUrl); if (response.status !== 200) { throw new Error(`鳴き声ファイルが見つかりません: ${cryUrl}`); } const cryInfo = { name: data.name, id: data.id, cry_url: cryUrl, format: "ogg", source: "PokeAPI/cries repository" }; return { content: [ { type: "text", text: JSON.stringify(cryInfo, null, 2) } ] }; } catch (error) { return { content: [ { type: "text", text: `エラー: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/index.ts:128-137 (schema)The input schema for the get_pokemon_cry tool, specifying a required 'pokemon' string parameter.inputSchema: { type: "object", properties: { pokemon: { type: "string", description: "ポケモン名またはID番号", }, }, required: ["pokemon"], },
- src/index.ts:125-138 (registration)Tool registration in the ListTools response, defining name, description, and input schema.{ name: "get_pokemon_cry", description: "ポケモンの鳴き声音声ファイルのURLを取得", inputSchema: { type: "object", properties: { pokemon: { type: "string", description: "ポケモン名またはID番号", }, }, required: ["pokemon"], }, },
- src/index.ts:171-172 (registration)Dispatch logic in the CallToolRequest handler that routes calls to the getPokemonCry method.} else if (name === "get_pokemon_cry") { return await this.getPokemonCry(args.pokemon as string);