Skip to content

docs: add Flutter Driver example to MCP server page#13220

Open
Ortes wants to merge 9 commits into
flutter:mainfrom
Ortes:doc/mcp-flutter-driver-example
Open

docs: add Flutter Driver example to MCP server page#13220
Ortes wants to merge 9 commits into
flutter:mainfrom
Ortes:doc/mcp-flutter-driver-example

Conversation

@Ortes
Copy link
Copy Markdown

@Ortes Ortes commented Mar 25, 2026

Summary

  • Adds a third usage example to the MCP server docs page
  • Shows how to connect to a running Flutter app and interact with its UI using Flutter Driver via the MCP server
  • Links to the full setup guide in dart-lang/ai for details

Related

Test plan

  • Verify page builds and renders correctly
  • Verify the :::note directive renders as expected
  • Verify the link to the dart-lang/ai README section works

🤖 Generated with Claude Code

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Mar 25, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, @Ortes! Let us know when you're ready to land.

Comment thread src/content/ai/mcp-server.md Outdated
@sfshaza2
Copy link
Copy Markdown
Contributor

/gcbrun

@flutter-website-bot
Copy link
Copy Markdown
Collaborator

Visit the preview URL for this PR (updated for commit 1a33d89):

https://flutter-docs-prod--pr13220-doc-mcp-flutter-driver-exam-sg841r6i.web.app

Copy link
Copy Markdown
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Any reason we can't move this out of draft and land it?

@Ortes
Copy link
Copy Markdown
Author

Ortes commented May 7, 2026

It's not up-to-date anymore. I will update.

@Ortes Ortes marked this pull request as ready for review May 8, 2026 00:22
@Ortes Ortes requested a review from a team as a code owner May 8, 2026 00:22
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new section to the documentation detailing how to use the Dart and Flutter MCP server to interact with a running Flutter app. The reviewer provided a suggestion to improve formatting consistency by removing spaces around an em dash.

Comment thread src/content/ai/mcp-server.md Outdated
@Ortes Ortes force-pushed the doc/mcp-flutter-driver-example branch from 591e49e to ed51f41 Compare May 8, 2026 00:36
Ortes and others added 6 commits May 7, 2026 20:54
Add a third usage example showing how to connect to a running Flutter
app and interact with its UI using Flutter Driver via the MCP server.
- Remove --print-dtd from the launch command (auto-discovered via DDS in
  Flutter ≥3.27; flag no longer needed)
- Add explicit web note: flutter_driver doesn't compile under dart2js,
  pair with a browser-driving MCP for UI actions
- Trim wording to keep this section setup-oriented; full reference lives
  in dart-lang/ai
With `-d chrome`, only the Chrome window Flutter spawns receives hot
reload patches; a second browser at the same URL renders the bundle but
is invisible to dwds. Spell out the recommendation in the note block so
readers don't hit the trap.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Reorder the section so readers see the flag's origin before they hit
it on the command line: gate enableFlutterDriverExtension() in main()
first, launch with --dart-define second, then prompt the assistant.
ENABLE_FLUTTER_DRIVER is a user-defined flag, not a Flutter built-in,
so explaining it after the run command read backwards.
@Ortes Ortes force-pushed the doc/mcp-flutter-driver-example branch from 7c7144b to fd3acb7 Compare May 8, 2026 00:55
Copy link
Copy Markdown
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Some small suggestions and questions:

Comment thread sites/docs/src/content/ai/mcp-server.md Outdated
production builds:

```dart
import 'package:flutter_driver/driver_extension.dart';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since users might not have flutter_driver added as a dependency, should we suggest adding it first?

```console
$ flutter pub add "flutter_driver:{sdk: flutter}"
```

Comment thread sites/docs/src/content/ai/mcp-server.md Outdated
and common pitfalls.
:::

[flutter-driver-guide]: https://github.com/dart-lang/ai/blob/main/pkgs/dart_mcp_server/README.md#connect-to-a-running-flutter-app
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this PR should wait to land until the one to dart-lang/ai does for this link?

agent drives is the one DTD is connected to—with -d chrome, only the
window Flutter spawned receives hot reload patches.

See the [setup guide][flutter-driver-guide] for the snippet, web modes,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What snippet?

Comment thread sites/docs/src/content/ai/mcp-server.md Outdated
Comment on lines +430 to +433
**Web**: the `flutter_driver` package doesn't compile under dart2js. Pair
the Dart MCP server with a browser-driving MCP for clicks and screenshots;
the Dart MCP server still handles widget tree, runtime errors, and hot
reload through DTD. Prefer `flutter run -d web-server` so the browser the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here. So does this strategy not work with dart2js (release mode) or web as a whole? Since it at first mentions dart2js but here mentioned hot reload, which is not available with dart2js anyway.

sfshaza2 and others added 3 commits May 28, 2026 13:57
Co-authored-by: Parker Lougheed <parlough@gmail.com>
Co-authored-by: Parker Lougheed <parlough@gmail.com>
Co-authored-by: Parker Lougheed <parlough@gmail.com>
@sfshaza2
Copy link
Copy Markdown
Contributor

@Ortes, I have committed some of @parlough's changes. Can you address the rest?

@sfshaza2 sfshaza2 added the act.wait-for-customer Needs response from customer label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act.wait-for-customer Needs response from customer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants