fix(core): respect NO_PROXY for network-based MCP servers#27012
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses connectivity issues for local MCP servers in environments with global proxy configurations. By integrating a specialized fetcher that respects the NO_PROXY environment variable, the changes ensure that traffic to local endpoints bypasses unnecessary proxy routing while maintaining existing error handling logic for SSE streams. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces proxy-aware fetching in the MCP client by utilizing undici's EnvHttpProxyAgent to respect the NO_PROXY environment variable. This change ensures that requests to local MCP servers bypass global proxies when configured. The implementation includes logic to wrap the fetch operation, conditionally using the proxy agent and converting undici responses to standard Response objects for compatibility. I have no feedback to provide.
|
✅ 80 tests passed successfully on gemini-3-flash-preview. 🧠 Model Steering GuidanceThis PR modifies files that affect the model's behavior (prompts, tools, or instructions).
This is an automated guidance message triggered by steering logic signatures. |
adamfweidman
left a comment
There was a problem hiding this comment.
Approved with a comment
e3f2d3e
Summary
Fixes issue where local MCP servers (localhost/127.0.0.1) are unreachable when a global proxy is configured, even if
NO_PROXYis set. Introduced a surgical, proxy-aware fetcher specifically for MCP network transports that respectsNO_PROXY.Details
globalThis.fetchwith a localizedundici.fetchusingEnvHttpProxyAgentinmcp-client.ts.EnvHttpProxyAgentcorrectly handlesNO_PROXYandno_proxyenvironment variables.StreamableHTTPClientTransportandSSEClientTransportinitialization, ensuring zero risk to core Gemini API traffic.Related Issues
Fixes #3340
How to Validate
HTTP_PROXYto an invalid address (e.g.,http://127.0.0.1:8888).NO_PROXY=127.0.0.1.gemini chatand attempt to use a tool from the local MCP server.Pre-Merge Checklist