Refactor HTTP client transport cloning in MCP transport builders - #9132
Merged
Conversation
5 tasks
Copilot
AI
changed the title
[WIP] Refactor duplicate HTTP client transport cloning code
Refactor HTTP client transport cloning in MCP transport builders
Jul 11, 2026
lpcox
marked this pull request as ready for review
July 11, 2026 18:55
Contributor
There was a problem hiding this comment.
Pull request overview
Renames the existing shared HTTP client cloning helper and adds focused unit coverage.
Changes:
- Renames
cloneHTTPClientWithTransport. - Tests cloning and default transport resolution.
- No functional transport-building change.
Show a summary per file
| File | Description |
|---|---|
internal/mcp/http_transport_client.go |
Renames the shared cloning helper. |
internal/mcp/http_transport_test.go |
Adds helper unit tests. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Medium
Comment on lines
+49
to
+51
| // cloneClientWithTransport returns a shallow copy of baseClient with the given transport. | ||
| // Callers constructing a wrapper transport should use resolveBaseTransport to obtain its base. | ||
| func cloneHTTPClientWithTransport(baseClient *http.Client, newTransport http.RoundTripper) *http.Client { | ||
| func cloneClientWithTransport(baseClient *http.Client, newTransport http.RoundTripper) *http.Client { |
Collaborator
|
@copilot address review feedback |
Contributor
Author
Updated the PR description to accurately reflect the scope of the change: it's a rename of the existing shared helper plus new unit tests, with no duplication removed (both builders already shared |
This was referenced Jul 11, 2026
Closed
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.
Renames the shared HTTP client cloning helper in
internal/mcp/http_transport_client.goand adds focused unit coverage.cloneHTTPClientWithTransport→cloneClientWithTransport(drops the redundantHTTPinfix; both call sites updated)TestCloneClientWithTransport— verifies shallow-clone behavior and transport replacementTestResolveBaseTransport— verifiesnil-transport fallback tohttp.DefaultTransportNo functional changes; both
buildHTTPClientWithHeadersandbuildHTTPClientWithOIDCalready shared the same helper before this PR.