pilot_set_cookie
Set cookies on web pages to manage sessions, store user preferences, or test authentication flows during browser automation.
Instructions
Set a cookie on the current page domain.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Cookie name | |
| value | Yes | Cookie value |
Implementation Reference
- src/tools/settings.ts:33-56 (handler)The handler for 'pilot_set_cookie' is registered and implemented within 'registerSettingsTools' in 'src/tools/settings.ts'. It uses the 'BrowserManager' to add a cookie to the current page's domain.
server.tool( 'pilot_set_cookie', 'Set a cookie on the current page domain.', { name: z.string().describe('Cookie name'), value: z.string().describe('Cookie value'), }, async ({ name, value }) => { await bm.ensureBrowser(); try { const page = bm.getPage(); const url = new URL(page.url()); await page.context().addCookies([{ name, value, domain: url.hostname, path: '/', }]); return { content: [{ type: 'text' as const, text: `Cookie set: ${name}=****` }] }; } catch (err) { return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true }; } } );