Skip to content

DevFlow MCP tools fail for Android emulator agents — IPv4/IPv6 mismatch with adb forward #268

@jongalloway

Description

@jongalloway

Summary

All DevFlow MCP tools (\maui_screenshot, \maui_status, \maui_tree, \maui_query, \maui_tap, etc.) fail when targeting an Android emulator agent, even though direct curl requests to the same agent port work perfectly. The root cause is an IPv4/IPv6 mismatch: \�db forward\ only binds on IPv4 (\127.0.0.1), but the MCP server's .NET HttpClient resolves \localhost\ and attempts IPv6 (::1) first, which fails with "Connection refused" and does not fall back.

Steps to Reproduce

  1. Start a MAUI DevFlow broker: \maui devflow broker start\
  2. Set up adb reverse for broker: \�db reverse tcp:19223 tcp:19223\
  3. Deploy and launch a MAUI app on Android emulator
  4. Note the agent port from broker (e.g., 10224)
  5. Set up adb forward: \�db forward tcp:10224 tcp:10224\
  6. Use DevFlow MCP tools (e.g., \maui_screenshot) — they all fail
  7. Use direct curl: \curl http://localhost:10224/api/screenshot --output test.png\ — works perfectly

Diagnostic Evidence

  • \curl -v http://localhost:10224/api/status\ → tries [::1]:10224\ first (fails), falls back to \127.0.0.1:10224\ (succeeds)
  • \curl -v http://[::1]:10224/api/status\ → "Failed to connect to ::1 port 10224 — Connection refused"
  • \curl -v http://127.0.0.1:10224/api/status\ → succeeds immediately
  • \maui_list_agents\ via MCP → correctly sees the agent on port 10224
  • \maui_screenshot\ via MCP → "Screenshot failed — no image data returned"
  • \maui_status\ via MCP → "Agent not responding"

Root Cause

\�db forward tcp:PORT tcp:PORT\ only binds on IPv4 loopback (\127.0.0.1), not IPv6 (::1). The MCP server's .NET \HttpClient\ resolves \localhost\ and may attempt IPv6 first. Unlike curl, it does not fall back to IPv4 on connection refused.

Workaround

Add --agent-host 127.0.0.1\ to the MCP server args in ~/.copilot/mcp-config.json:

\\json
"maui-devflow": {
"type": "local",
"command": "maui",
"args": ["devflow", "mcp", "--agent-host", "127.0.0.1"]
}
\\

Suggested Fix

When the MCP server connects to Android emulator agents (discovered via broker), it should use \127.0.0.1\ instead of \localhost\ to avoid IPv6 resolution issues with \�db forward. Alternatively, the HttpClient could be configured to prefer IPv4 or implement proper dual-stack fallback.

Environment

  • Windows 11
  • .NET 10 Preview
  • MAUI DevFlow CLI: 0.1.0-preview.8.26256.5
  • Android emulator: Pixel Tablet API 35
  • adb: Android Debug Bridge (platform-tools)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions