Skip to main content
Glama
PetitBaguette

play-sound-mcp-server

play-local-sound

Play local sound files on macOS using the afplay command to enable AI assistants to trigger audio notifications after responding.

Instructions

ローカルのサウンドファイル(sound.mp3)をafplayで再生します。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'play-local-sound' tool. It asynchronously executes the 'afplay' command on the local sound file using child_process.exec and resolves with a structured content response (success or error message).
    async () => { return new Promise((resolve) => { exec(`afplay "${soundFile}"`, (error) => { if (error) { resolve({ content: [ { type: "text", text: `サウンド再生に失敗しました: ${error}` }, ], }); } else { resolve({ content: [ { type: "text", text: `サウンド(${soundFileName})を再生しました。` }, ], }); } }); }); }
  • src/index.ts:23-46 (registration)
    Registration of the 'play-local-sound' MCP tool on the McpServer instance, specifying name, Japanese description, empty input schema, and the handler function.
    server.tool( "play-local-sound", `ローカルのサウンドファイル(${soundFileName})をafplayで再生します。`, {}, async () => { return new Promise((resolve) => { exec(`afplay "${soundFile}"`, (error) => { if (error) { resolve({ content: [ { type: "text", text: `サウンド再生に失敗しました: ${error}` }, ], }); } else { resolve({ content: [ { type: "text", text: `サウンド(${soundFileName})を再生しました。` }, ], }); } }); }); } );
  • Empty input schema object for the 'play-local-sound' tool (no parameters required).
    {},
  • Helper code to determine the absolute path of the sound file to play, using __dirname, command-line argument (default 'sound.mp3'), and path.join to locate it in '../sounds/'.
    // サウンドファイルの絶対パスを取得 const __dirname = path.dirname(fileURLToPath(import.meta.url)); // コマンドライン引数からファイル名を取得(デフォルト: sound.mp3) const soundFileName = process.argv[2] || "sound.mp3"; const soundFile = path.join(__dirname, "..", "sounds", soundFileName);

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/PetitBaguette/play-sound-mcp-server'

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