Skip to main content
Glama

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
NameRequiredDescriptionDefault
urlsNoURLs to get cookies for (uses current page URL if not specified)
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • 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))); } }
  • 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))); } } );
  • 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, });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/andytango/puppeteer-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server