Skip to main content
Glama
ghchen99

MuseScore MCP Server

by ghchen99

MuseScore MCPサーバー

WebSocketベースのプラグインシステムを介してMuseScoreをプログラムで制御するModel Context Protocol (MCP) サーバーです。これにより、ClaudeのようなAIアシスタントが直接MuseScoreを操作し、作曲、歌詞の追加、楽譜のナビゲーションなどを行えるようになります。

Demo GIF

前提条件

  • MuseScore 3.x または 4.x

  • Python 3.8+

  • Claude Desktop または互換性のあるMCPクライアント

Related MCP server: Ableton Copilot MCP

セットアップ

1. MuseScoreプラグインのインストール

まず、QMLプラグインコードをMuseScoreのプラグインディレクトリに保存します:

macOS: ~/Documents/MuseScore4/Plugins/musescore-mcp-websocket.qml Windows: %USERPROFILE%\Documents\MuseScore4\Plugins\musescore-mcp-websocket.qml Linux: ~/Documents/MuseScore4/Plugins/musescore-mcp-websocket.qml

2. MuseScoreでプラグインを有効にする

  1. MuseScoreを開く

  2. プラグイン → プラグインマネージャー に移動

  3. 「MuseScore API Server」を見つけてチェックボックスをオンにする

  4. OK をクリック

3. Python環境のセットアップ

git clone <your-repo>
cd mcp-agents-demo
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install fastmcp websockets

4. Claude Desktopの設定

Claude Desktopの設定ファイルに以下を追加します:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "musescore": {
      "command": "/path/to/your/project/.venv/bin/python",
      "args": [
        "/path/to/your/project/server.py"
      ]
    }
  }
}

注意: パスは実際のプロジェクトの場所に合わせて更新してください。

システムの実行

操作手順

  1. まずMuseScoreを起動し、楽譜を開く

  2. MuseScoreプラグインを実行: プラグイン → MuseScore API Server に移動

    • コンソールに "Starting MuseScore API Server on port 8765" と表示されるはずです

  3. 次にPython MCPサーバーを起動するか、Claude Desktopを再起動する

[insert screenshot of different functionality, harmonisation, melodywriting, as zoomed in GIFs]

開発とテスト

開発にはMCP開発ツールを使用してください:

# Install MCP dev tools
pip install mcp

# Test your server
mcp dev server.py

# Check connection status
mcp dev server.py --inspect

コンソール出力の確認

MuseScoreプラグインのコンソール出力を確認するには、ターミナルからMuseScoreを実行します:

macOS:

/Applications/MuseScore\ 4.app/Contents/MacOS/mscore

Windows:

cd "C:\Program Files\MuseScore 4\bin"
MuseScore.exe

Linux:

musescore4

機能

このMCPサーバーは、包括的なMuseScore制御を提供します。

🌟 このフォークの新機能: 自動的かつ完璧な多声ポリフォニーと、LilyPondへの時間的レイアウトマッピングを内蔵!

ナビゲーションとカーソル制御

  • get_cursor_info() - 現在のカーソル位置と選択情報を取得

  • go_to_measure(measure) - 指定した小節へ移動

  • go_to_beginning_of_score() / go_to_final_measure() - 楽譜の最初/最後に移動

  • next_element() / prev_element() - カーソルを要素ごとに移動

  • next_staff() / prev_staff() - 五線間を移動

  • select_current_measure() - 現在の小節全体を選択

  • select_custom_range(start_tick, end_tick, start_staff, end_staff) - 小節をまたぐ、または複数五線にわたるフレーズを抽出するためのスライスツール

ポリフォニーとLilyPond統合

  • 時間的リズムパディング: ギャップや休符がある声部には、数学的な位置を正確に保持するためにLilyPondのスペーサーシーケンス (s4.) が自動的に適用されます。

  • 同時声部レンダリング: 高度なエージェント処理のために、4声部 (\voiceOne, \voiceTwo など) の配列が五線ごとに正しく構造化および分割されます。

音符と休符の作成

  • add_note(pitch, duration, advance_cursor_after_action) - MIDIピッチで音符を追加

  • add_rest(duration, advance_cursor_after_action) - 休符を追加

  • add_tuplet(duration, ratio, advance_cursor_after_action) - 連符(3連符など)を追加

小節管理

  • insert_measure() - 現在位置に小節を挿入

  • append_measure(count) - 楽譜の末尾に小節を追加

  • delete_selection(measure) - 現在の選択範囲または指定した小節を削除

歌詞とテキスト

  • add_lyrics_to_current_note(text) - 現在の音符に歌詞を追加

  • add_lyrics(lyrics_list) - 複数の音符に歌詞を一括追加

  • set_title(title) - 楽譜のタイトルを設定

楽譜情報

  • get_score() - 楽譜全体の解析と構造を取得

  • ping_musescore() - MuseScoreへの接続をテスト

  • connect_to_musescore() - WebSocket接続を確立

ユーティリティ

  • undo() - 最後のアクションを取り消し

  • set_time_signature(numerator, denominator) - 拍子記号を変更

  • processSequence(sequence) - 複数のコマンドを一括実行

サンプル楽曲

