Configuration
The MCP server can be configured using command-line arguments.
MCP transport is stdin/stdout (no inbound MCP TCP port).
Command Line Arguments
| Option | Description |
|---|---|
--dart-vm-host | The host for the Dart VM connection. Defaults to localhost. |
--dart-vm-port | The port for the Dart VM connection. Defaults to 8181. |
--resources | Enable or disable support for resources (widget tree, screenshots). Defaults to true. |
--images | Enable or disable support for images (screenshots). Defaults to true. |
--dumps | Enable or disable support for debug dump operations (e.g., dump_render_tree). Defaults to false. |
--dynamics | Enable or disable support for dynamic tool registration. Defaults to true. |
--await-dnd | Await until a dynamic tool registration connection is established. This can be useful for some AI clients. Defaults to false. |
--save-images | Save captured images as files instead of returning them as base64 data. Defaults to false. |
--flutter-project-dir | Optional Flutter project directory used by machine discovery (flutter attach --machine). |
--flutter-device | Optional Flutter device for machine discovery (for example chrome). |
--flutter-discovery-timeout-ms | Timeout in milliseconds for machine discovery. Defaults to 2500. |
--log-level | The logging level for the server. Can be debug, info, notice, warning, error, critical, alert, or emergency. Defaults to critical. Log levels are based on https://spec.modelcontextprotocol.io/specification/2025-03-26/server/utilities/logging/#log-levels |
--environment | The environment mode. Can be development or production. Defaults to production. |
-h, --help | Show the usage text. |
CLI note: flutter_mcp_cli has a separate --log-level default of error.
v3 Reliability Commands
- Preflight diagnostics:
flutter_mcp_cli doctor --jsonflutter_mcp_cli doctor --json --target ws://127.0.0.1:8181/<token>/ws --timeout-ms 4000
- Safe write controls for
snapshot createandbundle create:--check(no writes)--diff(unified diff metadata)--backup(timestamped backup before replace)--no-overwrite(block existing targets)
Error codes and descriptor semantics are documented in Error Code Playbook.
Connection Targeting
Server flags (--dart-vm-host, --dart-vm-port) define defaults, but VM-dependent requests can override connection selection per call.
Resolution Policy
For VM-dependent operations, the server resolves target in this order:
- Reuse active healthy connection.
- Reuse sticky target if still discoverable.
- Auto-attach if exactly one target is discovered.
- Return
connection_selection_requiredif multiple targets exist and no explicit target is provided.
Per-Request connection Object
VM-dependent tool calls support optional arguments.connection:
{
"name": "debug_dump_render_tree",
"arguments": {
"connection": {
"targetId": "ws://127.0.0.1:59490/<token>/ws"
}
}
}
Supported fields:
targetId(full VM websocket URI)mode:auto,manual, orurihostporturiforceReconnect
Zero-Mistake Rules
Use these in order:
- Safest: set
connection.urito the exactapp.debugPort.wsUrivalue from Flutter machine output. - If you use
connection.targetId, copy it exactly fromdiscover_debug_apps/availableTargets. - Never use plain
host:portastargetId(rejected). - If you get
target_not_foundwithtargetId, retry withconnection.uriusing exactapp.debugPort.wsUri.
Examples:
{
"name": "get_vm",
"arguments": {
"connection": {
"mode": "manual",
"host": "localhost",
"port": 8182
}
}
}
{
"name": "get_vm",
"arguments": {
"connection": {
"mode": "uri",
"uri": "ws://127.0.0.1:8181/<token>/ws",
"forceReconnect": true
}
}
}
Important:
- Legacy
host:portvalues are rejected forconnection.targetId. connection.uriis the most robust selector because it preserves tokenized VM paths exactly.- Full tokenized URI
targetIdvalues are accepted. If discovery cannot resolve them, the server attempts direct connect using that URI. - Tool input schemas are strict: flat aliases like
arguments.port,arguments.host, andarguments.uriare rejected. connect_debug_appaccepts the sameconnectionobject.- Dynamic registry tools (
listClientToolsAndResources,runClientTool,runClientResource) also accept optionalconnection. - CLI one-shot
exec --args, daemoncommand/execute, and daemonwatch/startaccept the same nestedconnectionobject contract. snapshot/createsupports per-stepargs.commands[i].args.connection.connectandsession_startreject mixed native selector fields and nestedconnectionin the same args object.