feat(mcp): add start_recording and stop_recording tools#3135
Open
sinano1107 wants to merge 4 commits intomobile-dev-inc:mainfrom
Open
feat(mcp): add start_recording and stop_recording tools#3135sinano1107 wants to merge 4 commits intomobile-dev-inc:mainfrom
sinano1107 wants to merge 4 commits intomobile-dev-inc:mainfrom
Conversation
Add MCP tools to start and stop simulator screen recording. Internally delegates to LocalSimulatorUtils which wraps xcrun simctl io recordVideo with proper SIGINT handling. RecordingManager tracks active recordings per device and supports an optional output_path parameter for specifying the destination. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Code reviewFound 1 issue:
For reference, the established stop protocol in And the SIGINT contract in 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Replace manual process teardown in shutdown() with a call to LocalSimulatorUtils.stopScreenRecording(), which properly closes stdin (triggering SIGINT via screenrecord.sh) and waits for simctl to finish writing the video file. The previous approach used destroyForcibly() after a 5-second timeout, which could kill the wrapper process before simctl finalized the video. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- stopRecording: wrap in try/finally so activeRecordings.remove() is always called, preventing a device from being permanently locked if stopScreenRecording or file copy throws - startRecording: add early containsKey check before launching the recording process to avoid wasteful process start/stop on duplicate - Tool descriptions: explicitly state iOS Simulator only, since the implementation uses xcrun simctl which is not available on Android Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The early containsKey check is not atomic with putIfAbsent and gives a false sense of safety. On a race, a second caller would pass the check, start a recording process, then find it lost the putIfAbsent race and have to stop the process it just started. putIfAbsent alone is the correct guard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
start_recordingandstop_recordingMCP tools for controlling simulator screen recordingLocalSimulatorUtilswhich wrapsxcrun simctl io recordVideowith proper SIGINT handling viascreenrecord.shRecordingManagertracks active recordings per device, preventing duplicate recordings and cleaning up on JVM shutdownoutput_pathparameter allows specifying the destination file; defaults to a temp pathMotivation
The MCP server currently has no way to record the simulator screen. Users working with AI agents need to capture screen recordings for documentation, bug reports, or video production workflows. The existing
maestro recordcommand is self-contained and cannot run alongside MCP tool calls, so dedicated MCP tools are needed.Implementation
RecordingManager: Manages recording lifecycle per device usingConcurrentHashMapwith atomicputIfAbsent. ReusesLocalSimulatorUtils.startScreenRecording()/stopScreenRecording()— no new process management code.StartRecordingTool: Returnsrecording_idandoutput_pathon success.StopRecordingTool: Acceptsrecording_idto prevent accidental stops. Returnsvideo_path.McpServer.ktalongside existing tools.Test plan
RecordingManager(state management, error cases, output path copying)start_recording→ interact with app →stop_recording→ verify MP4 plays correctly🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com