Skip to main content
Glama
PetitBaguette

play-sound-mcp-server

play-local-sound

Play local sound files on macOS using afplay to trigger audio notifications after AI assistant responses.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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})を再生しました。` },
                ],
              });
            }
          });
        });
      }
    );
  • Empty input schema object for the 'play-local-sound' tool.
    {},
  • 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);
Install Server

Other 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