Skip to content

Conversation

stefanoamorelli
Copy link

@stefanoamorelli stefanoamorelli commented Oct 4, 2025

Adds hot_restart tool to the flutter_launcher MCP server. Works the same as pressing 'R' in the terminal during flutter run, it restarts the app without killing the debug session.

  • New hot_restart tool that sends 'R' command to process stdin
  • Fixed test mock stdin (was throwing UnimplementedError)
  • Added tests for success and error cases
  • Updated docs

Fix broken test infrastructure where MockProcess.stdin threw
UnimplementedError, making it impossible to test any functionality
that writes to process stdin.

This was a bug in the test mock that prevented testing stdin-based
features like hot restart commands.

Changes:
- Replace UnimplementedError with functional MockIOSink implementation
- Implement writeln, flush, and close methods
- Add state tracking for verification in tests
Implement hot restart functionality to allow restarting Flutter
applications without terminating the debug session. The tool sends
the 'R' command to the running process's stdin, triggering a full
application restart while maintaining the connection.

Changes:
- Add hotRestartTool definition with input/output schemas
- Implement _hotRestart handler method
- Register hot_restart tool in initialize method
- Add error handling for non-existent process IDs
Add comprehensive test coverage for the hot_restart tool, including
success and error scenarios.

Tests added:
- Successful hot restart on running application
- Error handling for non-existent process ID
Update documentation to include the new hot_restart tool in the
list of available MCP server tools.

Changes:
- Add hot_restart to tool list in main README
- Add hot_restart API documentation in flutter_launcher_mcp README
- Include input/output schemas for the tool
@stefanoamorelli stefanoamorelli changed the title Add hot restart support [Feat] Add hot_restart support Oct 4, 2025
@sethladd
Copy link
Collaborator

sethladd commented Oct 7, 2025

amazing, thank you! We really appreciate this contribution!

Apologies, but would you be willing to make a patch over here: https://github.com/dart-lang/ai/tree/main/pkgs/dart_mcp_server ? We're going to actually move these MCP tools in the extension over to the dart/flutter MCP server.

You could help close out dart-lang/ai#254

@stefanoamorelli
Copy link
Author

@sethladd sounds good, closing this PR then and opened this! 🚀

@stefanoamorelli stefanoamorelli deleted the feat/hot-restart branch October 7, 2025 17:19
@sethladd
Copy link
Collaborator

sethladd commented Oct 7, 2025

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants