11 KiB
Project CLAUDE.md
This is the canonical project context file for any AI agent working in this repository.
If you are Kimi K2, Claude Code, Codex, GLM, Qwen, or any other model:
- read this file first
- treat it as the highest-signal project handoff
- use it before exploring code, making edits, debugging, or declaring success
Mission
This project is not a toy loop generator.
The goal is to operate Ableton Live 12 through MCP and a Remote Script so an AI agent can:
- inspect the Live set
- create and edit tracks and clips
- generate musical arrangements
- analyze references
- retrieve local samples
- leave the final result audible, editable, and stable
Mandatory Read Order
Read in this order before doing substantial work:
C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\CLAUDE.mdC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\KIMI_K2_CODEBASE_FIXES.md- inspect the active entrypoints and code directly
Do not trust stale docs over live code. Do not trust live code over runtime evidence.
Project Roots
User-facing project root:
C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts
Actual MCP code root used by the wrapper:
C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\AbletonMCP_AI
Environment Rules
This machine is using native Windows paths.
- prefer PowerShell commands, not bash
- do not use
/c/...paths - do not assume
Program Filesif the executable was already verified elsewhere - when in doubt, use the exact absolute paths documented in this file
Verified executable paths:
- active Ableton install:
C:\ProgramData\Ableton\Live 12 Suite\Program\Ableton Live 12 Suite.exe - backup or parallel updated install:
C:\ProgramData\Ableton\.Live 12 Suite_updated\Program\Ableton Live 12 Suite.exe
Current Active Execution Paths
MCP used by Claude Code and opencode
C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\.mcp.jsonC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\opencode.jsonC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\mcp_wrapper.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\AbletonMCP_AI\MCP_Server\server.py
Remote Script used by Ableton Live
C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\__init__.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\Remote_Script.py
Important:
- those shims currently prefer
AbletonMCP_AI_BAK_20260328_200801\Remote_Script.py - they only fall back to
abletonmcp_init.py
This means MCP and Ableton Live are not currently using a single implementation.
Source Of Truth Rules
Before changing code, answer these questions with evidence:
- Which file is the active entrypoint for this path?
- Which file is actually loaded at runtime?
- Is the bug in the MCP server, the wrapper, or the Live runtime?
- Can the bug be confirmed with logs, compile output, or direct socket checks?
If you cannot answer those, you are not ready to patch.
Non-Negotiable Engineering Rules
- Do not guess the active runtime.
- Do not patch dead files first.
- Do not assume a timeout means failure.
- Do not assume a success string means Live is healthy.
- Do not declare success without runtime validation.
- Do not break
get_session_info,get_tracks, orgenerate_track. - Do not create a second architecture when one already exists.
- Do not use the backup tree as the long-term source of truth.
- Do not edit random helper scripts and call that a fix.
What Success Looks Like
A fix is only real if most of these are true:
- the MCP connects
- Ableton loads the
AbletonMCP_AIControl Surface - the socket is listening on
127.0.0.1:9877 get_session_inforesponds quicklyget_tracksresponds consistently- Ableton remains responsive during mutations
- generation does not trigger
Audio queue timeout - the final set is audible and editable
Best Practices For Working In This Repo
1. Start from the active path, not from file names
There are duplicate and legacy files:
- multiple servers
- backup runtimes
- moved trees
- legacy utility scripts
Always start from the wrapper or shim that is actually being executed.
2. Separate the layers mentally
This project has three separate layers:
- MCP transport and tool layer
- socket protocol layer
- Ableton Remote Script / Live API layer
Many bugs come from fixing the wrong layer.
3. Prefer runtime evidence over theory
Use:
- Ableton log
- compile output
- direct socket probes
- MCP
tools/list get_session_infoget_tracks
Do not argue with logs.
4. Keep Live API mutations short
Long or monolithic work on the Live thread is dangerous.
If a task touches Live objects:
- keep each mutation small
- avoid large blocking batches
- do heavy planning outside the Live thread
- schedule short main-thread operations when required
5. Compile changed Python files
Before testing runtime changes, compile the touched Python files.
Useful pattern:
python -m py_compile "C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\mcp_wrapper.py"
python -m py_compile "C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\abletonmcp_init.py"
python -m py_compile "C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\AbletonMCP_AI\MCP_Server\server.py"
python -m py_compile "C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\AbletonMCP_AI\MCP_Server\song_generator.py"
6. Validate both MCP and Live
MCP can be healthy while Live is broken. Live can be listening while generation still crashes it.
Check both.
7. Prefer one source of truth
If you are cleaning architecture:
- pick one canonical Remote Script runtime
- pick one canonical MCP server
- retire or isolate dead variants
Do not leave three half-working options.
High-Value Files
Read these first when debugging real behavior:
C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\mcp_wrapper.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\.mcp.jsonC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\opencode.jsonC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\__init__.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\Remote_Script.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\abletonmcp_init.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\AbletonMCP_AI_BAK_20260328_200801\Remote_Script.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\AbletonMCP_AI\MCP_Server\server.pyC:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI\AbletonMCP_AI\MCP_Server\song_generator.pyC:\Users\ren\AppData\Roaming\Ableton\Live 12.0.15\Preferences\Log.txt
Known Current Reality
As of the latest audit:
- Claude Code and opencode can connect to the MCP
- Ableton can load the
AbletonMCP_AIControl Surface generate_trackcan still push Live intoAudio queue timeoutserver_v2.pydoes not compileserver.pycontains duplicated MCP tools- the backup runtime is still in the active load path
If your task involves repairs, read KIMI_K2_CODEBASE_FIXES.md immediately after this file.
Fast Diagnostic Checklist
When MCP fails to appear
Check:
.mcp.jsonopencode.jsonmcp_wrapper.pyC:\Users\ren\.claude.jsonif Claude behaves differently from project config
When Ableton does not show the Control Surface
Check:
AbletonMCP_AI\__init__.pyAbletonMCP_AI\Remote_Script.py- Ableton log for
MidiRemoteScript
When Ableton listens on 9877 but commands hang or crash
Check:
- newline framing in socket responses
- thread model in the Remote Script
- long Live API operations during generation
- Ableton log for
Audio queue timeout
When a generation times out
Do this before declaring failure:
- inspect Ableton log
- query
get_session_info - query
get_tracks - verify whether the set changed anyway
Commands Worth Remembering
Read Ableton log tail:
Get-Content "C:\Users\ren\AppData\Roaming\Ableton\Live 12.0.15\Preferences\Log.txt" -Tail 120
Check if Live socket is listening:
netstat -an | findstr 9877
Compile active MCP and runtime files:
python -m compileall "C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\AbletonMCP_AI" "C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\abletonmcp_init.py"
Launching Ableton Safely
Use the real Ableton executable:
- active install:
C:\ProgramData\Ableton\Live 12 Suite\Program\Ableton Live 12 Suite.exe - backup or parallel updated install:
C:\ProgramData\Ableton\.Live 12 Suite_updated\Program\Ableton Live 12 Suite.exe
Preferred restart policy:
- if Live is responsive, close it normally first
- only use
taskkillif Live is hung or a script crash left zombie processes - wait a few seconds before relaunching
- relaunch the executable directly
Known helper script:
C:\ProgramData\Ableton\Live 12 Suite\Resources\MIDI Remote Scripts\restart_ableton.bat
Do not invent alternate launch paths. Do not copy files into random Ableton installs and then launch a different binary.
Recovery Popup Suppression
If the user explicitly wants to skip the recovery popup after a crash, clean the active recovery file before relaunching Live:
C:\Users\ren\AppData\Roaming\Ableton\Live 12.0.15\Preferences\CrashRecoveryInfo.cfg
Important:
- this discards the pending crash-recovery state for the last session
- do this only when the user wants to suppress the popup
- do not delete the whole
Crashfolder underPreferences CrashDetection.cfgmay remain; the popup-relevant file isCrashRecoveryInfo.cfg
Safe PowerShell pattern:
$liveExe = 'C:\ProgramData\Ableton\Live 12 Suite\Program\Ableton Live 12 Suite.exe'
$recoveryFile = 'C:\Users\ren\AppData\Roaming\Ableton\Live 12.0.15\Preferences\CrashRecoveryInfo.cfg'
Get-Process 'Ableton Live 12 Suite' -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process 'AbletonPushCpl' -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process 'Ableton Index' -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 3
if (Test-Path $recoveryFile) {
Remove-Item -LiteralPath $recoveryFile -Force
}
Start-Process -FilePath $liveExe
After relaunch:
- wait 10 to 15 seconds for full startup
- verify the process is still alive
- inspect
C:\Users\ren\AppData\Roaming\Ableton\Live 12.0.15\Preferences\Log.txtbefore declaring success
If a task requires preserving the unsaved recovery state, do not remove CrashRecoveryInfo.cfg.
Working Mindset
Be skeptical. Be concrete. Verify everything important.
In this repo, the intelligent agent is not the one that writes the most code. It is the one that identifies the active runtime, patches the correct layer, and proves the fix with evidence.