Problem
Currently mcp-openmsx can only control emulator instances it spawns itself via emu_control.launch. There's no way to connect to an openMSX instance the user started independently (e.g. from the command line). This limits integration in workflows where the user already has an openMSX session open doing some inspection and wants the AI agent help in a more tight collaboration.
Use case
This feature is particularly valuable for interactive bug hunting and reverse engineering workflows. A user often has openMSX already running a ROM or disk program they're debugging — stepping through code in an IDE, setting breakpoints, inspecting memory. Being able to attach the agent to that live session lets the agent help diagnose issues in real time: reading registers, scanning memory, analyzing VDP state, or suggesting breakpoints, all without disrupting the user's existing setup or forcing them to restart the emulator from scratch.
Proposed solution
Add attach and detach commands to emu_control that connect to an already-running openMSX instance via its control socket, without taking ownership of the process lifecycle.
Design
Instance discovery — on Linux/macOS, openMSX writes Unix domain sockets at /tmp/openmsx-<username>/socket.<PID>. On Windows, the situation is more involved and since I don't actually use Windows, a solution will be proposed later.
Proposed interface:
emu_control.attach
- Without
socketPath: auto-scans, connects if exactly one instance found, returns a list for agent elicitation if multiple found.
- With
socketPath: connects directly to the specified instance.
- Skips auto-configuration (renderer,
save_settings_on_exit, reverse replay) — the instance keeps its own settings.
emu_control.detach — disconnects without killing the openMSX process.
Lifecycle changes — emu_close, destroy, forceClose, and the command queue guard are updated so attached instances are cleanly disconnected rather than killed.
Scope
| Area |
Changes |
openmsx.ts |
scanRunningInstances, emu_connect, querySocketIdentity, queryTcpIdentity, connectUnix, connectTcp. Updated guards in emu_close, forceClose, destroy, writeData. |
server_tools.ts |
attach/detach commands, socketPath parameter, instances output schema. |
| Tests |
7 new tests: direct connect, auto-connect, no-instances, multi-instance, detach success/failure. |
| Docs |
Skills, launch reference, tool reference, README updated. |
Questions to resolve
- Should attached instances be allowed to call
powerOff/reset, or should those be blocked for non-owned processes?
- On Windows, should the
attach scan also support direct-sspi mode (TCP without the socket file), or only stdio-proxy?
Problem
Currently
mcp-openmsxcan only control emulator instances it spawns itself viaemu_control.launch. There's no way to connect to an openMSX instance the user started independently (e.g. from the command line). This limits integration in workflows where the user already has an openMSX session open doing some inspection and wants the AI agent help in a more tight collaboration.Use case
This feature is particularly valuable for interactive bug hunting and reverse engineering workflows. A user often has openMSX already running a ROM or disk program they're debugging — stepping through code in an IDE, setting breakpoints, inspecting memory. Being able to attach the agent to that live session lets the agent help diagnose issues in real time: reading registers, scanning memory, analyzing VDP state, or suggesting breakpoints, all without disrupting the user's existing setup or forcing them to restart the emulator from scratch.
Proposed solution
Add
attachanddetachcommands toemu_controlthat connect to an already-running openMSX instance via its control socket, without taking ownership of the process lifecycle.Design
Instance discovery — on Linux/macOS, openMSX writes Unix domain sockets at
/tmp/openmsx-<username>/socket.<PID>. On Windows, the situation is more involved and since I don't actually use Windows, a solution will be proposed later.Proposed interface:
emu_control.attachsocketPath: auto-scans, connects if exactly one instance found, returns a list for agent elicitation if multiple found.socketPath: connects directly to the specified instance.save_settings_on_exit, reverse replay) — the instance keeps its own settings.emu_control.detach— disconnects without killing the openMSX process.Lifecycle changes —
emu_close,destroy,forceClose, and the command queue guard are updated so attached instances are cleanly disconnected rather than killed.Scope
openmsx.tsscanRunningInstances,emu_connect,querySocketIdentity,queryTcpIdentity,connectUnix,connectTcp. Updated guards inemu_close,forceClose,destroy,writeData.server_tools.tsattach/detachcommands,socketPathparameter,instancesoutput schema.Questions to resolve
powerOff/reset, or should those be blocked for non-owned processes?attachscan also supportdirect-sspimode (TCP without the socket file), or onlystdio-proxy?