MCP Server - Model Context Protocol

MidiEditor AI includes a built-in MCP (Model Context Protocol) server that lets any MCP-compatible AI client - Claude Desktop, VS Code Copilot, Cursor, Windsurf, Continue, and others - directly use MidiEditor’s MIDI editing tools. Instead of copy-pasting between your AI client and the editor, the AI can read your MIDI file, create tracks, insert notes, set tempo, and more - all through a standard protocol.

Protocol panel showing MidiPilotMCP actions from VS Code Copilot
Protocol panel showing MidiPilotMCP actions with client identification

What is MCP?

The Model Context Protocol is an open standard that lets AI models discover and use external tools. Think of it like a USB port for AI - any AI client that speaks MCP can plug into MidiEditor AI and control it.

MidiEditor AI’s MCP server exposes the same 15 tools that the built-in MidiPilot AI uses. The difference is that with MCP, you choose which AI client and model to use.


Demo & Examples

See MidiEditor AI's MCP server in action with this AI-composed metal remix of Mozart's Eine kleine Nachtmusik - created using the MCP protocol with shredding guitars, strings, and drums:

MCP Server Demo - Metal Mozart
Metal remix composition in MidiEditor AI
MCP Protocol Panel - Metal Mozart
Protocol panel showing MCP agent actions

Listen & Download:

🔊 Listen

This demo shows how an external MCP client (Claude, VS Code Copilot, Cursor, etc.) can compose music by calling MidiEditor AI's tools. All 20 measures were created via the MCP protocol with a guitar solo in the middle.


Quick Start

  1. Enable the MCP Server
    Go to Edit → Settings → AI Settings. In the MCP Server section, check “Start MCP server on launch”. Optionally generate an auth token for security.
  2. Copy the Config
    Click “Copy MCP Config to Clipboard”. This copies a ready-to-paste JSON snippet with the URL, port, and auth token.
  3. Paste into Your AI Client
    Add the JSON to your client’s MCP configuration file (see Client Setup below).
  4. Restart Your AI Client
    The MCP server starts immediately when you check the box in Settings. Just restart your AI client (Claude Desktop, VS Code, Cursor, etc.) so it connects to the running server.
  5. Start Editing
    Open a MIDI file in MidiEditor AI, then ask your AI client to compose, edit, or analyze. All changes appear live in the editor with full undo support.
MCP Server settings in AI Settings dialog
MCP Server settings - enable, configure port, generate auth token, copy config

Toolbar Toggle Button

You can also start and stop the MCP server directly from the toolbar without opening Settings. The MCP Server button shows the server status at a glance:

MCP Server running (green) Green - MCP server is running and accepting connections
MCP Server stopped (gray) Gray - MCP server is stopped

Click the button to toggle the server on or off. The toolbar button stays in sync with the checkbox in Settings. You can reposition or hide it via Edit → Settings → Layout → Customize Toolbar.


Client Setup

Click “Copy MCP Config to Clipboard” in MidiEditor AI’s settings, then paste it into the appropriate config file for your AI client.

Edit %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "midieditor": {
      "url": "http://localhost:9420/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN_HERE"
      }
    }
  }
}

Restart Claude Desktop after saving.

Add to your VS Code settings.json or create .vscode/mcp.json in your workspace:

// settings.json
{
  "mcp": {
    "servers": {
      "midieditor": {
        "url": "http://localhost:9420/mcp",
        "headers": {
          "Authorization": "Bearer YOUR_TOKEN_HERE"
        }
      }
    }
  }
}
// .vscode/mcp.json
{
  "servers": {
    "midieditor": {
      "url": "http://localhost:9420/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN_HERE"
      }
    }
  }
}

Edit ~/.cursor/mcp.json:

{
  "mcpServers": {
    "midieditor": {
      "url": "http://localhost:9420/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN_HERE"
      }
    }
  }
}

Edit ~/.windsurf/mcp_config.json:

{
  "mcpServers": {
    "midieditor": {
      "url": "http://localhost:9420/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN_HERE"
      }
    }
  }
}

The MCP server uses Streamable HTTP transport (MCP 2025-03-26) on a single endpoint:

EndpointMethodDescription
/mcpPOSTJSON-RPC 2.0 messages (initialize, tools/call, etc.)
/mcpGETSSE stream for server-initiated notifications
/mcpDELETEEnd session

Include the Mcp-Session-Id header (returned by initialize) in all subsequent requests.


Available Tools

All 15 tools from MidiEditor AI’s built-in MidiPilot are exposed via MCP. The AI client discovers them automatically via tools/list.

