From 154daefacb80cdff997652e62ee0f579154594eb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 12 Apr 2026 12:35:05 +0000 Subject: [PATCH 1/2] fix: remove redundant log.Printf calls from connection.go Addresses #3633. Five log.Printf calls in internal/mcp/connection.go were either duplicating adjacent logger.LogInfo structured-log calls or writing to stderr with no structured counterpart: - Remove log.Printf at line 144 (duplicate of logger.LogInfo line 143) - Remove log.Printf "Connecting to MCP server..." (logConn.Print at line 149 already covers this at debug level) - Replace log.Printf "Started MCP server" (line 178) with logger.LogInfo so the event is captured in mcp-gateway.log - Remove log.Printf "Configured HTTP MCP server with streamable transport" (duplicate of logger.LogInfo line 240) - Remove log.Printf "Configured HTTP MCP server with plain JSON-RPC transport" (duplicate of logger.LogInfo line 263) Remove the now-unused "log" standard-library import from connection.go. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/mcp/connection.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/mcp/connection.go b/internal/mcp/connection.go index 57374691..73a723a1 100644 --- a/internal/mcp/connection.go +++ b/internal/mcp/connection.go @@ -7,7 +7,6 @@ import ( "encoding/json" "fmt" "io" - "log" "net/http" "os/exec" "strings" @@ -141,11 +140,9 @@ func NewConnection(ctx context.Context, serverID, command string, args []string, }() logger.LogInfo("backend", "Starting MCP backend server, command=%s, args=%v", command, sanitize.SanitizeArgs(expandedArgs)) - log.Printf("Starting MCP server command: %s %v", command, sanitize.SanitizeArgs(expandedArgs)) transport := &sdk.CommandTransport{Command: cmd} // Connect to the server (this handles the initialization handshake automatically) - log.Printf("Connecting to MCP server...") logConn.Print("Initiating MCP server connection and handshake") session, err := client.Connect(ctx, transport, nil) if err != nil { @@ -175,7 +172,7 @@ func NewConnection(ctx context.Context, serverID, command string, args []string, isHTTP: false, } - log.Printf("Started MCP server: %s %v", command, sanitize.SanitizeArgs(args)) + logger.LogInfo("backend", "Started MCP server: %s %v", command, sanitize.SanitizeArgs(args)) return conn, nil } @@ -238,7 +235,6 @@ func NewHTTPConnection(ctx context.Context, serverID, url string, headers map[st conn, err := tryStreamableHTTPTransport(ctx, cancel, serverID, url, headers, headerClient, keepAlive) if err == nil { logger.LogInfo("backend", "Successfully connected using streamable HTTP transport, url=%s", url) - log.Printf("Configured HTTP MCP server with streamable transport: %s", url) return conn, nil } logConn.Printf("Streamable HTTP failed: %v", err) @@ -261,7 +257,6 @@ func NewHTTPConnection(ctx context.Context, serverID, url string, headers map[st conn, err = tryPlainJSONTransport(ctx, cancel, serverID, url, headers, headerClient) if err == nil { logger.LogInfo("backend", "Successfully connected using plain JSON-RPC transport, url=%s", url) - log.Printf("Configured HTTP MCP server with plain JSON-RPC transport: %s", url) return conn, nil } logConn.Printf("Plain JSON-RPC transport failed: %v", err) From 4462ca9b73c0acfd4905f6e4e6557d180ae50952 Mon Sep 17 00:00:00 2001 From: Landon Cox Date: Sun, 12 Apr 2026 09:02:16 -0700 Subject: [PATCH 2/2] Update internal/mcp/connection.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- internal/mcp/connection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/mcp/connection.go b/internal/mcp/connection.go index 73a723a1..7e283af5 100644 --- a/internal/mcp/connection.go +++ b/internal/mcp/connection.go @@ -172,7 +172,7 @@ func NewConnection(ctx context.Context, serverID, command string, args []string, isHTTP: false, } - logger.LogInfo("backend", "Started MCP server: %s %v", command, sanitize.SanitizeArgs(args)) + logger.LogInfo("backend", "Started MCP server: %s %v", command, sanitize.SanitizeArgs(expandedArgs)) return conn, nil }