Skip to content

DevServer MCP launches another solution than the one selected (monitor rescan, candidate check, workspace watcher) #25524

Description

@carldebilly

Current behavior

The DevServer MCP bridge (dnx uno.devserver --mcp-app) can resolve the right solution and then start the DevServer host with another one. An explicit uno_app_select_solution cannot always correct it.

Repro layout (one global.json at the repository root, an app solution four levels below it, a library-only solution higher up):

root/
├── global.json                  (msbuild-sdks: Uno.Sdk)
└── a/
    ├── Lib/Lib.sln              (class libraries only)
    └── b/c/d/App.sln            (the app head)

Start the MCP bridge in root/a/b/c/d. Workspace discovery reports selectedSolutionPath: …/a/b/c/d/App.sln (AutoDiscovered), but the host is launched with --solution …/a/Lib/Lib.sln. No app ever registers, and CsprojUserGenerator writes the DevServer port into the library projects' .csproj.user. uno_app_select_solution with the absolute path of App.sln does not help: the path is accepted as a candidate, resolves to the same workspace (Refresh, no-op), and even forceRestart relaunches through the same rescan.

Cause

Line numbers are on master (9e17b82), under src/Uno.UI.DevServer.Cli/. The solution is decided again in several places after the resolver has chosen it, and only the first one honors the choice:

  1. WorkspaceResolver selects App.sln correctly; its effective workspace directory is the folder of the nearest Uno global.json, here root (Helpers/WorkspaceResolver.cs:37-60, 208-240).
  2. DevServerMonitor.RunMonitor rescans that directory on every cycle with SolutionFileFinder.FindSolutionFiles (max depth 3, Mcp/DevServerMonitor.cs:159). DetermineSolutionToLaunch (426-444) uses SelectedSolutionPath only if the rescan contains it, and otherwise launches the first scanned solution in sorted order. An empty rescan never launches at all (SolutionNotFound, 173). The value drives --solution (648-652), the .csproj.user port (629) and ambient-host reuse (281, 611).
  3. uno_app_select_solution rejects any path that is not in a depth-3 candidate scan of the observed root (Mcp/ProxyLifecycleManager.cs:278-299, 1003-1015; WorkspaceResolver.cs:166-167), so a solution outside the directory the bridge started in, or deeper than the scan, cannot be selected.
  4. The workspace watcher re-resolves on any global.json, project.assets.json, .sln or .slnx change with plain ResolveAsync(root), ignoring the selection, and may restart onto another solution or stop (ProxyLifecycleManager.cs:428-440, 560-572; Mcp/WorkspaceTransitionDecisions.cs:35-53). A dotnet restore is enough to trigger it.
  5. MCP roots still drive discovery, and roots pointing elsewhere degrade the session (ProxyLifecycleManager.cs:372-426, 519-543, 1163-1234).

Add-in discovery has the same depth limit (#24311): UnoToolsLocator scans root/obj and root/*/obj only, so for this layout Uno.UI.App.Mcp is also missing from --addins and the host exposes no MCP tools, even once --solution is right.

Expected behavior

A solution the agent selects is authoritative; discovery helps choose, it does not restrict. This also follows the MCP 2026-07-28 revision, which deprecates roots (SEP-2577) and points servers at tool parameters and server configuration instead.

  • uno_app_select_solution accepts any absolute, existing .sln/.slnx, inside or outside the directory the bridge started in; it is refused only when the DevServer cannot start for it (no resolvable Uno.Sdk), with that reason. uno_health keeps listing discovered candidates as suggestions.
  • With a selection, the monitor launches exactly that solution; the rescan and its sorted fallback apply only when nothing is selected (with a warning when the fallback picks among several), and an empty rescan does not block a selected solution.
  • File changes do not replace a selected solution: a change to its global.json or to the solution restarts the same solution; deleting it degrades the session with a message.
  • Roots are hints for auto-discovery only and never override a selection.
  • A --solution <path> startup argument, next to --solution-dir, for MCP server configurations.
  • Add-in discovery reads the restored assets of the projects listed in the selected solution (DevServer add-in discovery misses project.assets.json when projects sit more than one level below the workspace root #24311).

Security: accepting any solution adds no trust boundary. The stdio bridge is started locally by the user, and the agent already has its own access to the files; the selection stays logged and visible in uno_health.

Workaround

Copy the root global.json, unchanged, next to the app solution: the resolver stops at the nearest global.json, so the app solution's folder becomes the effective workspace (depth 0 for the rescan, */obj for add-in discovery).

Environment

Reported with Uno.WinUI.DevServer 6.7.103 (Uno.Sdk 6.7.22) on macOS with the Codex CLI; the code involved is unchanged on master.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions