Skip to content

[Bug]: avdt mcp attach-to-app / attach-to-file always times out (cross-platform, 2.2.0-beta2) #10

@C5T8fBt-WY

Description

@C5T8fBt-WY

Describe the bug

Both attach-to-app and attach-to-file MCP tool calls return TimeoutException after ~5 seconds. The MCP server discovers the app correctly (availableClients returns app name/PID), but the connection step always fails.

The DevTools GUI mode (avdt --connect --session-id X --http-port 29414) works perfectly.

To Reproduce

  1. Install avdt 2.2.0-beta2: dotnet tool install --global AvaloniaUI.DeveloperTools --prerelease
  2. Add AvaloniaUI.DiagnosticsSupport 2.2.0-beta2 to any Avalonia 11.x app
  3. Call this.AttachDeveloperTools() in App.Initialize() under #if DEBUG
  4. Configure MCP in .vscode/mcp.json:
    {
      "servers": {
        "avalonia_devtools": {
          "type": "stdio",
          "command": "avdt",
          "args": ["mcp"],
          "env": { "ACCELERATE_LICENSE_KEY": "avln_on_key:v1:..." }
        }
      }
    }
  5. Start the app, invoke attach-to-app via any MCP client (VSCode, Claude Code, etc.)

Expected: Connection established, MCP tools (tree, search, props, etc.) return data
Actual: TimeoutException after ~5 seconds

Product(s)

DevTools

Platform

Windows, Linux

Accelerate Tier

Trial

Avalonia version

11.3.3

Accelerate Version

No response

Relevant log output

Starting HTTP server: DevToolsTargetListenerOptions { HttpsPort = , HttpPort = 39141, ListenAnyIp = False }
Failed to connect to client with process ID 35771
System.TimeoutException: The operation has timed out.
  at AvaloniaUI.DeveloperTools.Mcp.McpDevToolsConnection.<ConnectToClientAsync>d__19.MoveNext()

Additional context

1. Discovery pipe exists, app IS listening:

$ lsof -p <APP_PID> | grep CoreFx
StabilityS <APP_PID> lilyknight 172u unix 0x00 0t0 541826 /tmp/CoreFxPipe_Global.AVDT.Discovery type=STREAM (LISTEN)

2. MCP server process NEVER opens the discovery pipe:

$ lsof -p <MCP_PID> | grep -i "CoreFx\|AVDT"
(no output)

The MCP process has only stdio Unix sockets (fd 0,1,2,5,6,9,13 — all connected to the editor).

3. MCP ignores settings.json httpPort:

  • settings.json has "httpPort": 29414
  • GUI mode: uses 29414 ✓
  • MCP mode: uses random ports (38105, 39141, 35463 observed across multiple runs) ✗

4. Connection CAN be established via workaround:
Using ConnectOnStartup = true + Protocol = CreateHttp(Loopback, 29414) + a TCP forwarder (port 29414 → MCP's random port), the app successfully connects:

# MCP log after workaround:
Target connected, SessionId: 7tdgWeOcmKu, ProtocolVersion: 1.1.0

5. attach-to-app ignores existing connections:
Even after the app is successfully connected (see workaround above), calling attach-to-app again still times out. It always attempts a fresh discovery pipe approach instead of checking for existing connected sessions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions