flutter-bridge-mcp

v0.1.1
flutter-bridge-mcp Checked 1 day ago Published 2 months ago

MCP server that joins Android's view of a running Flutter app to Dart's — screen coordinates, widget tree and source locations in one place

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_devices

List connected Android devices and emulators with their state and model.

read_logs

Read recent logcat output, filtered. Args: package: only show logs from this app's process (e.g. com.example.app). tag: regex matched against the log tag. min_level: one of V, D, I, W, E, F. Defaults to I. contains: case-insensitive substring that must appear in tag or message. limit: max lines returned (hard-capped by FLUTTER_BRIDGE_MAX_LINES). buffer: main, system, crash, events, radio, or all. serial: device serial when several are attached.

ParameterTypeDescription
bufferstring
contains
limitinteger
min_levelstring
package
serial
tag

find_crashes

Extract recent crashes and ANRs as whole stack traces from the crash buffer. Args: package: restrict to traces mentioning this package name. limit: how many of the most recent traces to return. serial: device serial when several are attached.

ParameterTypeDescription
limitinteger
package
serial

clear_logs

Clear all logcat buffers. Do this before reproducing a bug so logs stay clean.

ParameterTypeDescription
serial

capture_start

Begin recording logcat into a background ring buffer. Use this when the user is about to reproduce a bug: start the capture, let them reproduce it, then query with capture_read. Unlike read_logs this survives log rotation and captures everything, including verbose output.

ParameterTypeDescription
labelstring
serial

capture_read

Query the background capture buffer with the same filters as read_logs. Args: stop: also end the capture after reading.

ParameterTypeDescription
contains
limitinteger
min_levelstring
package
stopboolean
tag

capture_stop

Stop the background logcat capture and release the adb process.

retrace

De-obfuscate an R8/ProGuard stack trace using a mapping.txt file. Args: stacktrace: the obfuscated trace, copied from find_crashes output. mapping_path: path to mapping.txt, usually under app/build/outputs/mapping/<variant>/mapping.txt

ParameterTypeDescription
mapping_path *string
stacktrace *string

screenshot

Capture what is currently on screen. Use this to see the app before acting on it. The image is downscaled before sending, so coordinates read off it are NOT the device's own. Use ui_dump, or tap(text=...), to get real tap targets. Args: max_width: longest edge of the returned image in pixels. serial: device serial when several are attached.

ParameterTypeDescription
max_widthinteger
serial

ui_dump

List on-screen UI elements with their tap coordinates. Cheaper and more precise than a screenshot when you only need to find a control. Args: contains: case-insensitive filter on text, content description or id. clickable_only: only return elements that accept taps. limit: max elements returned. serial: device serial when several are attached.

ParameterTypeDescription
clickable_onlyboolean
contains
limitinteger
serial

tap

Tap the screen, either at a coordinate or on the element matching `text`. Prefer `text`: it survives layout and resolution differences. Exact matches win over partial ones; if several elements match, none is tapped and they are listed so you can pick a coordinate instead. Args: x, y: device coordinates. Ignored when `text` is given. text: text, content description or resource id of the element to tap. serial: device serial when several are attached.

ParameterTypeDescription
serial
text
x
y

swipe

Swipe or scroll. Give a direction for a centred swipe, or explicit coordinates. Args: direction: up, down, left or right. "up" scrolls the content up (reveals what is below), matching how a finger moves. x1, y1, x2, y2: start and end points, used when direction is omitted. duration_ms: swipe duration; raise it for a slow drag, lower it to fling. serial: device serial when several are attached.

ParameterTypeDescription
direction
duration_msinteger
serial
x1
x2
y1
y2

input_text

Type into the focused field. Tap the field first so it has focus. Args: text: the text to type. ASCII only — adb cannot type emoji or most non-Latin text. submit: press Enter afterwards. clear: delete the field's existing contents first. serial: device serial when several are attached.

ParameterTypeDescription
text *string
clearboolean
serial
submitboolean

press_key

