mcp library
Module D — MCP server. One barrel covering the server class, the per-connection session, the response envelope, the tool base + registry, and the concrete tool implementations.
Classes
- AppLogsTool
-
Query the app-side log buffer — FlutterError exceptions, developer.log
messages, anything the running Flutter app wrote to stderr or logging.
Distinct from the
logstool which records glint's own tool calls. - AppSession
- Everything one attachment owns: the VM runtime, the device backend, the perception pipeline, app logs, reconnect and lifecycle watchers. A GlintSession pools several of these and delegates to the active one.
- ArmingFailed
- ArmingOutcome
- Shared armed-intent gate for targeted action tools. Returns one of three outcomes; callers branch sealed-style.
- ArmingReady
- ArmingSkipped
- AttachTool
-
attach— connect to a Flutter app's VM and bind the device it's actually running on. Every argument is optional: glint discovers the app, derives the platform from the VM, correlates the app to its real simulator (so it picks the right one even with several booted), and reports device + app identity, capabilities, and screen context in one reply. - BatchTool
-
batch— run an ordered list of gesture steps server-side in one call. Each step settles like a normal call; the batch stops at the first error or (by default) the first step that changed nothing, and returns one final scene. Cuts a known N-step flow from N round trips to one. - BreakpointTool
-
breakpointpauses the app when one of its log lines matches a regex, screenshots that moment, and resumes on command. - Capture
- One background screenshot and why it was taken.
- CaptureRing
- The last max screenshots of one device, newest first. Evicting an entry deletes its file; clear deletes them all. Never throws.
- ConfigTool
-
Get / set runtime defaults — poll cadences, ceilings, scroll size.
Ops:
get(full snapshot) orset(one key/value). - DeviceTool
-
device— inspect or configure an iOS simulator. Defaults to the attached device; passudidto target another booted sim. ops: status (default) | appearance | openurl | screenshot | privacy. Heavier control (location, biometrics, push, status-bar) is roadmapped. - DragTool
- Mechanically a swipe with a longer default hold so listeners recognise it as drag rather than fling.
- ExploreTool
- Reads the persistent screen graph glint builds from every action and scene read: where the app has been, what was tried, what is left.
- GetSceneTool
-
get_scene— the semantic scene for the current screen. Text by default, JSON on request. - GlintMcpServer
- The glint MCP server. Registers every tool in kDefaultGlintTools against a single GlintSession held for the connection's lifetime.
- GlintSession
- Per-connection state: a pool of attached apps (one per device) plus the active one every tool reads through. Getters delegate to the active AppSession; accessing them with nothing attached throws SessionNotAttachedError. actionLog is always available — survives detach so cross-attach history stays queryable.
- GlintTool
- One MCP tool. Subclasses provide a definition + handle; invoke wraps both with the envelope conversion + uniform error catch.
- HardwareButtonTool
- iOS Xcode 26: lock + unlock + home + back (left-edge swipe) wired. Others (volumeUp/Down, appSwitcher) raise UnsupportedBackendAction. See source-of-truth §13.
- HotReloadTool
-
hot_reloadreloads or restarts the attached app through the services its ownflutter runregistered, so no other project's app is ever touched. - KeyTool
- The editing keys and a change signal follow a press, so an agent can clear a field, submit a form, or move the caret without a printable character.
- KillAppTool
-
kill_app— stop a running app glint started (or the attached one) and detach. - LocationTool
-
locationsets where the device thinks it is, or drives it along a route in the background while the agent keeps using the app. - LogsTool
- Query the action log. Every tool call is recorded automatically (success or failure) with timestamp + args + summary + elapsedMs.
- LongPressTool
- MapTool
-
mapreads a Google map and moves it the way a finger does: tap a marker, pan, zoom. - MediaTool
-
mediaputs photos, videos and audio in the device gallery, lists and pulls what the app wrote, and inspects media files (a glint test card decodes to rotation, mirror, scale, frames and audio sync). - RecordTool
- Records the display while a short step sequence runs and returns the distinct frames, so an agent can see a screen that only flashes mid-transition.
- ReportIssueTool
-
Files a bug / UX / feature note into glint's public GitHub repo via the local
ghCLI, or a pre-filled deep link; everything is path- and secret-redacted first. - ResolveTool
- Read-only geometry lookup. Resolves a glintId against the live render tree and returns its logical-point center, bounds, painted, hittable flags — without side effects. Use this when you need to know where a node is without firing a gesture against it.
- ScrollToFindTool
-
Loops
get_scene+scrolluntil a target (glintId or text content) is on screen (and hittable for tap:true), or the ceiling is reached. Stops early if already visible. - ScrollTool
- SessionTool
-
session— group action-log entries into named runs. One active session at a time; opening a new one auto-closes the previous. Ops: status / open / close / note / list / export / detach. - ShutdownSimTool
-
shutdown_sim— shut down a simulator/emulator, or all booted ones. - StructuredResponse
-
Common reply shape: summary + optional warnings + nextSteps.
Renders both human text and
structuredContentso callers can branch on data instead of parsing prose. - SwipeTool
- TapTool
- TelemetryTool
- Inspect or trigger glint's telemetry pipeline: status — opt-out + recorder + store + watermark state report — local rollup: per-tool stats, error kinds, transitions ship — build + send a rollup now (also writes audit log) dryRun — like ship but doesn't post or advance the watermark token_usage — estimated agent-side token cost per tool audit_show — pretty-print recent audit entries audit_verify — walk the hash chain Usage is recorded locally; nothing is sent unless the user sets GLINT_TELEMETRY=on.
- TouchesOutcome
- What an app answered when asked to show or hide touches; errorKind is set when it could not.
- TypeTool
- WaitForSettleTool
- §8.4: poll frame quiescence + loading affordances, return when the screen is stable or the ceiling is reached.
Enums
- FindVerdict
- What one read of the target means for the scroll loop.
- SceneDetail
- How far to enrich a scene: structural = overlays + route (cheap); interactive = also input values + toggle states (change-detection); full = also icon names + inline link detection (for rendering).
- SceneMode
- Whether an app is read through the Flutter VM tree or the native OS AX tree.
- ScrollDirection
Constants
- kDefaultCallCeiling → const Duration
- The time a call may run before glint cancels it, unless its tool raises the ceiling for a wait the agent asked for.
-
kDefaultGlintTools
→ const List<
GlintTool> - The P4 v0 default tool set. Pass a different list to GlintMcpServer.fromStreamChannel to plug in custom tools while keeping the same envelope + session contract.
- nativeRunnerGrace → const Duration
- How long attach waits for a runner start before replying; a warm start is up well inside it.
- nativeRunnerPending → const String
- scrollHoldMs → const int
- Rest at the end of a scroll swipe so the list stops where the finger does instead of flinging on.
Functions
-
describeLifecycle(
String? lifecycle) → String - What a non-resumed lifecycle means for the agent, in one line.
-
findVerdict(
ResolvedCoord coord, {required bool tap}) → FindVerdict - A lookup needs the target painted on the viewport; a tap needs it hittable there, and a painted one that is not is covered.
-
holdsTyped(
String before, String after, String typed) → bool -
Whether
afterisbeforewithtypedinserted at one place, once iOS smart quotes and dashes are undone. -
labelsForType(
String type) → List< String> -
Labels for a filed issue:
glint, the kind, andagent-filedso the maintainer can filter MCP-originated reports. -
lifecycleIsOverlay(
String? lifecycle) → bool - True when the native layer is over the app rather than the app being away.
-
looksLikeConnectionLoss(
Object e) → bool - A read that failed because the VM service went away, whatever wrapper it arrived in.
-
maybeAwaitReady(
{required GlintSession session, required String glintId, required bool awaitReady, required int ceilingMs, String? toolLabel}) → Future< ArmingOutcome> -
If
awaitReadyis true, polls untilglintIdis hittable. ReturnsArmingReadyon success (caller proceeds with the action and tags armed metadata onto the response),ArmingFailedwith a ready-to- return envelope on miss, orArmingSkippedwhenawaitReadyis false. -
probeFailureResponse(
{required String? lifecycle, required Object? lastError, required int timeoutMs}) → StructuredResponse - The reply when the viewport never probed: a native layer over the app when it is not resumed, else the geometry reason.
-
readScrollPosition(
GlintSession session, Scene scene, String? glintId) → Future< ({bool notScrollable, (double, double, double)? position})> -
The pixels, minimum and maximum extent of the scrollable around the node
glintIdinscene, by one small eval;positionis null when it cannot be read andnotScrollablesays whether nothing scrolls there. -
reasonLine(
String detail) → String -
The line of
detailthat carries the reason: a VM header like "Unhandled exception:" is joined to the line after it, capped at 240 chars. -
refreshUpdateCheck(
) → Future< void> - Asks pub.dev for glint_mcp's latest version, at most once a day.
-
scrollTargetFor(
GlintSession session, Scene scene, SceneNode hit, ScrollDirection dir) → Future< ScrollTarget> -
The scrollable that moves
hitalongdir's axis (not whatever sits under the default swipe point) and the PageViews around it that must stay on their page; a target with no anchor keeps the default swipe. -
swipeRegion(
Rect4 screen, Rect4? clip, {bool horizontal = false}) → Rect4 -
Where to swipe:
screen(already above the keyboard) narrowed to the scrollable's visibleclip; falls back toscreenwhen the overlap is too small to swipe in (a thin strip such as a tab bar is enough across the swipe). -
updateNotice(
) → String? - The line attach shows when the last check found a newer glint on pub.dev; null when up to date or unknown.
-
withArmedMetadata(
StructuredResponse response, ArmingReady arming) → StructuredResponse -
Wraps an action's StructuredResponse with armed metadata. Use after
the action fires when
armingreports ready.