browser_get_cookies
Retrieve all cookies from the current browser session to manage authentication states or track user data during web automation tasks.
Instructions
Get all cookies
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/cookieTools.ts:7-14 (registration)Direct registration of the 'browser_get_cookies' tool using server.tool(), including the inline handler function that uses CookieService to fetch and return all cookie names.server.tool('browser_get_cookies', 'Get all cookies', {}, async () => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); const cookies = await cookieService.getCookies(); return { content: [{ type: 'text', text: `Cookies: ${cookies.join(', ')}` }], }; });
- src/tools/cookieTools.ts:7-14 (handler)Inline handler for 'browser_get_cookies' tool: retrieves Selenium driver, instantiates CookieService, gets all cookies, and formats response as text.server.tool('browser_get_cookies', 'Get all cookies', {}, async () => { const driver = stateManager.getDriver(); const cookieService = new CookieService(driver); const cookies = await cookieService.getCookies(); return { content: [{ type: 'text', text: `Cookies: ${cookies.join(', ')}` }], }; });
- src/services/cookieService.ts:6-9 (helper)Core helper method getCookies() in CookieService class, which uses Selenium WebDriver to fetch all cookies and returns array of cookie names.async getCookies(): Promise<string[]> { const cookies = await this.driver.manage().getCookies(); return cookies.map(cookie => cookie.name); }