multi_device_preview_marionette 1.1.1
multi_device_preview_marionette: ^1.1.1 copied to clipboard
Exposes multi_device_preview commands (devices, input sync, restart, screenshots, trackpad scroll) as Marionette MCP tools for AI agents.
multi_device_preview_marionette #
Lets AI agents drive multi_device_preview through Marionette MCP: every preview command becomes an MCP tool with a typed schema.
| Tool | What it does |
|---|---|
multiDevicePreview.getState |
Devices (preset, text scale, orientation, size, screen key, out-of-sync) and sync state |
multiDevicePreview.listPresets |
Preset ids |
multiDevicePreview.setSync |
Turns input sync on or off |
multiDevicePreview.restart |
Rebuilds every app from scratch |
multiDevicePreview.setDevice / addDevice / removeDevice |
Changes the devices; orientation=landscape rotates one |
multiDevicePreview.saveScreenshot |
Writes a PNG of all devices, or one, to a file. frame=false writes a store screenshot of one device |
multiDevicePreview.panZoom |
Scrolls with a trackpad gesture, mirrored like a real one |
Setup #
flutter pub add dev:multi_device_preview_marionette dev:marionette_flutter
In the preview entry point, initialize Marionette before
runMultiDevicePreview (and before any other binding, for example before
WidgetsFlutterBinding.ensureInitialized() when main() awaits something
first). Pass the devices to the controller, not to runMultiDevicePreview:
import 'package:flutter/foundation.dart';
import 'package:marionette_flutter/marionette_flutter.dart';
import 'package:multi_device_preview/multi_device_preview.dart';
import 'package:multi_device_preview_marionette/multi_device_preview_marionette.dart';
void main() {
final controller = MultiDevicePreviewController(
devices: const [
PreviewDevice(preset: DevicePresets.iPhone17),
PreviewDevice(preset: DevicePresets.pixel9),
],
);
if (!kReleaseMode) {
MarionetteBinding.ensureInitialized(
multiDevicePreviewMarionetteConfiguration,
);
registerMultiDevicePreviewMarionetteExtensions(controller);
}
runMultiDevicePreview(
controller: controller,
appBuilder: (context, slot) => const MyApp(),
);
}
multiDevicePreviewMarionetteConfiguration uses CompactionMode.none, so
get_interactive_elements reports every element and an agent can compare
sizes and text scales across devices. Pass your own MarionetteConfiguration
to customize it.
Tips for agents #
- Each device screen has the key
multi_device_preview.screen.<n>. Pass it inancestor_keysto look at, or act on, a single device. Without it, keys and texts match the first device, and the action is mirrored to the others while input sync is on. - Prefer
multiDevicePreview.saveScreenshotovertake_screenshots: several devices easily exceed the size of an MCP response. - macOS stops rendering a window hidden behind other windows; keep the
preview window visible, or
saveScreenshotreports an error. boundsfrom Marionette:x/yare positions in the scaled window,width/heightare logical sizes inside the device.
License #
MIT