delete_cookie
Delete a specific cookie from a URL by providing the cookie name and URL. Removes unwanted cookies for browser management.
Instructions
Delete a specific cookie
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Cookie name | |
| url | Yes | URL associated with the cookie | |
| apiKey | No | API key for authentication |
Implementation Reference
- src/tools/devtools-storage.ts:44-57 (handler)The handler/implementation of the delete_cookie tool. It accepts 'name' (required), 'url' (required), and 'apiKey' (optional), sends a 'delete_cookie' command via the WebSocket bridge, and returns a success or error message.
server.tool( 'delete_cookie', 'Delete a specific cookie', { name: z.string().describe('Cookie name'), url: z.string().describe('URL associated with the cookie'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ name, url, apiKey }) => { const result = await bridge.sendCommand({ command: 'delete_cookie', params: { name, url }, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: `Cookie "${name}" deleted` }] }; } ); - src/tools/devtools-storage.ts:47-51 (schema)Input validation schema for delete_cookie using Zod. Requires 'name' (string) and 'url' (string), with optional 'apiKey'.
{ name: z.string().describe('Cookie name'), url: z.string().describe('URL associated with the cookie'), apiKey: z.string().optional().describe('API key for authentication'), }, - src/tools/index.ts:42-42 (registration)Registration point where delete_cookie is registered as part of devtools storage tools via the registerDevtoolsStorageTools function called from registerAllTools.
registerDevtoolsStorageTools(server, bridge); - src/server.ts:5-14 (registration)Top-level server creation that calls registerAllTools, which ultimately registers delete_cookie.
export function createServer(bridge: WebSocketBridge): McpServer { const server = new McpServer({ name: 'browser-genie', version: '1.0.0', }); registerAllTools(server, bridge); return server; } - src/websocket-bridge.ts:63-103 (helper)The WebSocketBridge.sendCommand helper that actually dispatches the 'delete_cookie' command to the Chrome extension over WebSocket and awaits the response.
async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> { if (!this.isConnected()) { return { success: false, error: { code: 'NOT_CONNECTED', message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.', }, }; } const id = crypto.randomUUID(); const timeout = cmd.timeout ?? DEFAULT_TIMEOUT; return new Promise<BridgeResponse>((resolve, reject) => { const timer = setTimeout(() => { this.pending.delete(id); resolve({ success: false, error: { code: 'TIMEOUT', message: `Command '${cmd.command}' timed out after ${timeout}ms`, }, }); }, timeout); this.pending.set(id, { resolve, reject, timer }); const message = { id, type: 'request', command: cmd.command, params: cmd.params, tabId: cmd.tabId, apiKey: cmd.apiKey, timestamp: Date.now(), }; this.client!.send(JSON.stringify(message)); }); }