get_cookies
Retrieve browser cookies from the current page or specified URLs to enable session management and authentication for automated web interactions.
Instructions
Get cookies for the current page or specified URLs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| urls | No | URLs to get cookies for (uses current page URL if not specified) | |
| tabId | No | Tab ID to operate on (uses active tab if not specified) |
Implementation Reference
- src/tools/cookies.ts:22-48 (handler)Handler function that gets cookies for specified URLs or current page using Puppeteer page.cookies()async ({ urls, tabId }) => { const pageResult = await getPageForOperation(tabId); if (!pageResult.success) { return handleResult(pageResult); } const page = pageResult.data; try { const cookies = await page.cookies(...(urls ?? [])); return handleResult(ok({ cookies: cookies.map((cookie) => ({ name: cookie.name, value: cookie.value, domain: cookie.domain, path: cookie.path, expires: cookie.expires, httpOnly: cookie.httpOnly, secure: cookie.secure, sameSite: cookie.sameSite, })), })); } catch (error) { return handleResult(err(normalizeError(error))); } }
- src/tools/cookies.ts:18-49 (registration)Registration of the get_cookies tool including its inline handler on the MCP server.server.tool( 'get_cookies', 'Get cookies for the current page or specified URLs', getCookiesSchema.shape, async ({ urls, tabId }) => { const pageResult = await getPageForOperation(tabId); if (!pageResult.success) { return handleResult(pageResult); } const page = pageResult.data; try { const cookies = await page.cookies(...(urls ?? [])); return handleResult(ok({ cookies: cookies.map((cookie) => ({ name: cookie.name, value: cookie.value, domain: cookie.domain, path: cookie.path, expires: cookie.expires, httpOnly: cookie.httpOnly, secure: cookie.secure, sameSite: cookie.sameSite, })), })); } catch (error) { return handleResult(err(normalizeError(error))); } } );
- src/schemas.ts:172-175 (schema)Zod input schema definition for the get_cookies tool.export const getCookiesSchema = z.object({ urls: z.array(z.string().url()).optional().describe('URLs to get cookies for (uses current page URL if not specified)'), tabId: tabIdSchema, });