/examples フォルダには、さまざまな音楽スタイルを示すMuseScoreファイルのサンプルがあります:

  • Asian Instrumental - アジアの伝統音楽にインスパイアされたインストゥルメンタル曲

  • String Quartet - クラシックの弦楽四重奏アレンジ

各サンプルには以下が含まれます:

  • .mscz - MuseScoreファイル(編集可能)

  • .pdf - 楽譜

  • .mp3 - オーディオプレビュー

使用例

シンプルなメロディの作成

# Set up the score
await set_title("My First Song")
await go_to_beginning_of_score()

# Add notes (MIDI pitch: 60=C, 62=D, 64=E, etc.)
await add_note(60, {"numerator": 1, "denominator": 4}, True)  # Quarter note C
await add_note(64, {"numerator": 1, "denominator": 4}, True)  # Quarter note E
await add_note(67, {"numerator": 1, "denominator": 4}, True)  # Quarter note G
await add_note(72, {"numerator": 1, "denominator": 2}, True)  # Half note C

# Add lyrics
await go_to_beginning_of_score()
await add_lyrics_to_current_note("Do")
await next_element()
await add_lyrics_to_current_note("Mi")
await next_element()
await add_lyrics_to_current_note("Sol")
await next_element()
await add_lyrics_to_current_note("Do")

一括操作

# Add multiple lyrics at once
await add_lyrics(["Twin-", "kle", "twin-", "kle", "lit-", "tle", "star"])

# Use sequence processing for complex operations
sequence = [
    {"action": "goToBeginningOfScore", "params": {}},
    {"action": "addNote", "params": {"pitch": 60, "duration": {"numerator": 1, "denominator": 4}, "advanceCursorAfterAction": True}},
    {"action": "addNote", "params": {"pitch": 64, "duration": {"numerator": 1, "denominator": 4}, "advanceCursorAfterAction": True}},
    {"action": "addRest", "params": {"duration": {"numerator": 1, "denominator": 4}, "advanceCursorAfterAction": True}}
]
await processSequence(sequence)

スターの履歴

Star History Chart

トラブルシューティング

接続の問題

  • "Not connected to MuseScore":

    • MuseScoreが起動しており、楽譜が開かれていることを確認してください

    • MuseScoreプラグインを実行してください (プラグイン → MuseScore API Server)

    • ポート8765がファイアウォールでブロックされていないことを確認してください

プラグインの問題

  • プラグインが表示されない: .qml ファイルが正しいプラグインディレクトリにあるか確認してください

  • プラグインが有効にならない: プラグインファイルを配置した後、MuseScoreを再起動してください

  • コンソール出力がない: ターミナルからMuseScoreを実行してデバッグメッセージを確認してください

Pythonサーバーの問題

  • "No server object found": サーバーオブジェクトはモジュールレベルで mcpserver、または app という名前である必要があります

  • WebSocketエラー: Pythonサーバーを起動する前にMuseScoreプラグインが実行されていることを確認してください

  • 接続タイムアウト: MuseScoreプラグインは単に有効にするだけでなく、アクティブに実行されている必要があります

APIの制限

  • 歌詞: MuseScore 3.xのプラグインAPIでは第1番のみサポートされています

  • タイトルの設定: フレームアクセスの制限により、複数のフォールバックメソッドを使用しています

  • 選択の永続性: 一部の操作は現在の選択範囲に影響を与える可能性があります

ファイル構造

mcp-agents-demo/
├── .venv/
├── server.py                           # Python MCP server entry point
├── musescore-mcp-websocket.qml         # MuseScore plugin
├── requirements.txt
├── README.md
└── src/                                # Source code modules
    ├── __init__.py
    ├── client/                         # WebSocket client functionality
    │   ├── __init__.py
    │   └── websocket_client.py
    ├── tools/                          # MCP tool implementations
    │   ├── __init__.py
    │   ├── connection.py               # Connection management tools
    │   ├── navigation.py               # Score navigation tools
    │   ├── notes_measures.py           # Note and measure manipulation
    │   ├── sequences.py                # Batch operation tools
    │   ├── staff_instruments.py        # Staff and instrument tools
    │   └── time_tempo.py               # Timing and tempo tools
    └── types/                          # Type definitions
        ├── __init__.py
        └── action_types.py             # WebSocket action type definitions

MIDIピッチリファレンス

参考用の一般的なMIDIピッチ値:

  • 中央ハ (Middle C): 60

  • ハ長調音階: 60, 62, 64, 65, 67, 69, 71, 72

  • 半音階: C=60, C#=61, D=62, D#=63, E=64, F=65, F#=66, G=67, G#=68, A=69, A#=70, B=71

音価リファレンス

音価フォーマット: {"numerator": int, "denominator": int}

  • 全音符: {"numerator": 1, "denominator": 1}

  • 2分音符: {"numerator": 1, "denominator": 2}

  • 4分音符: {"numerator": 1, "denominator": 4}

  • 8分音符: {"numerator": 1, "denominator": 8}

  • 付点4分音符: {"numerator": 3, "denominator": 8}

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to control Unreal E…

  • A Model Context Protocol server for Wix AI tools

View all MCP Connectors

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/ghchen99/mcp-musescore'

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