Skip to content

[Repo Assist] fix: remove redundant log.Printf calls from connection.go#3640

Merged
lpcox merged 2 commits intomainfrom
repo-assist/fix-issue-3633-connection-log-69a4aff3d1c4192e
Apr 12, 2026
Merged

[Repo Assist] fix: remove redundant log.Printf calls from connection.go#3640
lpcox merged 2 commits intomainfrom
repo-assist/fix-issue-3633-connection-log-69a4aff3d1c4192e

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Addresses #3633.

Problem

internal/mcp/connection.go had five log.Printf calls that either duplicated adjacent logger.LogInfo structured-log calls or wrote to stderr with no structured counterpart. This meant:

  • Operators monitoring mcp-gateway.log would miss some events (e.g. "Started MCP server")
  • Operators watching stderr got duplicate lines for the same event with slightly different wording
  • The "log" standard-library import persisted only to serve these calls

Changes

Line Old New
144 log.Printf("Starting MCP server command: ...") Removed — logger.LogInfo on line 143 already covers this
148 log.Printf("Connecting to MCP server...") Removed — logConn.Print("Initiating MCP server connection and handshake") on the next line already covers this at debug level
178 log.Printf("Started MCP server: ...") Replaced with logger.LogInfo("backend", "Started MCP server: ...") — now written to mcp-gateway.log
241 log.Printf("Configured HTTP MCP server with streamable transport: ...") Removed — logger.LogInfo on line 240 already covers this
264 log.Printf("Configured HTTP MCP server with plain JSON-RPC transport: ...") Removed — logger.LogInfo on line 263 already covers this

The now-unused "log" standard-library import is also removed.

Test Status

⚠️ Infrastructure note: The Go 1.25.0 toolchain required by go.mod is unavailable in this environment (blocked by network firewall). All changes are mechanical deletions of log.Printf calls with no logic changes. go vet and make test will run in the GitHub Actions CI environment where Go 1.25.0 is available.

Trade-offs

  • The "Started MCP server" event (previously only on stderr) is now in mcp-gateway.log. This is strictly better — it was a gap in structured logging.
  • Removing the two "Connecting" and "Starting" stderr echoes reduces startup noise on stderr; the events are still visible via DEBUG=mcp:* through logConn.

Closes #3633

Generated by Repo Assist · ● 2.8M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

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>
@lpcox lpcox marked this pull request as ready for review April 12, 2026 15:58
Copilot AI review requested due to automatic review settings April 12, 2026 15:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes redundant log.Printf calls in internal/mcp/connection.go to ensure MCP connection lifecycle events are logged consistently through the structured logger (and to drop the now-unused stdlib log import).

Changes:

  • Removed duplicated log.Printf messages that mirrored adjacent logger.LogInfo calls.
  • Replaced the stderr-only “Started MCP server …” message with a structured logger.LogInfo.
  • Removed the unused "log" import from connection.go.
Show a summary per file
File Description
internal/mcp/connection.go Removes redundant stderr logging in favor of structured logging for MCP connection setup events.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit ab5d495 into main Apr 12, 2026
14 checks passed
@lpcox lpcox deleted the repo-assist/fix-issue-3633-connection-log-69a4aff3d1c4192e branch April 12, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[duplicate-code] Duplicate Code Pattern: Mixed log.Printf / logger.LogInfo Parallel Logging in connection.go

2 participants