Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

set_local_storage

Set a key-value pair in the browser's localStorage on the active page. Specify the key and value to store data locally.

Instructions

Set a localStorage entry on the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesStorage key
valueYesStorage value
tabIdNoTarget tab ID (defaults to active tab)
apiKeyNoAPI key for authentication

Implementation Reference

  • The tool handler function that executes set_local_storage logic. It takes key, value, optional tabId and apiKey, sends a 'set_local_storage' command via the WebSocket bridge, and returns success/error text.
    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` }] };
      }
    );
  • Input schema/validation for set_local_storage using Zod, defining required 'key' (string), required 'value' (string), optional 'tabId' (number), and optional 'apiKey' (string).
    {
      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'),
    },
  • The tool is registered via server.tool() call on line 75 as 'set_local_storage' inside the registerDevtoolsStorageTools function.
    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` }] };
      }
    );
  • The sendCommand method on WebSocketBridge that dispatches the 'set_local_storage' command over WebSocket to the Chrome extension.
    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));
      });
    }
  • The registerAllTools function (called from server.ts) which calls registerDevtoolsStorageTools to register all storage tools including set_local_storage.
    export function registerAllTools(server: McpServer, bridge: WebSocketBridge) {
      registerNavigationTools(server, bridge);
      registerTabManagementTools(server, bridge);
      registerKeyboardTools(server, bridge);
      registerScreenshotTools(server, bridge);
      registerClickTools(server, bridge);
      registerInputTools(server, bridge);
      registerDragDropTools(server, bridge);
      registerHoverTools(server, bridge);
    
      registerDevtoolsSourcesTools(server, bridge);
      registerDevtoolsModifyTools(server, bridge);
      registerDevtoolsNetworkTools(server, bridge);
      registerDevtoolsStorageTools(server, bridge);
      registerDevtoolsConsoleTools(server, bridge);
    
      registerAccessibilityTools(server, bridge);
      registerEmulationTools(server, bridge);
      registerElementTools(server, bridge);
      registerAuditTools(server, bridge);
      registerInteractionTools(server, bridge);
      registerMonitoringTools(server, bridge);
      registerQaTools(server, bridge);
      registerGestureTools(server, bridge);
      registerMacroTools(server, bridge);
      registerVisualRegressionTools(server, bridge);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It only states the basic action, omitting details like overwrite behavior, persistence, or authentication requirements (apiKey parameter).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that front-loads the purpose. However, it could include a brief phrase about targeting a specific tab or authentication without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of annotations and the presence of 4 parameters (including optional tabId and apiKey), the description is too sparse. It fails to mention how tab targeting works or authentication requirements, leaving the agent underinformed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already documents each parameter. The description adds no additional meaning or usage hints beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Set' and the resource 'localStorage entry on the current page.' It is distinct from sibling tools like get_local_storage and remove_local_storage.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives such as set_session_storage, set_cookie, or monitor_storage_events. The agent receives no context for appropriate usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/BrowserGenie/mcp'

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