Conversation
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/7911ff4d-69fa-49d6-b29f-f80ef626673d Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/7911ff4d-69fa-49d6-b29f-f80ef626673d Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor duplicate code in HTTP backend transport
Refactor MCP connection response logging and timeout default handling to remove duplication
Apr 16, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the MCP connection layer to remove duplicated logic around inbound RPC response logging and connect-timeout defaulting, keeping behavior consistent across HTTP (plain JSON / SDK transports) and stdio connections.
Changes:
- Introduces
normalizeConnectTimeoutto centralize the “non-positive => default” connect-timeout fallback. - Consolidates inbound RPC response logging in
SendRequestWithServerIDinto a single post-branch block. - Adds focused table-driven unit coverage for timeout normalization behavior.
Show a summary per file
| File | Description |
|---|---|
internal/mcp/connection.go |
Centralizes connect-timeout fallback and de-duplicates inbound response logging across transport branches. |
internal/mcp/connect_timeout_test.go |
Adds table-driven tests covering normalizeConnectTimeout behavior. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
This was referenced Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The HTTP backend transport refactor introduced two maintainability duplications in
internal/mcp/connection.go: repeated inbound RPC response logging across request paths, and repeated inline connect-timeout fallback logic. This change consolidates both patterns without changing request/transport behavior.Consolidate inbound response logging in
SendRequestWithServerIDresult/err.logInboundRPCResponse(...)into a single shared post-branch block.Centralize connect-timeout fallback
normalizeConnectTimeout(timeout time.Duration) time.Duration.<= 0 ? 30slogic in:NewHTTPConnection(...)reconnectSDKTransport()defaultConnectTimeoutvia one helper.Add focused timeout normalization coverage
internal/mcp/connect_timeout_test.gowith a table-driven test for:Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build1492124397/b510/launcher.test /tmp/go-build1492124397/b510/launcher.test -test.testlogfile=/tmp/go-build1492124397/b510/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 1.80.0/resolver/map.go 1.80.0/resolver/resolver.go x_amd64/vet -c -I /tmp/go-build1492124397/b165/ x_amd64/vet(dns block)/tmp/go-build2158887558/b514/launcher.test /tmp/go-build2158887558/b514/launcher.test -test.testlogfile=/tmp/go-build2158887558/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s .cfg�� pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptr-errorsas pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptr-ifaceassert 64/bin/gofmt -I /tmp/go-build273-V=full -I ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet estl�� /tmp/go-build2730629838/b437/_pkg_.a -trimpath ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -p google.golang.or/usr/bin/runc -lang=go1.24 ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build1492124397/b492/config.test /tmp/go-build1492124397/b492/config.test -test.testlogfile=/tmp/go-build1492124397/b492/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 0629838/b276/_pk-errorsas -I x_amd64/vet --gdwarf-5 re/xxhash/v2 -o x_amd64/vet go_.�� 1.80.0/credentials/insecure/inse-errorsas 2124397/b062/vet.cfg x_amd64/vet 0629838/b276/sym/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet --gdwarf2 --64 x_amd64/vet(dns block)/tmp/go-build2158887558/b496/config.test /tmp/go-build2158887558/b496/config.test -test.testlogfile=/tmp/go-build2158887558/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s -o .cfg -trimpath 64/pkg/tool/linux_amd64/vet -p JllqmO5GmEzd -lang=go1.23 64/pkg/tool/linu-trimpath .cfg�� pkg/mod/github.c-p pkg/mod/github.cmain 64/pkg/tool/linu-lang=go1.25 -p google.golang.or--norc -lang=go1.24 64/pkg/tool/linu-dwarf=false(dns block)nonexistent.local/tmp/go-build1492124397/b510/launcher.test /tmp/go-build1492124397/b510/launcher.test -test.testlogfile=/tmp/go-build1492124397/b510/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 1.80.0/resolver/map.go 1.80.0/resolver/resolver.go x_amd64/vet -c -I /tmp/go-build1492124397/b165/ x_amd64/vet(dns block)/tmp/go-build2158887558/b514/launcher.test /tmp/go-build2158887558/b514/launcher.test -test.testlogfile=/tmp/go-build2158887558/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s .cfg�� pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptr-errorsas pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptr-ifaceassert 64/bin/gofmt -I /tmp/go-build273-V=full -I ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet estl�� /tmp/go-build2730629838/b437/_pkg_.a -trimpath ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -p google.golang.or/usr/bin/runc -lang=go1.24 ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet(dns block)slow.example.com/tmp/go-build1492124397/b510/launcher.test /tmp/go-build1492124397/b510/launcher.test -test.testlogfile=/tmp/go-build1492124397/b510/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 1.80.0/resolver/map.go 1.80.0/resolver/resolver.go x_amd64/vet -c -I /tmp/go-build1492124397/b165/ x_amd64/vet(dns block)/tmp/go-build2158887558/b514/launcher.test /tmp/go-build2158887558/b514/launcher.test -test.testlogfile=/tmp/go-build2158887558/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s .cfg�� pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptr-errorsas pkg/mod/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptr-ifaceassert 64/bin/gofmt -I /tmp/go-build273-V=full -I ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet estl�� /tmp/go-build2730629838/b437/_pkg_.a -trimpath ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -p google.golang.or/usr/bin/runc -lang=go1.24 ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet(dns block)this-host-does-not-exist-12345.com/tmp/go-build1492124397/b519/mcp.test /tmp/go-build1492124397/b519/mcp.test -test.testlogfile=/tmp/go-build1492124397/b519/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true .cfg olang.org/protobuf@v1.36.11/encoding/prototext/dgoogle.golang.org/grpc/health/grpc_health_v1 x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet -o om/grpc-ecosystem/grpc-gateway/v2@v2.28.0/utilit-errorsas om/grpc-ecosystem/grpc-gateway/v2@v2.28.0/utilit-ifaceassert x_amd64/vet -p g/protobuf/encod-o -lang=go1.25 x_amd64/vet(dns block)/tmp/go-build2158887558/b523/mcp.test /tmp/go-build2158887558/b523/mcp.test -test.testlogfile=/tmp/go-build2158887558/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s estl�� -bool -buildtags ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linu--others 0629�� /tmp/go-build2730629838/b442/_pkg_.a -trimpath ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -p github.com/githu/usr/bin/runc -lang=go1.25 ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either: