Skip to main content
Glama

Sonic Pi MCP

ソニックパイMCP

AIアシスタントがOSCメッセージを介してSonic Piと対話できるようにするModel Context Protocol(MCP)サーバー。これにより、ClaudeやCursorなどのAIツールが音楽を作成したり、Sonic Piをプログラムで制御したりできるようになります。

特徴

  • カスタマイズ可能なシンセパラメータで個々の音符を演奏する
  • 任意のSonic Piコードを実行する
  • あらゆる MCP 互換クライアント (Claude Desktop、Cursor など) で動作します。

前提条件

  • Node.js (v18以上)
  • Sonic Pi (v4.0 以上)
  • MCP 対応クライアント (Cursor、Claude Desktop など)

Sonic Piの設定

MCPサーバーを使用する前に、Sonic Piのバッファに以下のコードを追加する必要があります。このコードは、サーバーから送信されるOSCメッセージを処理します。

# Required Sonic Pi configuration # Add this to a buffer in Sonic Pi and run it live_loop :code_runner do use_real_time code = sync "/osc*/run-code" # Since we receive the code as a string, we can use eval to execute it # The code comes as the first element of the message begin eval(code[0].to_s) rescue Exception => e puts "Error executing code: #{e.message}" end end

MCP サーバーを使用する前に、このコードが Sonic Pi で実行されていることを確認してください。

クライアントとの統合

カーソル

~/.cursor/mcpServers.jsonに追加:

{ "mcpServers": { "sonic_pi_mcp": { "name": "Sonic Pi MCP", "command": "npx", "args": ["-y", "sonic-pi-mcp", "start"], "transport": { "type": "stdio" } } } }
クロードデスクトップ

Claude の MCP 構成に追加:

{ "mcpServers": { "sonic_pi_mcp": { "command": "npx", "args": ["-y", "sonic-pi-mcp", "start"] } } }

利用可能なツール

プレイノート

カスタマイズ可能なパラメータを使用して単音を再生します。

パラメータ:

  • note (必須): MIDIノート番号(0~127)
  • synth (オプション): 使用するシンセ (例: "", "", "")
  • sustain (オプション):音符の長さ(秒)(デフォルト:1)
  • cutoff (オプション):フィルタのカットオフ周波数(デフォルト:100)

例:

// Play middle C with saw wave synth { "name": "play_note", "parameters": { "note": 60, "synth": ":saw", "sustain": 0.5, "cutoff": 80 } }

実行コード

任意の Sonic Pi コードを実行します。

パラメータ:

  • code (必須): 実行するSonic Piコード

例:

{ "name": "run_code", "parameters": { "code": "use_synth :prophet\nplay_pattern_timed [60, 64, 67], [0.5]" } }

使用例

MCP ツールを使用したインタラクションの例を次に示します。

シンプルなメロディー

// Play a C major arpeggio { "code": ` use_synth :piano play_pattern_timed [60, 64, 67, 72], [0.25], release: 0.1 ` }

複雑なパターン

// Create a rhythmic pattern { "code": ` live_loop :rhythm do use_synth :tb303 play choose(chord(:C3, :minor)), release: 0.2, cutoff: rrand(60, 120) sleep 0.25 end ` }

トラブルシューティング

  1. 音が出ない
    • Sonic Piが動作していることを確認する
    • Sonic PiでOSCハンドラーコードが実行されていることを確認します。
    • Sonic Piがポート4560(デフォルト)でリッスンしていることを確認する
  2. 接続エラー
    • サーバーの別のインスタンスが実行中かどうかを確認します
    • Sonic Piを再起動する
    • 他のアプリケーションがポート4560を使用していないことを確認する
  3. コード実行エラー
    • Sonic Piのログウィンドウでエラーメッセージを確認します
    • Sonic Piコードの構文を検証する
    • 必要なシンセサイザーとサンプルがすべて利用可能であることを確認する

発達

