Skip to content

fix: select an mDNS-connected phone over Wi-Fi without adb connect - #46

Merged
Jeomon merged 2 commits into
CursorTouch:masterfrom
aftabkh4n:fix/wifi-connect-mdns-serial
Nov 22, 2026
Merged

Jeomon merged 2 commits into
CursorTouch:masterfrom
aftabkh4n:fix/wifi-connect-mdns-serial

Conversation

@aftabkh4n

Copy link
Copy Markdown
Contributor

Problem

When a phone is paired for wireless debugging, adb connects to it itself over mDNS and lists it under its service name, e.g. adb-RF8M12345-AbC9Zz._adb-tls-connect._tcp. #43 taught pick_device to treat that serial as a network device. The explicit Wi-Fi path still didn't handle it.

When a user names that serial together with Wi-Fi, through any of:

  • --connection wifi --device adb-RF8M12345-AbC9Zz._adb-tls-connect._tcp
  • ANDROID_MCP_CONNECTION=wifi with ANDROID_MCP_DEVICE=<that serial>
  • --wifi <that serial>

then normalize_wifi_address appends :5555, and connect_wifi runs adb connect adb-…_tcp:5555. That fails because the name doesn't resolve as a host:

AdbError: failed to resolve host: 'adb-RF8M12345-AbC9Zz._adb-tls-connect._tcp': Name or service not known

Even if it didn't fail there, the :5555 serial would no longer match the device adb lists, so a phone that's attached and ready can never be selected.

Change (mobile/service.py)

Host and host:port addresses behave exactly as before.

Testing

  • uv run pytest: 587 passed, 21 skipped. ruff check and ruff format --check are clean.
  • New tests, all failing on master and passing with this change:
    • TestWifi.test_normalize: an mDNS serial is kept whole.
    • TestWifi.test_mdns_serial_is_selected_without_adb_connect
    • TestResolvePreference.test_wifi_option_keeps_an_mdns_serial_whole
  • End to end through resolve_preference(device=<mDNS serial>, connection="wifi") → Session.connect_configured() and the real subprocess layer, with ANDROID_MCP_ADB_PATH pointing at a fake adb that lists the phone as device and answers adb connect like real adb does for an unresolvable name:
adb calls Result
Before connect adb-…_tcp:5555 AdbError: failed to resolve host …
After devices -l connected to adb-RF8M12345-AbC9Zz._adb-tls-connect._tcp

I don't have a wireless-debugging setup here. The serial format is the one from the scrcpy report cited in #43.

aftabkh4n and others added 2 commits November 22, 2026 06:22
A phone paired for wireless debugging is connected by adb itself over
mDNS and listed under its service name, e.g.
"adb-RF8M12345-AbC9Zz._adb-tls-connect._tcp". CursorTouch#43 taught pick_device
that such a serial is a network device, but the explicit Wi-Fi path did
not know it: with --connection wifi --device <that serial>,
ANDROID_MCP_CONNECTION=wifi + ANDROID_MCP_DEVICE, or --wifi <serial>,
normalize_wifi_address appended ":5555" and connect_wifi ran
`adb connect adb-…_tcp:5555`, which fails to resolve the name as a
host. Even past that, the ":5555" serial no longer matched the device
adb lists, so the attached, ready phone could never be selected.

normalize_wifi_address now leaves an mDNS serial as it is, and
connect_wifi selects it without `adb connect`, since adb already holds
the connection. Host and host:port addresses are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014TonJ1geSd97oAtSBZofUK
@Jeomon
Jeomon merged commit 96ca8c1 into CursorTouch:master Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants