Skip to content

Commit f64fce6

Browse files
committed
feat: update pages tools with header
1 parent 4a87702 commit f64fce6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/tools/pages.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ export const newPage = defineTool({
8888
},
8989
schema: {
9090
url: zod.string().describe('URL to load in a new page.'),
91+
headers: zod
92+
.record(zod.string())
93+
.optional()
94+
.describe('Optional headers to send with the navigation request.'),
9195
...timeoutSchema,
9296
},
9397
handler: async (request, response, context) => {
9498
const page = await context.newPage();
9599

100+
if (request.params.headers) {
101+
await page.setExtraHTTPHeaders(request.params.headers);
102+
}
103+
96104
await context.waitForEventsAfterAction(async () => {
97105
await page.goto(request.params.url, {
98106
timeout: request.params.timeout,
@@ -118,6 +126,10 @@ export const navigatePage = defineTool({
118126
'Navigate the page by URL, back or forward in history, or reload.',
119127
),
120128
url: zod.string().optional().describe('Target URL (only type=url)'),
129+
headers: zod
130+
.record(zod.string())
131+
.optional()
132+
.describe('Optional headers to send with the navigation request.'),
121133
ignoreCache: zod
122134
.boolean()
123135
.optional()
@@ -130,6 +142,10 @@ export const navigatePage = defineTool({
130142
timeout: request.params.timeout,
131143
};
132144

145+
if (request.params.headers) {
146+
await page.setExtraHTTPHeaders(request.params.headers);
147+
}
148+
133149
if (!request.params.type && !request.params.url) {
134150
throw new Error('Either URL or a type is required.');
135151
}

0 commit comments

Comments
 (0)