{"slug": "i-built-dusk-playwright-mcp-but-for-flutter-apps", "title": "I Built Dusk: Playwright MCP, but for Flutter Apps", "summary": "A developer built Dusk, an open-source tool that gives AI agents direct access to Flutter app semantics via VM Service extensions, enabling live, unscripted testing without test files or build steps. Dusk provides 32 CLI commands and 31 MCP tools for actions like tap, type, scroll, and screenshot, with a 6-step actionability gate to ensure reliability. The tool is designed for ad hoc driving of running Flutter apps by humans and AI agents, complementing existing test suites.", "body_md": "Last week I watched my AI agent try to test a Flutter screen. It wrote a test file, ran `flutter test`\n\n, copied the stack trace back into the prompt, pasted a screenshot, and called it a workflow. It was slow, and it was guessing.\n\nOn the web, agents do not work like that anymore. Playwright MCP gives them an accessibility tree to read and stable refs to act on. 33k stars, no screenshot guessing. Flutter never had that layer.\n\nSo I built Dusk.\n\nEnd-to-end testing on Flutter has always been a stitched-together ritual.\n\n`flutter_driver`\n\nships a one-off socket protocol and is on the legacy track. `integration_test`\n\nruns in-process against a simulated `WidgetTester`\n\n, but you write a test file, build, run, and wait. Maestro is nice but pays around 3 seconds per action. Patrol is powerful but tends to be unstable on CI.\n\nThe deeper issue is the loop. An agent that wants to drive your app reaches for ad hoc `flutter test`\n\nruns, copies stack traces by hand, and pastes screenshots back. There is no live connection between the agent and the running app.\n\n```\n// The old loop: write a test file, build, run, wait, read the failure, repeat.\ntestWidgets('checkout flow', (tester) async {\n  await tester.tap(find.byKey(const Key('checkout')));\n  await tester.pumpAndSettle();\n  // ...and you still rebuild and rerun the whole thing to see what happened.\n});\n```\n\nDusk attaches to a running Flutter app over VM Service extensions. No test file, no `flutter_test`\n\nharness, no build step. You start your app, attach, and the agent has eyes and hands.\n\nFirst it snapshots the Semantics tree:\n\n```\ndart run fluttersdk_dusk dusk:snap\n```\n\nThat returns a YAML tree with stable `[ref=eN]`\n\ntokens. Every action targets a ref, so there is no brittle XPath and no coordinate guessing.\n\n```\ndusk:tap --ref=e7\ndusk:type --ref=e3 --text \"ada@fluttersdk.com\"\ndusk:screenshot\n```\n\nThe same contracts power your terminal and your AI agent. `dusk:tap --ref=e7`\n\non the CLI and `dusk_tap`\n\nas an MCP tool reach the exact same code path. 32 CLI commands and 31 MCP tools: snap, tap, type, scroll, drag, observe, screenshot, and a hot-reload-and-snap round trip that returns the new tree, a screenshot, and any exceptions in one call.\n\nEvery gesture passes a 6-step actionability gate before it runs: not defunct, enabled, non-zero rect, on-viewport (it auto-scrolls), stable across 2 frames, and actually hit-testable. So your agent never taps a button that is not really there yet.\n\nThis is the part that turns \"drive the app\" from a demo into something you trust. The boring check is the whole point.\n\nDusk does not replace your test suite. It owns a different niche: the unscripted, running app.\n\n| Tool | What it is | Where Dusk fits |\n|---|---|---|\n| integration_test | Authored test file via `WidgetTester`\n|\nOwns the test file. Dusk owns the live, unscripted app. Use both. |\n| patrol | Native dialogs on integration_test | Owns authored tests with native permissions. Dusk owns ad hoc driving by humans and agents. |\n| flutter_driver | Legacy socket protocol | Dusk is hot-restart safe, one contract for CLI and MCP, no separate isolate. |\n| maestro | YAML DSL over the OS accessibility layer | Dusk drives the Flutter widget tree directly. Zero YAML to author. |\n| playwright-mcp | Browser MCP via the accessibility tree | Dusk is the Flutter-native equivalent, ported to Semantics. |\n\n```\nflutter pub add fluttersdk_dusk\ndart run fluttersdk_dusk dusk:install\n```\n\n`dusk:install`\n\npatches `lib/main.dart`\n\nbehind `kDebugMode`\n\nand scaffolds the CLI. Release builds tree-shake the entire driver across web, desktop, and mobile, so Dusk never ships to production.\n\nWire it into your agent with one more command:\n\n```\ndart run fluttersdk_dusk mcp:install\n```\n\nThat registers the stdio MCP server for Claude Code, Cursor, Windsurf, VS Code Copilot, and any MCP-compatible agent. Dusk also ships its own agent skill, so the agent learns the ref grammar and the tool surface, not just the syntax.\n\nTwo things stuck with me.\n\nFirst, the accessibility tree is the right interface for agents on Flutter just as much as on the web. Semantics nodes are stable, cheap, and already there. Screenshots are the slow, expensive fallback, not the default.\n\nSecond, the actionability gate matters more than the tool count. An agent that taps confidently on a widget that has not settled is worse than no automation at all. The 6-step check is what makes the rest usable.\n\nDocs: [https://fluttersdk.com/dusk](https://fluttersdk.com/dusk)\n\nAgent setup: [https://fluttersdk.com/dusk/ai](https://fluttersdk.com/dusk/ai)\n\nIf you try it with your agent, I would love to hear what breaks. That's all.", "url": "https://wpnews.pro/news/i-built-dusk-playwright-mcp-but-for-flutter-apps", "canonical_source": "https://dev.to/fluttersdk/i-built-dusk-playwright-mcp-but-for-flutter-apps-l5m", "published_at": "2026-06-14 17:09:36+00:00", "updated_at": "2026-06-14 17:40:43.888736+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "ai-agents"], "entities": ["Dusk", "Flutter", "Playwright MCP", "Claude Code", "Cursor", "Windsurf", "VS Code Copilot", "Maestro"], "alternates": {"html": "https://wpnews.pro/news/i-built-dusk-playwright-mcp-but-for-flutter-apps", "markdown": "https://wpnews.pro/news/i-built-dusk-playwright-mcp-but-for-flutter-apps.md", "text": "https://wpnews.pro/news/i-built-dusk-playwright-mcp-but-for-flutter-apps.txt", "jsonld": "https://wpnews.pro/news/i-built-dusk-playwright-mcp-but-for-flutter-apps.jsonld"}}