Read-Only Tools READ

ToolDescription
get_editor_stateGet file info, tracks, cursor position, tempo, time signature, and selected events
get_track_infoGet details about a specific track (name, channel, note count, pitch range)
query_eventsQuery MIDI events in a tick range on a track

Write Tools WRITE

ToolParametersDescription
create_tracktrackName, channelCreate a new MIDI track
rename_tracktrackIndex, newNameRename an existing track
set_channeltrackIndex, channelSet the MIDI channel for a track
insert_eventstrackIndex, eventsInsert MIDI events (notes, program changes, CCs)
replace_eventstrackIndex, startTick, endTick, eventsReplace events in a tick range
delete_eventstrackIndex, startTick, endTickDelete events in a tick range
set_tempobpm, tickSet tempo at a tick position
set_time_signaturenumerator, denominator, tickSet time signature at a tick position
move_events_to_tracksourceTrackIndex, targetTrackIndex, startTick, endTickMove events between tracks

FFXIV Tools FFXIV

These tools appear automatically when FFXIV mode is enabled in MidiEditor AI. The server sends a notifications/tools/list_changed notification when FFXIV mode is toggled, so connected clients refresh their tool list automatically.

ToolDescription
validate_ffxivCheck if the file meets FFXIV Bard Performance constraints
convert_drums_ffxivConvert a GM drum track into FFXIV drum instrument tracks
setup_channel_patternFix FFXIV channel assignments and program_change events

MCP Resources

MCP resources provide read-only context. AI clients can read these to understand the current editor state without making tool calls.

URIDescription
midi://stateFull editor state - file info, all tracks, cursor, tempo, time signature
midi://tracksTrack list with names, channels, and event counts
midi://configFFXIV mode status, file path, ticks per beat, current tempo

Protocol Panel & Client Identification

Every tool call made via MCP appears in the Protocol panel with a special prefix that identifies the source client. During the MCP initialize handshake, the client sends its name and version in the clientInfo field. MidiEditor AI displays this in the Protocol panel:

This makes it easy to see which actions came from where - especially useful when both the built-in MidiPilot and an external MCP client are used on the same file. Every MCP action supports Ctrl+Z undo, just like built-in actions.

Protocol panel showing MidiPilotMCP prefix with client identification
Protocol panel - MCP actions with client name and model identification

Security

The MCP server is designed for local use only:

FeatureDescription
Localhost bindingListens on 127.0.0.1 only - not accessible from the network
Origin validationRejects requests with non-local Origin headers (DNS rebinding protection)
Auth tokenOptional Bearer token authentication - generate one in Settings
Rate limiting100 tool calls per minute per session
Session managementSessions expire after 1 hour of inactivity

For personal use on your own machine, the server is safe without an auth token since it only accepts local connections. If you share your machine or want defense in depth, generate a token in Settings.


Limits & Performance

The MCP server enforces rate limits and has practical performance boundaries. AI clients should be aware of these when composing or editing large MIDI files.

LimitValueNotes
Rate limit100 tool calls / minutePer session. Resets every 60 seconds. Applies to all tools combined.
Max request body1 MBRequests exceeding 1 MB are rejected with HTTP 413.
Events per call (fast)~2,000Recommended maximum for sub-500ms response time.
Events per call (max)~10,000Possible but may take 5-12 seconds. Body size ~660 KB.
Maximum tracks100+No hard limit. 100 tracks tested successfully.
Session expiry1 hourSessions expire after 1 hour of inactivity.

Best Practices for Large Compositions


Troubleshooting

Server won’t start

Client can’t connect

Tools not showing up

“Rate limit exceeded” error


Technical Details

DetailValue
MCP version2025-03-26
TransportStreamable HTTP (single /mcp endpoint)
EncodingJSON-RPC 2.0 over HTTP
Default port9420
Session headerMcp-Session-Id
Auth headerAuthorization: Bearer <token>
Thread safetyAll tool calls execute on the Qt main thread via BlockingQueuedConnection
Session expiry1 hour of inactivity
Rate limit100 tool calls per minute per session
Max request body1 MB (HTTP 413 if exceeded)
Max events per call~10,000 (recommended: ~2,000 for fast response)

Session Lifecycle

  1. Client sends POST /mcp with initialize
  2. Server responds with capabilities and Mcp-Session-Id header
  3. Client includes Mcp-Session-Id in all subsequent requests
  4. Client optionally opens SSE stream via GET /mcp
  5. Client sends DELETE /mcp to end session (or it expires after 1 hour)