fidelity_save_session
Save the current browser session state to maintain login and account access across restarts, avoiding repeated authentication.
Instructions
Manually save the current browser session state (cookies/localStorage) for persistence across restarts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:463-465 (handler)The async handler for the 'fidelity_save_session' tool. Calls saveSession() from the browser module and returns a success or error message.
async () => { try { await saveSession(); - src/index.ts:459-486 (registration)Registers the 'fidelity_save_session' tool on the MCP server with a description, empty schema (no params), and the handler function.
server.tool( "fidelity_save_session", "Manually save the current browser session state (cookies/localStorage) for persistence across restarts.", {}, async () => { try { await saveSession(); return { content: [ { type: "text", text: "Session state saved successfully.", }, ], }; } catch (e) { return { content: [ { type: "text", text: `Failed to save session: ${e instanceof Error ? e.message : String(e)}`, }, ], isError: true, }; } } ); - src/index.ts:462-462 (schema)Empty input schema for fidelity_save_session — the tool accepts no parameters.
{}, - src/browser.ts:89-98 (helper)Core helper function saveSession() that persists the browser context's storage state (cookies/localStorage) to a JSON file on disk.
export async function saveSession(): Promise<void> { if (!context || !currentConfig) return; const sessionPath = getSessionPath(currentConfig); try { const state = await context.storageState(); fs.writeFileSync(sessionPath, JSON.stringify(state, null, 2)); } catch { // Silently fail if context is already closed } }