remove_session_storage
Remove a sessionStorage entry from the current page using its key to clear temporary data.
Instructions
Remove a sessionStorage entry from the current page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | Storage key to remove | |
| tabId | No | Target tab ID (defaults to active tab) | |
| apiKey | No | API key for authentication |
Implementation Reference
- src/tools/devtools-storage.ts:138-151 (handler)The handler function that executes the 'remove_session_storage' tool logic. It calls bridge.sendCommand with the command name and key parameter, then returns success/error message.
server.tool( 'remove_session_storage', 'Remove a sessionStorage entry from the current page', { key: z.string().describe('Storage key to remove'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ key, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'remove_session_storage', params: { key }, tabId, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: `sessionStorage["${key}"] removed` }] }; } ); - Zod schema for the tool's input parameters: key (required string), tabId (optional number), apiKey (optional string).
{ key: z.string().describe('Storage key to remove'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, - src/tools/devtools-storage.ts:5-152 (registration)The 'remove_session_storage' tool is registered via server.tool() inside the registerDevtoolsStorageTools function exported from devtools-storage.ts. This function is called from src/tools/index.ts line 42.
export function registerDevtoolsStorageTools(server: McpServer, bridge: WebSocketBridge) { // --- Cookies --- server.tool( 'get_cookies', 'Get cookies for the current page or a specific URL', { url: z.string().optional().describe('URL to get cookies for (defaults to current page URL)'), name: z.string().optional().describe('Filter by cookie name'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ url, name, apiKey }) => { const result = await bridge.sendCommand({ command: 'get_cookies', params: { url, name }, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }] }; } ); server.tool( 'set_cookie', 'Set a cookie', { name: z.string().describe('Cookie name'), value: z.string().describe('Cookie value'), url: z.string().optional().describe('URL to associate the cookie with'), domain: z.string().optional().describe('Cookie domain'), path: z.string().optional().describe('Cookie path'), secure: z.boolean().optional().describe('Secure flag'), httpOnly: z.boolean().optional().describe('HttpOnly flag'), sameSite: z.enum(['no_restriction', 'lax', 'strict']).optional().describe('SameSite attribute'), expirationDate: z.number().optional().describe('Expiration as Unix timestamp in seconds'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ apiKey, ...params }) => { const result = await bridge.sendCommand({ command: 'set_cookie', params, 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 "${params.name}" set` }] }; } ); 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` }] }; } ); // --- Local Storage --- server.tool( 'get_local_storage', 'Read localStorage entries for the current page', { key: z.string().optional().describe('Specific key to read (returns all if omitted)'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ key, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'get_local_storage', params: { key }, tabId, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }] }; } ); server.tool( 'set_local_storage', 'Set a localStorage entry on the current page', { key: z.string().describe('Storage key'), value: z.string().describe('Storage value'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ key, value, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'set_local_storage', params: { key, value }, tabId, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: `localStorage["${key}"] set` }] }; } ); server.tool( 'remove_local_storage', 'Remove a localStorage entry from the current page', { key: z.string().describe('Storage key to remove'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ key, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'remove_local_storage', params: { key }, tabId, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: `localStorage["${key}"] removed` }] }; } ); // --- Session Storage --- server.tool( 'get_session_storage', 'Read sessionStorage entries for the current page', { key: z.string().optional().describe('Specific key to read (returns all if omitted)'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ key, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'get_session_storage', params: { key }, tabId, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: JSON.stringify(result.data, null, 2) }] }; } ); server.tool( 'set_session_storage', 'Set a sessionStorage entry on the current page', { key: z.string().describe('Storage key'), value: z.string().describe('Storage value'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ key, value, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'set_session_storage', params: { key, value }, tabId, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: `sessionStorage["${key}"] set` }] }; } ); server.tool( 'remove_session_storage', 'Remove a sessionStorage entry from the current page', { key: z.string().describe('Storage key to remove'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication'), }, async ({ key, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'remove_session_storage', params: { key }, tabId, apiKey }); if (!result.success) return { content: [{ type: 'text' as const, text: `Error: ${result.error?.message}` }], isError: true }; return { content: [{ type: 'text' as const, text: `sessionStorage["${key}"] removed` }] }; } ); } - src/tools/index.ts:42-42 (registration)Registration hook: registerDevtoolsStorageTools is invoked in registerAllTools to add all devtools storage tools (including remove_session_storage) to the MCP server.
registerDevtoolsStorageTools(server, bridge);