camofox_close_session
Close all browser tabs for a user session to complete cleanup. Provide any tab ID from the session to identify the user.
Instructions
Close all browser tabs for a user session. Use for complete cleanup when done with a browsing session.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tabId | Yes | Any tab ID from the session to identify the user |
Implementation Reference
- src/tools/session.ts:75-131 (registration)The tool 'camofox_close_session' is registered via server.tool() with schema (tabId: z.string()) and handler logic.
server.tool( "camofox_close_session", "Close all browser tabs for a user session. Use for complete cleanup when done with a browsing session.", { tabId: z.string().describe("Any tab ID from the session to identify the user") }, async (input: unknown) => { try { const parsed = z .object({ tabId: z.string().describe("Any tab ID from the session to identify the user") }) .parse(input); const tracked = getTrackedTab(parsed.tabId); let autoSaved = false; // Auto-save before session close (best-effort; never blocks close) if (deps.config.autoSave) { const saved = await withAutoTimeout( (async () => { const allTabs = getAllTrackedTabs().filter((t) => t.userId === tracked.userId); const tabForExport = allTabs.find((t) => t.tabId === parsed.tabId) ?? allTabs[0]; if (!tabForExport) { return false; } const cookies = await deps.client.exportCookies(tabForExport.tabId, tracked.userId); if (cookies.length <= 0) { return false; } const autoProfileId = `_auto_${tracked.userId}`; await saveProfile(deps.config.profilesDir, autoProfileId, tracked.userId, cookies, { description: "Auto-saved session", lastUrl: tabForExport.url }); return true; })(), AUTO_PROFILE_TIMEOUT_MS ); autoSaved = saved.ok ? saved.value : false; } try { await deps.client.closeSession(tracked.userId); } finally { clearTrackedTabsByUserId(tracked.userId); } return okResult({ message: `Session closed. All tabs for user ${tracked.userId} have been released.`, autoSaved }); } catch (error) { return toErrorResult(error); } } ); - src/tools/session.ts:76-76 (helper)The tool name 'camofox_close_session' is defined as a string literal.
"camofox_close_session", - src/tools/session.ts:78-80 (schema)Input schema: tabId (z.string()) is the only required parameter. No output schema defined besides the return result.
{ tabId: z.string().describe("Any tab ID from the session to identify the user") }, - src/tools/session.ts:81-130 (handler)The handler function: looks up tracked tab by tabId, optionally auto-saves cookies to a profile, calls deps.client.closeSession(tracked.userId), then clears tracked tabs by userId. Returns success message or error.
async (input: unknown) => { try { const parsed = z .object({ tabId: z.string().describe("Any tab ID from the session to identify the user") }) .parse(input); const tracked = getTrackedTab(parsed.tabId); let autoSaved = false; // Auto-save before session close (best-effort; never blocks close) if (deps.config.autoSave) { const saved = await withAutoTimeout( (async () => { const allTabs = getAllTrackedTabs().filter((t) => t.userId === tracked.userId); const tabForExport = allTabs.find((t) => t.tabId === parsed.tabId) ?? allTabs[0]; if (!tabForExport) { return false; } const cookies = await deps.client.exportCookies(tabForExport.tabId, tracked.userId); if (cookies.length <= 0) { return false; } const autoProfileId = `_auto_${tracked.userId}`; await saveProfile(deps.config.profilesDir, autoProfileId, tracked.userId, cookies, { description: "Auto-saved session", lastUrl: tabForExport.url }); return true; })(), AUTO_PROFILE_TIMEOUT_MS ); autoSaved = saved.ok ? saved.value : false; } try { await deps.client.closeSession(tracked.userId); } finally { clearTrackedTabsByUserId(tracked.userId); } return okResult({ message: `Session closed. All tabs for user ${tracked.userId} have been released.`, autoSaved }); } catch (error) { return toErrorResult(error); } }