Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ public static IntPtr GetWindowHandle()
try
{
IntPtr display = XOpenDisplay(":1");
Console.WriteLine(display == IntPtr.Zero

// Do not write to standard output because it is interpreted as a JSON RPC response
// from the MCP server. Instead, write to standard error for diagnostics.
Console.Error.WriteLine(display == IntPtr.Zero
? "No X display available. Running in headless mode."
: "X display is available.");
Comment thread
conniey marked this conversation as resolved.
return display;
}
catch (Exception)
catch (Exception exception)
{
// X11 display detection failed; running in headless mode.
// Avoid logging exception details to console to prevent information disclosure.
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Failed to detect X display. Running in headless mode. Exception type: {typeof(Exception).FullName}");
Console.ResetColor();
Console.Error.WriteLine($"Failed to detect X display. Running in headless mode. Exception type: {exception.GetType().FullName}");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changes:
- section: "Bugs Fixed"
description: "Fix issue where writing exception to stdout is interpreted as JSON RPC response."