This MCP server provides programmatic control over MuseScore through a WebSocket-based plugin system, allowing AI assistants like Claude to compose music, add lyrics, navigate scores, and control MuseScore directly. You'll be able to automate music creation and manipulation tasks through a simple API.
Save the QML plugin code to your MuseScore plugins directory:
~/Documents/MuseScore4/Plugins/musescore-mcp-websocket.qml
%USERPROFILE%\Documents\MuseScore4\Plugins\musescore-mcp-websocket.qml
~/Documents/MuseScore4/Plugins/musescore-mcp-websocket.qml
Enable the plugin in MuseScore:
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
Add to your Claude Desktop configuration file:
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"
]
}
}
}
Note: Update the paths to match your actual project location.
The order of operations is important:
"Starting MuseScore API Server on port 8765"
For development and testing:
# Install MCP dev tools
pip install mcp
# Test your server
mcp dev server.py
# Check connection status
mcp dev server.py --inspect
To see MuseScore plugin console output, run MuseScore from terminal:
macOS:
/Applications/MuseScore\ 4.app/Contents/MacOS/mscore
Windows:
cd "C:\Program Files\MuseScore 4\bin"
MuseScore.exe
Linux:
musescore4
await get_cursor_info() # Get current cursor position and selection info
await go_to_measure(5) # Navigate to measure 5
await go_to_beginning_of_score() # Go to start
await go_to_final_measure() # Go to end
await next_element() # Move to next element
await prev_element() # Move to previous element
await next_staff() # Move to staff below
await prev_staff() # Move to staff above
await select_current_measure() # Select entire current measure
# Add a quarter note C (MIDI pitch 60)
await add_note(60, {"numerator": 1, "denominator": 4}, True)
# Add a quarter rest
await add_rest({"numerator": 1, "denominator": 4}, True)
# Add a triplet
await add_tuplet({"numerator": 1, "denominator": 8}, {"numerator": 3, "denominator": 2}, True)
await insert_measure() # Insert measure at cursor
await append_measure(4) # Add 4 measures to end of score
await delete_selection() # Delete current selection
# Add lyrics to current note
await add_lyrics_to_current_note("Hello")
# Batch add lyrics to multiple notes
await add_lyrics(["Twin-", "kle", "twin-", "kle", "lit-", "tle", "star"])
# Set score title
await set_title("My Composition")
await get_score() # Get complete score analysis
await ping_musescore() # Test connection
await connect_to_musescore() # Establish WebSocket connection
# 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)
.qml
file is in the correct plugins directorymcp
, server
, or app
at module levelCommon MIDI pitch values:
Duration format: {"numerator": int, "denominator": int}
{"numerator": 1, "denominator": 1}
{"numerator": 1, "denominator": 2}
{"numerator": 1, "denominator": 4}
{"numerator": 1, "denominator": 8}
{"numerator": 3, "denominator": 8}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "musescore" '{"command":"/path/to/your/project/.venv/bin/python","args":["/path/to/your/project/server.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"musescore": {
"command": "/path/to/your/project/.venv/bin/python",
"args": [
"/path/to/your/project/server.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"musescore": {
"command": "/path/to/your/project/.venv/bin/python",
"args": [
"/path/to/your/project/server.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect