Skip to content

feat: add set_extra_http_headers tool for Network.setExtraHTTPHeaders#1209

Open
JayeeHsu wants to merge 2 commits intoChromeDevTools:mainfrom
JayeeHsu:feat/set-extra-http-headers
Open

feat: add set_extra_http_headers tool for Network.setExtraHTTPHeaders#1209
JayeeHsu wants to merge 2 commits intoChromeDevTools:mainfrom
JayeeHsu:feat/set-extra-http-headers

Conversation

@JayeeHsu
Copy link
Copy Markdown

Summary

  • Add a new MCP tool set_extra_http_headers that allows setting extra HTTP headers on all page requests via Puppeteer's page.setExtraHTTPHeaders()
  • Headers persist across navigations and can be cleared by passing an empty object
  • This addresses the need for injecting custom headers (e.g. swim-lane routing, A/B testing, feature flags) on all request types including initial document loads

Closes #1175

Test plan

  • Test setting multiple headers returns correct count and header names
  • Test clearing headers with empty object returns clear confirmation
  • Test headers are actually included in subsequent requests (end-to-end via echo server)

🤖 Generated with Claude Code

@google-cla
Copy link
Copy Markdown

google-cla bot commented Mar 20, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@JayeeHsu JayeeHsu closed this Mar 20, 2026
@JayeeHsu JayeeHsu reopened this Mar 20, 2026
@JayeeHsu JayeeHsu force-pushed the feat/set-extra-http-headers branch from 28ae38f to 4c3697a Compare March 20, 2026 03:36
@JayeeHsu
Copy link
Copy Markdown
Author

I have signed the CLA.

Add a new MCP tool that allows setting extra HTTP headers on all page
requests via Puppeteer's page.setExtraHTTPHeaders(). Headers persist
across navigations and can be cleared by passing an empty object.

This addresses the need for injecting custom headers (e.g. swim-lane
routing, A/B testing, feature flags) on all request types including
initial document loads, which is not possible with initScript alone.

Closes ChromeDevTools#1175
@JayeeHsu JayeeHsu force-pushed the feat/set-extra-http-headers branch from f86f6e5 to 372fe5c Compare March 20, 2026 06:34
@JayeeHsu
Copy link
Copy Markdown
Author

@wolfib Could you help review this?

Copy link
Copy Markdown
Collaborator

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Please align the implementation with the comment in #1175 (comment) To also work better with the CLI interface, perhaps we can have a string format for expressing headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: set_extra_http_headers tool for Network.setExtraHTTPHeaders

2 participants