Skip to content

Commit 22f028e

Browse files
committed
Add error handling for MCP Inspector launch failures with user notifications
1 parent acdf25d commit 22f028e

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

Unity-MCP-Plugin/Assets/root/Editor/Scripts/UI/MenuItems.cs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,49 @@ public static void LaunchMcpInspector()
9393
UseShellExecute = true,
9494
CreateNoWindow = false,
9595
};
96-
System.Diagnostics.Process.Start(processInfo);
96+
97+
try
98+
{
99+
System.Diagnostics.Process.Start(processInfo);
100+
}
101+
catch (System.ComponentModel.Win32Exception ex)
102+
{
103+
var command = $"{processInfo.FileName} {processInfo.Arguments}";
104+
NotificationPopupWindow.Show(
105+
windowTitle: "Launch Failed",
106+
title: "Unable to start MCP Inspector",
107+
message:
108+
"The MCP Inspector could not be started from Unity.\n\n" +
109+
"This usually means that Node.js (and npx) is not installed, or 'npx' is not available on your PATH.\n\n" +
110+
"Prerequisites:\n" +
111+
" - Install Node.js (which includes npx)\n" +
112+
" - Ensure 'npx' is available from your terminal/command prompt\n\n" +
113+
"You can try running the following command manually in a terminal:\n" +
114+
command + "\n\n" +
115+
"System error:\n" +
116+
ex.Message,
117+
width: 450,
118+
minWidth: 450,
119+
height: 460,
120+
minHeight: 460);
121+
}
122+
catch (System.Exception ex)
123+
{
124+
var command = $"{processInfo.FileName} {processInfo.Arguments}";
125+
NotificationPopupWindow.Show(
126+
windowTitle: "Launch Failed",
127+
title: "Unexpected error starting MCP Inspector",
128+
message:
129+
"An unexpected error occurred while trying to start the MCP Inspector.\n\n" +
130+
"You can try running the following command manually in a terminal:\n" +
131+
command + "\n\n" +
132+
"Error details:\n" +
133+
ex.Message,
134+
width: 450,
135+
minWidth: 450,
136+
height: 460,
137+
minHeight: 460);
138+
}
97139
}
98140

99141
[MenuItem("Tools/AI Game Developer/Debug/Show Update Popup", priority = 2000)]

0 commit comments

Comments
 (0)