Press a hardware or navigation key. Args: key: back, home, recents, enter, tab, delete, escape, search, menu, power, wake, sleep, volume_up, volume_down, camera, or dpad_up/down/left/right/center. A raw KEYCODE_* name or a numeric keycode also works. serial: device serial when several are attached.

ParameterTypeDescription
key *string
serial

launch_app

Launch an app, optionally from a clean state. Args: package: application id, e.g. com.example.app. activity: fully qualified activity to start instead of the launcher entry point. clear_data: wipe the app's data first, for a true first-run test. serial: device serial when several are attached.

ParameterTypeDescription
package *string
activity
clear_databoolean
serial

stop_app

Force-stop an app. Pair with launch_app to test a cold start. Args: package: application id, e.g. com.example.app. serial: device serial when several are attached.

ParameterTypeDescription
package *string
serial

device_info

Report screen size, density, Android version and the foreground activity.

ParameterTypeDescription
serial

flutter_connect

Connect to a running Flutter app's Dart VM Service. Call this first. The VM Service URI is printed to logcat only at launch, and only by debug and profile builds. If it has already scrolled out of the buffer, pass relaunch=True to restart the app and capture it. Args: package: application id, needed for relaunch. relaunch: force-stop and restart the app to capture a fresh URI. serial: device serial when several are attached.

ParameterTypeDescription
package
relaunchboolean
serial

flutter_widget_tree

Show the live widget tree with the source location of each widget. Only widgets from your own project are shown by default — the framework's own wrappers are noise. Each line ends with the file and line that built it. Args: contains: case-insensitive filter on widget type or description. max_depth: 0 for no limit, otherwise prune deeper than this. limit: max widgets returned. include_framework: also show widgets from Flutter and third-party packages. package, serial: as elsewhere.

ParameterTypeDescription
contains
include_frameworkboolean
limitinteger
max_depthinteger
package
serial

flutter_locate

Find something on screen and report both how to tap it and where it lives in code. This is the bridge: tap coordinates come from Android's semantics tree, while the widget type and source location come from the Dart VM Service. Use it to go from "this looks wrong on screen" to the exact line that built it. Args: text: visible text, semantics label or widget type to look for. package, serial: as elsewhere.

ParameterTypeDescription
text *string
package
serial

flutter_diagnose

Correlate Dart-side errors with the native Android log around them. A Flutter failure usually leaves two unrelated-looking traces: a Dart exception and, for anything crossing a platform channel, a Java/Kotlin one in logcat. This pulls both and puts them next to each other in time order. Args: package: app to restrict native logs to, e.g. com.example.app. limit: how many Dart errors to report. serial: device serial when several are attached.

ParameterTypeDescription
limitinteger
package
serial

ui_checkpoint

Remember the current screen so a later ui_diff can show what changed. Take one before editing code, then call ui_diff after hot reloading. Args: label: name for this checkpoint. serial: device serial when several are attached.

ParameterTypeDescription
labelstring
serial

ui_diff

Compare the screen now against a checkpoint and highlight what moved. Returns a summary plus the current screen with changed regions outlined, so you can confirm an edit did what you meant and did not disturb anything else. Args: label: which checkpoint to compare against. threshold: per-channel difference (0-255) that counts as a real change. Raise it to ignore animations and anti-aliasing. max_width: longest edge of the returned image. serial: device serial when several are attached.

ParameterTypeDescription
labelstring
max_widthinteger
serial
thresholdinteger

flutter_attach

Attach the Flutter tool to the running app so hot reload becomes possible. Needed once per session before flutter_hot_reload: the VM Service on its own has no Dart compiler, so source edits cannot be applied without this. Args: project_dir: the Flutter project root, the directory holding pubspec.yaml. serial: device serial when several are attached.

ParameterTypeDescription
project_dir *string
serial

flutter_hot_reload

Apply Dart source edits to the running app. Requires flutter_attach first. Use full_restart after changing initState, global state or main(), which a plain reload cannot pick up. Args: full_restart: hot restart instead of hot reload. package, serial: as elsewhere.

ParameterTypeDescription
full_restartboolean
package
serial

flutter_detach

End the attach session, leaving the app running on the device.