Skip to main content
Glama

play_pokemon_cry

Play the authentic cry of any Pokémon by entering its name or ID number. This tool retrieves and plays the official sound file for Pokémon identification and enjoyment.

Instructions

ポケモンの鳴き声を再生(音声ファイルをダウンロードして情報を返す)

Input Schema

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

Implementation Reference

  • The core handler function that fetches Pokemon data, downloads the cry audio file from PokeAPI cries repo, saves to temp file, plays it using platform-specific commands (PowerShell on Windows, afplay on macOS, aplay/paplay on Linux), handles errors, cleans up temp file, and returns play status information.
    private async playPokemonCry(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`; // 一時ディレクトリとファイル名を作成 const tempDir = path.join(process.cwd(), 'temp'); if (!fs.existsSync(tempDir)) { fs.mkdirSync(tempDir, { recursive: true }); } const fileName = `${data.name}_cry.ogg`; const filePath = path.join(tempDir, fileName); // 音声ファイルをダウンロード const response = await axios.get(cryUrl, { responseType: 'stream' }); const writer = fs.createWriteStream(filePath); response.data.pipe(writer); await new Promise<void>((resolve, reject) => { writer.on('finish', () => resolve()); writer.on('error', reject); }); // プラットフォームに応じて音声再生コマンドを選択 let playCommand: string; const platform = process.platform; if (platform === 'win32') { // Windows: PowerShellでメディアプレイヤーを使用 playCommand = `powershell -c "(New-Object Media.SoundPlayer '${filePath}').PlaySync()"`; } else if (platform === 'darwin') { // macOS: afplayを使用 playCommand = `afplay "${filePath}"`; } else { // Linux: aplayまたはpaplayを使用 playCommand = `aplay "${filePath}" || paplay "${filePath}"`; } // 音声再生を実行 try { await execAsync(playCommand); // 再生後にファイルを削除 fs.unlinkSync(filePath); const playInfo = { name: data.name, id: data.id, cry_url: cryUrl, status: "再生完了", platform: platform, file_saved_temporarily: filePath }; return { content: [ { type: "text", text: JSON.stringify(playInfo, null, 2) } ] }; } catch (playError) { // 再生エラーの場合でもファイル情報は返す const playInfo = { name: data.name, id: data.id, cry_url: cryUrl, status: "ダウンロード完了(再生エラー)", platform: platform, file_saved_at: filePath, play_error: playError instanceof Error ? playError.message : String(playError), manual_play_instructions: platform === 'win32' ? "Windowsメディアプレーヤーまたは対応ソフトでファイルを開いてください" : "音声プレーヤーでファイルを開いてください" }; return { content: [ { type: "text", text: JSON.stringify(playInfo, null, 2) } ] }; } } catch (error) { return { content: [ { type: "text", text: `エラー: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • The input schema definition for the play_pokemon_cry tool, specifying pokemon as required string input.
    { name: "play_pokemon_cry", description: "ポケモンの鳴き声を再生(音声ファイルをダウンロードして情報を返す)", inputSchema: { type: "object", properties: { pokemon: { type: "string", description: "ポケモン名またはID番号", }, }, required: ["pokemon"], }, },
  • src/index.ts:173-175 (registration)
    The dispatch logic in the CallToolRequestSchema handler that routes calls to play_pokemon_cry to the playPokemonCry method.
    } else if (name === "play_pokemon_cry") { return await this.playPokemonCry(args.pokemon as 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