Skip to content

fix(mcp): pair proxy fetch with its Undici dispatcher - #29801

Open
seokjeongeum wants to merge 2 commits into
google-gemini:mainfrom
seokjeongeum:fix/mcp-node26-dispatcher
Open

seokjeongeum wants to merge 2 commits into
google-gemini:mainfrom
seokjeongeum:fix/mcp-node26-dispatcher

Conversation

@seokjeongeum

@seokjeongeum seokjeongeum commented Oct 17, 2026 •

Copy link
Copy Markdown

Summary

Fix HTTP MCP connections on Node 26 by pairing fetch with the Undici dispatcher that it understands. JSON and SSE initialization retain configured authorization headers and send one initialization POST per endpoint.

Details

Use Undici fetch for the dispatcher-backed default transport, while preserving explicitly supplied fetch implementations. Keep request-header merging, streamed responses, cancellation, and transport fallback behavior. The HTTP regression tests use local servers; the proxy-bypass fixture sets both environment-variable spellings consistently on Windows.

No authentication, public settings schema, model catalog, or package-version changes.

Related Issues

None linked.

How to Validate

Validated final head b82fcc44082225cb08c65f8ed115d46f1d44a86b, based on upstream ed96faedfd5571f055c44f2c9509d62321d1138d.

  • Focused regression command: node node_modules/vitest/vitest.mjs run --root packages/core src/tools/mcp-client.test.ts src/tools/mcp-client.http.test.ts src/tools/mcp-compliance-transport.test.ts --maxWorkers=1 --minWorkers=1 --coverage.enabled=false. All 97 tests pass on Linux Node 26.0.0 and native Windows Node 24.14.1 and 26.0.0. The nine HTTP cases also pass on Linux Node 20.19.0 and 24.21.0. Coverage includes headers, JSON/SSE, streaming, cancellation, custom fetch, and a single initialization POST.
  • Linux npm run build, npm run typecheck, npm run bundle, changed-file ESLint/Prettier, and git diff --check pass. Native Windows affected CLI/test-utils builds, bundle generation, and workspace typechecks pass; full native core/build asset-copy limitations are recorded below.
  • Actual source launches on Linux and native Windows Node 26 connect to isolated localhost JSON/SSE servers with dummy authorization, one initialization POST each, and unchanged isolated settings. A separate Linux isolated packed-npx consumer passes the same assertions under Node 26. Its 432 installed package files match the packed archive; the binary resolves within the isolated prefix.
  • Built Linux Docker artifact gemini-mcp-validation:b82fcc44 passes the localhost JSON/SSE fixture under Node 20.20.2. Repeated from native Windows through WSL Docker using Linux containers; this is Windows-launched Linux-container coverage.
  • Full npm run preflight ran in a disposable checkout on this final head with Node 22.23.3/npm 10.9.9 and bounded Vitest workers. Clean/install/format/build/full lint/all typechecks pass. Workspace tests report 10 CLI and 76 core failures; every failing test identity reproduces on the matching upstream baseline in the same checkout, runtime, dependencies, and isolated-home environment, with no candidate-only failure. These concern mocked home/workspace paths, keychain mocks, and unavailable bwrap. The script and SEA suites skipped by the failed workspace chain were run separately: 202/202 and 17/17 pass.

A follow-up null-body review claim was checked against the actual compiled transport: localhost HTTP 204/205/304 all preserve status/headers with a null body and empty text under Node 20.19.0, 24.21.0, and 26.0.0 (nine passing cases). The review thread was answered with that evidence and resolved without changing this head.

Known baseline limitations: native Windows core build and asset copying abort with status 3221226505, reproduced with identical upstream build sources and runtime. Native Windows packed-npx version/resolution checks pass and both JSON/SSE protocol assertions succeed, but the process aborts during shutdown with UV_HANDLE_CLOSING under Node 24 and 26. The identical shutdown assertion/status reproduces with the matching upstream bundle under both runtimes. This is not recorded as a fully passing native packaged feature run; the npx checklist remains unchecked.

GitHub Testing: CI for this head reports action_required. A maintainer with workflow approval permissions must approve the external-contributor run. Local results do not imply GitHub CI passed. Links and E2E workflows have the same approval gate.

macOS/Seatbelt are unavailable. Podman fixtures remain pending because host sudo authentication is unavailable. No merge requested.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@github-actions github-actions Bot added the size/l A large sized PR label Oct 17, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 418
  • Additions: +368
  • Deletions: -50
  • Files changed: 3

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 a regression in MCP discovery on Node 26, where the mismatch between the built-in fetch and an external Undici dispatcher resulted in missing response headers. The fix aligns the fetch implementation with the dispatcher when a proxy is used, ensuring robust response handling while maintaining support for custom fetch implementations.

Highlights

  • MCP HTTP Proxy Compatibility: Resolved an issue where NO_PROXY configurations caused response header loss on Node 26 by ensuring the fetch implementation and the Undici dispatcher originate from the same package.
  • Testing Infrastructure: Introduced a new HTTP test suite for the MCP client transport and updated existing tests to validate proxy behavior across multiple Node.js runtime versions.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions

Copy link
Copy Markdown

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the MCP client's HTTP transport to use Undici's fetch directly when a proxy is configured, ensuring compatibility with Node 26's dispatcher contract. It also adds a comprehensive test suite for the HTTP transport and updates existing tests to cover multiple NO_PROXY scenarios. A critical issue was identified where reconstructing the Response object with a non-null body for null-body status codes (e.g., 204, 304) will cause a TypeError, and a code suggestion was provided to handle this safely.

Comment thread packages/core/src/tools/mcp-client.ts Resolved
@gemini-cli

gemini-cli Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

This branch is waiting to be deployed

1 waiting deployment
eval-gate — b82fcc44 Waiting Oct 18, 2026 by seokjeongeum via Evaluate Steering & Regressions #2179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l A large sized PR status/need-issue Pull requests that need to have an associated issue. status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant