The SSE implementation of the MCP client currently hard codes http.DefaultClient
https://github.com/golang/tools/blob/439ea2f0f815f46421aaecd85ffd0f75b0a303f9/internal/mcp/sse.go#L336
It should be possible to provide your own http.Client
if customization of the client is needed.
Comment From: andrey-star
I can create a PR as follows:
func NewSSEClientTransport(baseURL string) *SSEClientTransport {
return NewSSEClientTransportWithHTTPClient(baseURL, http.DefaultClient)
}
func NewSSEClientTransportWithHTTPClient(baseURL string, httpClient *http.Client) *SSEClientTransport {
url, err := url.Parse(baseURL)
if err != nil {
panic(fmt.Sprintf("invalid base url: %v", err))
}
return &SSEClientTransport{
sseEndpoint: url,
httpClient: httpClient,
}
}
Comment From: gopherbot
Change https://go.dev/cl/681115 mentions this issue: internal/mcp: add the ability to provide a custom HTTP client for SSE client connections