From ad4f2c4a68a2ea619ce609e1f46fd1a2d1dfb077 Mon Sep 17 00:00:00 2001 From: Connie Yau Date: Fri, 1 May 2026 11:55:11 -0700 Subject: [PATCH 1/4] Write to Error output. --- .../Azure/Authentication/WindowHandleProvider.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs b/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs index 4eb3483d27..8dc52e92a8 100644 --- a/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs +++ b/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs @@ -26,7 +26,10 @@ 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."); return display; @@ -35,9 +38,7 @@ public static IntPtr GetWindowHandle() { // 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: {typeof(Exception).FullName}"); } } From a21624ed7504a59079b28b5b7f85cdd025048dfe Mon Sep 17 00:00:00 2001 From: Connie Yau Date: Fri, 1 May 2026 12:11:34 -0700 Subject: [PATCH 2/4] Add changelog entry. --- servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml diff --git a/servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml b/servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml new file mode 100644 index 0000000000..544cb24bc3 --- /dev/null +++ b/servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml @@ -0,0 +1,3 @@ +changes: + - section: "Bugs Fixed" + description: "Fix issue where writing exception to stdio is interpreted as JSON RPC response." From 67a8c9d6188813ca373b63570e42bdbbd67746fd Mon Sep 17 00:00:00 2001 From: Connie Yau Date: Fri, 1 May 2026 12:35:11 -0700 Subject: [PATCH 3/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml b/servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml index 544cb24bc3..527c544203 100644 --- a/servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml +++ b/servers/Azure.Mcp.Server/changelog-entries/1777662676190.yaml @@ -1,3 +1,3 @@ changes: - section: "Bugs Fixed" - description: "Fix issue where writing exception to stdio is interpreted as JSON RPC response." + description: "Fix issue where writing exception to stdout is interpreted as JSON RPC response." From 4fcbd346879a46832058b86a4ae4129d126fda64 Mon Sep 17 00:00:00 2001 From: Connie Yau Date: Fri, 1 May 2026 12:38:12 -0700 Subject: [PATCH 4/4] Apply getType().FullName --- .../src/Services/Azure/Authentication/WindowHandleProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs b/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs index 8dc52e92a8..c0abac68d0 100644 --- a/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs +++ b/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/WindowHandleProvider.cs @@ -34,11 +34,11 @@ public static IntPtr GetWindowHandle() : "X display is available."); 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.Error.WriteLine($"Failed to detect X display. Running in headless mode. Exception type: {typeof(Exception).FullName}"); + Console.Error.WriteLine($"Failed to detect X display. Running in headless mode. Exception type: {exception.GetType().FullName}"); } }