pilot_set_useragent
Set the browser user agent string to simulate different devices or browsers while preserving cookies and session state for web automation tasks.
Instructions
Set the browser user agent string. Recreates the browser context, preserving cookies and state.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| useragent | Yes | User agent string |
Implementation Reference
- src/tools/settings.ts:137-150 (handler)The handler implementation for the 'pilot_set_useragent' tool. It sets the user agent on the browser manager and recreates the context.
server.tool( 'pilot_set_useragent', 'Set the browser user agent string. Recreates the browser context, preserving cookies and state.', { useragent: z.string().describe('User agent string') }, async ({ useragent }) => { await bm.ensureBrowser(); try { bm.setUserAgent(useragent); const error = await bm.recreateContext(); if (error) { return { content: [{ type: 'text' as const, text: `User agent set to "${useragent}" but: ${error}` }] }; } return { content: [{ type: 'text' as const, text: `User agent set: ${useragent}` }] }; } catch (err) {