# Clone the repository git clone https://github.com/abhishekjairath/sonic-pi-mcp.git cd sonic-pi-mcp # Install dependencies npm install # Build npm run build # Install MCP Inspector globally (for testing) npm install -g @modelcontextprotocol/inspector # Start Sonic Pi and run the OSC handler code (see Sonic Pi Configuration section) # Start the server in one terminal npm run dev # In another terminal, start the MCP Inspector mcp-inspector

MCP Inspectorによるテスト

  1. ブラウザを開き、 http://localhost:3000にアクセスします。
  2. MCP Inspector UI で、接続を構成します。
    • コマンド: node
    • 引数: dist/server.mjs
    • 作業ディレクトリ: /path/to/your/sonic-pi-mcp (実際のプロジェクト パスを使用)
    • トランスポートタイプ: stdio
  3. play_noteツールをテストします。
{ "name": "play_note", "parameters": { "note": 60, "synth": ":beep", "sustain": 0.5 } }
  1. run_codeツールをテストします。
{ "name": "run_code", "parameters": { "code": "use_synth :prophet\nplay_pattern_timed scale(:c4, :major), [0.25]" } }
  1. Sonic Piのログウィンドウでエラーメッセージや出力を確認します

開発上の問題のトラブルシューティング

  1. ビルドエラー
    • npm run buildを実行し、TypeScript エラーを確認します。
    • すべての依存関係が正しくインストールされていることを確認する
    • tsconfig.jsonで適切な設定を確認してください
  2. MCPインスペクターの接続の問題
    • サーバーが実行中であることを確認します ( npm run dev )
    • 作業ディレクトリのパスが正しいことを確認してください
    • サーバーの他のインスタンスが実行されていないことを確認する
  3. OSC通信の問題
    • Sonic Piが実行中であり、OSCハンドラーコードがアクティブであることを確認します。
    • サーバーログで接続エラーを確認してください
    • ポート4560が利用可能であり、ブロックされていないことを確認します

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成します( git checkout -b feature/amazing-feature
  3. 変更をコミットします ( git commit -m 'Add some amazing feature' )
  4. ブランチにプッシュする ( git push origin feature/amazing-feature )
  5. プルリクエストを開く

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

Claude や Cursor などの AI アシスタントが音楽を作成し、OSC メッセージを通じてプログラムで Sonic Pi を制御できるようにするモデル コンテキスト プロトコル サーバー。

  1. 特徴
    1. 前提条件
      1. Sonic Piの設定
        1. クライアントとの統合
          1. カーソル
          2. クロードデスクトップ
        2. 利用可能なツール
          1. プレイノート
          2. 実行コード
        3. 使用例
          1. シンプルなメロディー
          2. 複雑なパターン
        4. トラブルシューティング
          1. 発達
            1. MCP Inspectorによるテスト
            2. 開発上の問題のトラブルシューティング
          2. 貢献
            1. ライセンス

              Related MCP Servers

              • A
                security
                F
                license
                A
                quality
                A lightweight Model Context Protocol server that enables AI assistants like Cursor & Claude to control Spotify playback and manage playlists.
                Last updated -
                12
                77
                TypeScript
              • -
                security
                F
                license
                -
                quality
                A Model Context Protocol server that enables AI assistants like Claude to interact with Spotify, allowing them to search for tracks, control playback, and manage playlists.
                Last updated -
                1
                TypeScript
                • Apple
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol implementation that plays sound effects (completion, error, notification) for Cursor AI and other MCP-compatible environments, providing audio feedback for a more interactive coding experience.
                Last updated -
                Python
                MIT License
                • Apple
                • Linux
              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server that enables real-time interaction with Ableton Live, allowing AI assistants to control song creation, track management, clip operations, and audio recording workflows.
                Last updated -
                23
                12
                24
                TypeScript
                MIT License
                • Linux
                • Apple

              View all related MCP servers

              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/abhishekjairath/sonic-pi-mcp'

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