Feature Request
Problem
There is currently no way to set custom HTTP headers on all requests (including the initial document navigation and <script> tag loads) via the MCP tools.
The navigate_page tool supports initScript, which can intercept fetch() and XMLHttpRequest calls at runtime. However, initScript runs after the document is already fetched — it cannot set headers on:
- The initial HTML document request (navigation)
<script src="..."> tag loads (parsed from HTML)
- CSS, image, and font loads
Proposed Solution
Add a set_extra_http_headers tool that calls Puppeteer's page.setExtraHTTPHeaders() (which uses CDP Network.setExtraHTTPHeaders under the hood).
Tool definition:
name: set_extra_http_headers
description: Set extra HTTP headers to be sent with every request. Headers persist until cleared. Pass an empty object to clear.
schema:
headers:
type: object
description: "Header name-value pairs, e.g. {\"X-Custom\": \"value\"}"
Behavior:
- Headers apply to ALL subsequent requests on the selected page (document, scripts, fetch, XHR, images, etc.)
- Headers persist across navigations until explicitly cleared with
{}
- Fits naturally in the existing
network category alongside list_network_requests and get_network_request
Use Case
We use chrome-devtools-mcp for visual regression testing of a Shopify storefront widget. The widget's JS bundle is served via a <script> tag in the HTML. To test a PR branch, the storefront server needs to see X-Promise-Tophat: <branch> on the document request to serve the branch-specific bundle URL.
Currently we work around this by using a separate tool (agent-browser) that supports --headers via CDP. Having set_extra_http_headers in chrome-devtools-mcp would eliminate this workaround.
Implementation Notes
The implementation should be straightforward since the MCP already has access to the Puppeteer page object:
// In tools/network.ts
await page.setExtraHTTPHeaders(params.headers);
This is a one-liner on top of existing Puppeteer infrastructure.
Feature Request
Problem
There is currently no way to set custom HTTP headers on all requests (including the initial document navigation and
<script>tag loads) via the MCP tools.The
navigate_pagetool supportsinitScript, which can interceptfetch()andXMLHttpRequestcalls at runtime. However,initScriptruns after the document is already fetched — it cannot set headers on:<script src="...">tag loads (parsed from HTML)Proposed Solution
Add a
set_extra_http_headerstool that calls Puppeteer'spage.setExtraHTTPHeaders()(which uses CDPNetwork.setExtraHTTPHeadersunder the hood).Tool definition:
Behavior:
{}networkcategory alongsidelist_network_requestsandget_network_requestUse Case
We use
chrome-devtools-mcpfor visual regression testing of a Shopify storefront widget. The widget's JS bundle is served via a<script>tag in the HTML. To test a PR branch, the storefront server needs to seeX-Promise-Tophat: <branch>on the document request to serve the branch-specific bundle URL.Currently we work around this by using a separate tool (
agent-browser) that supports--headersvia CDP. Havingset_extra_http_headersin chrome-devtools-mcp would eliminate this workaround.Implementation Notes
The implementation should be straightforward since the MCP already has access to the Puppeteer
pageobject:This is a one-liner on top of existing Puppeteer infrastructure.