play-local-sound
Play local sound files on macOS using afplay to trigger audio notifications after AI assistant responses.
Instructions
ローカルのサウンドファイル(sound.mp3)をafplayで再生します。
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "play-local-sound"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:27-45 (handler)The handler function for the 'play-local-sound' tool. It uses child_process.exec to run 'afplay' on the local sound file and resolves with a 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' tool using server.tool(name, description, schema, handler).
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})を再生しました。` }, ], }); } }); }); } ); - src/index.ts:26-26 (schema)Empty input schema object for the 'play-local-sound' tool.
{}, - src/index.ts:7-11 (helper)Helper code to compute the absolute path to the sound file based on command-line argument or default.
// サウンドファイルの絶対パスを取得 const __dirname = path.dirname(fileURLToPath(import.meta.url)); // コマンドライン引数からファイル名を取得(デフォルト: sound.mp3) const soundFileName = process.argv[2] || "sound.mp3"; const soundFile = path.join(__dirname, "..", "sounds", soundFileName);