Skip to content

Conversation

@clChenLiang
Copy link

In test scenarios,
the test environment of the production domain is typically used, which is usually distinguished by headers.
This merge request supports adding headers parameters when accessing the test environment of a project.

@google-cla
Copy link

google-cla bot commented Dec 18, 2025

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.

@clChenLiang clChenLiang force-pushed the main branch 3 times, most recently from cc1113f to 49be28e Compare December 22, 2025 05:33
@clChenLiang
Copy link
Author

can @OrKoN @Lightning00Blade to see this pr ?

Copy link
Collaborator

@Lightning00Blade Lightning00Blade left a comment

Choose a reason for hiding this comment

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

Thank you for your PR, we will discuss if this is something we want to include.
It would be nice to open an issue so other people can find it easier if they want the same feature.

In the mean while I left some comments for the PR itself.

this.#headers = options.headers;

this.#networkCollector = new NetworkCollector(this.browser);
this.#networkCollector = new NetworkCollector(this.browser, undefined, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should not happen in the NetworkCollector. Collectors are there to get "collect" data from the pages as things happen. The code should live inside the McpContext class.


// If we reach here without errors, headers functionality is working
assert.ok(true);
}, { debug: false });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}, { debug: false });
});

Comment on lines +116 to +117
const navigationPromise = page.goto('data:text/html,<html><body>Test</body></html>');
await navigationPromise;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const navigationPromise = page.goto('data:text/html,<html><body>Test</body></html>');
await navigationPromise;
await page.goto('data:text/html,<html><body>Test</body></html>');

});

describe('McpContext headers functionality', () => {
it('works with headers in context options', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test seems to test nothing.
We don't set the headers and we don't check that the headers are properly send on the response attached to the page navigation.

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.

2 participants