What happened?
On Windows, "Start Server" (and the auto-start path) in the MCP for Unity window fails every time with:
error: The handle is invalid. (os error 6)
This is the entire contents of Library/MCPForUnity/Logs/server-launch-{port}.log — no FastMCP banner, no traceback, nothing else. The (os error N) formatting is uv's/uvx's own Rust error-printing style (Python would say [WinError 6]), so the failure happens inside uvx itself, before it gets anywhere near launching the Python server.
I believe this is a regression from #1201 (fixes #1188 — hides the terminal window on Windows by launching headless via CreateNoWindow = true with no explicit stdio redirection).
Root cause
TerminalLauncher.CreateHeadlessProcessStartInfo (Windows branch) builds:
FileName = "cmd.exe",
Arguments = $"/c \"{command} >> \"{logFilePath}\" 2>&1\"",
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden
with none of RedirectStandardInput/Output/Error set — the >>/2>&1 redirection is left entirely to cmd.exe's own command-line parsing rather than the ProcessStartInfo.
The Unity Editor process itself is a GUI-subsystem process with no console at all. When it starts a child with CreateNoWindow = true and no stdio redirection, per the Win32 docs for that flag ("the console handle for the application is not set"), the resulting cmd.exe → uvx.exe chain gets no real console. cmd.exe's own >> file 2>&1 redirection gives it a valid stdout/stderr (a real file handle), but stdin is never touched, so uvx.exe inherits a console-less/invalid stdin. uvx then appears to touch that handle early during startup (plausibly for Ctrl-C/TTY setup) and dies immediately with ERROR_INVALID_HANDLE before it ever gets to spawn the Python venv / print anything.
Reproduction steps
- On Windows, open a Unity project with MCP for Unity (HTTP transport, default settings).
- Window > MCP for Unity > Start Server (or let auto-start trigger it).
- Observe:
Local HTTP server did not become reachable. with the log containing only error: The handle is invalid. (os error 6).
- This is deterministic — every attempt from inside the Unity Editor process fails identically, including with a warm
uv cache (so it isn't a first-run download/extraction race).
- Confirming it's specific to the console-less parent: copy the exact command Unity prints in the error dialog ("To run it yourself, copy this command into a terminal") and run it via an equivalent
ProcessStartInfo (cmd.exe /c "<command> >> log 2>&1", UseShellExecute=false, CreateNoWindow=true, no stdio redirection) but spawned from a process that already owns a console (e.g. a PowerShell/cmd session) instead of from Unity — it starts cleanly every time (FastMCP banner, Uvicorn listening). Running the identical command directly in a terminal ("To run it yourself...") also always works, which is why that fallback advice in the error dialog is misleading here — it works precisely because a terminal has a console, which is the variable that matters.
Suggested fix
Give the child process a real (even if empty) stdin instead of none, e.g. in the Windows branch of CreateHeadlessProcessStartInfo, redirect stdin from NUL:
string winRedirect = $"{command} < NUL >> \"{logFilePath}\" 2>&1";
or set RedirectStandardInput = true on the ProcessStartInfo and immediately close the stream after start. Either should give uvx.exe a valid handle to query instead of none.
Unity version
6000.0.78f1
MCP for Unity package version
10.1.0
Python server version
mcpforunityserver==10.1.0
MCP client
Claude Code
Transport
HTTP (default)
OS
Windows (11)
Relevant logs / console output
Library/MCPForUnity/Logs/server-launch-8080.log:
error: The handle is invalid. (os error 6)
Unity console:
MCP-FOR-UNITY: Local HTTP server did not become reachable. Launch log: C:\...\Library\MCPForUnity\Logs\server-launch-8080.log
error: The handle is invalid. (os error 6)
To run it yourself, copy this command into a terminal:
C:\Users\User\.local\bin\uvx.exe --from "mcpforunityserver==10.1.0" mcp-for-unity --transport http --http-url http://127.0.0.1:8080 --project-scoped-tools
UnityEngine.Debug:LogError (object)
MCPForUnity.Editor.Helpers.McpLog:Error (string) (at ./Library/PackageCache/com.coplaydev.unity-mcp@.../Editor/Helpers/McpLog.cs:50)
MCPForUnity.Editor.Services.ServerManagementService:LogLocalHttpServerLaunchFailure () (at ./Library/PackageCache/com.coplaydev.unity-mcp@.../Editor/Services/ServerManagementService.cs:1053)
MCPForUnity.Editor.Windows.Components.Connection.McpConnectionSection/<TryAutoStartSessionAsync>d__64:MoveNext () (at ./Library/PackageCache/com.coplaydev.unity-mcp@.../Editor/Windows/Components/Connection/McpConnectionSection.cs:798)
...
Checks
What happened?
On Windows, "Start Server" (and the auto-start path) in the MCP for Unity window fails every time with:
This is the entire contents of
Library/MCPForUnity/Logs/server-launch-{port}.log— no FastMCP banner, no traceback, nothing else. The(os error N)formatting isuv's/uvx's own Rust error-printing style (Python would say[WinError 6]), so the failure happens insideuvxitself, before it gets anywhere near launching the Python server.I believe this is a regression from #1201 (fixes #1188 — hides the terminal window on Windows by launching headless via
CreateNoWindow = truewith no explicit stdio redirection).Root cause
TerminalLauncher.CreateHeadlessProcessStartInfo(Windows branch) builds:with none of
RedirectStandardInput/Output/Errorset — the>>/2>&1redirection is left entirely tocmd.exe's own command-line parsing rather than theProcessStartInfo.The Unity Editor process itself is a GUI-subsystem process with no console at all. When it starts a child with
CreateNoWindow = trueand no stdio redirection, per the Win32 docs for that flag ("the console handle for the application is not set"), the resultingcmd.exe → uvx.exechain gets no real console.cmd.exe's own>> file 2>&1redirection gives it a valid stdout/stderr (a real file handle), but stdin is never touched, souvx.exeinherits a console-less/invalid stdin.uvxthen appears to touch that handle early during startup (plausibly for Ctrl-C/TTY setup) and dies immediately withERROR_INVALID_HANDLEbefore it ever gets to spawn the Python venv / print anything.Reproduction steps
Local HTTP server did not become reachable.with the log containing onlyerror: The handle is invalid. (os error 6).uvcache (so it isn't a first-run download/extraction race).ProcessStartInfo(cmd.exe /c "<command> >> log 2>&1",UseShellExecute=false,CreateNoWindow=true, no stdio redirection) but spawned from a process that already owns a console (e.g. a PowerShell/cmd session) instead of from Unity — it starts cleanly every time (FastMCP banner, Uvicorn listening). Running the identical command directly in a terminal ("To run it yourself...") also always works, which is why that fallback advice in the error dialog is misleading here — it works precisely because a terminal has a console, which is the variable that matters.Suggested fix
Give the child process a real (even if empty) stdin instead of none, e.g. in the Windows branch of
CreateHeadlessProcessStartInfo, redirect stdin fromNUL:or set
RedirectStandardInput = trueon theProcessStartInfoand immediately close the stream after start. Either should giveuvx.exea valid handle to query instead of none.Unity version
6000.0.78f1
MCP for Unity package version
10.1.0
Python server version
mcpforunityserver==10.1.0
MCP client
Claude Code
Transport
HTTP (default)
OS
Windows (11)
Relevant logs / console output
Library/MCPForUnity/Logs/server-launch-8080.log:Unity console:
Checks