Skip to main content
Glama
BrowserGenie

BrowserGenie MCP Server

by BrowserGenie

select_tab

Switch to a specific open browser tab to make it active and bring its window to front for interaction.

Instructions

Switch to a specific tab. Use this when you need to interact with a different open tab. Makes the tab active and brings its window to front.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdYesID of the tab to activate (get this from list_tabs)
apiKeyNoAPI key for authentication if enabled

Implementation Reference

  • The 'select_tab' tool is registered with the MCP server via server.tool(), using Zod schema for input validation (tabId: number, apiKey: optional string).
    server.tool(
      'select_tab',
      'Switch to a specific tab. Use this when you need to interact with a different open tab. Makes the tab active and brings its window to front.',
      {
        tabId: z.number().describe('ID of the tab to activate (get this from list_tabs)'),
        apiKey: z.string().optional().describe('API key for authentication if enabled'),
      },
      async ({ tabId, apiKey }) => {
        const result = await bridge.sendCommand({
          command: 'select_tab',
          params: { tabId },
          apiKey,
        });
        if (!result.success) {
          return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
        }
        return { content: [{ type: 'text', text: `Activated tab ${tabId}` }] };
      }
    );
  • The handler function for 'select_tab' sends a command via WebSocketBridge to the Chrome extension with command 'select_tab' and the tabId parameter, then returns success or error.
    async ({ tabId, apiKey }) => {
      const result = await bridge.sendCommand({
        command: 'select_tab',
        params: { tabId },
        apiKey,
      });
      if (!result.success) {
        return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true };
      }
      return { content: [{ type: 'text', text: `Activated tab ${tabId}` }] };
    }
  • Input schema for 'select_tab' using Zod: requires 'tabId' as a number and accepts optional 'apiKey' as a string.
    {
      tabId: z.number().describe('ID of the tab to activate (get this from list_tabs)'),
      apiKey: z.string().optional().describe('API key for authentication if enabled'),
    },
  • The 'registerTabManagementTools' function (which registers 'select_tab') is called from 'registerAllTools' in src/tools/index.ts.
    export function registerAllTools(server: McpServer, bridge: WebSocketBridge) {
      registerNavigationTools(server, bridge);
      registerTabManagementTools(server, bridge);
  • src/server.ts:5-11 (registration)
    The MCP server is created and tools are registered via 'registerAllTools' called from 'createServer' in src/server.ts.
    export function createServer(bridge: WebSocketBridge): McpServer {
      const server = new McpServer({
        name: 'browser-genie',
        version: '1.0.0',
      });
    
      registerAllTools(server, bridge);
  • The WebSocketBridge.sendCommand method is the underlying helper that sends the 'select_tab' command as a JSON message 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));
      });
    }
Behavior3/5

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

With no annotations, the description discloses key behaviors (tab activation, window focus). However, it omits potential side effects or error handling, such as what happens if the tab is already focused or if the tabId is invalid.

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

Conciseness5/5

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

Three concise sentences, each adding value: action, usage context, and result. No redundant information. Front-loaded with the core meaning.

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

Completeness4/5

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

For a simple tool with two parameters and no output schema, the description covers the essential purpose and behavior. It could mention error handling or prerequisites but remains adequate for an AI agent.

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?

Schema coverage is 100% and already explains tabId's purpose ('ID of the tab to activate (get this from list_tabs)'). The description adds no additional parameter semantics 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 action ('Switch to a specific tab'), the resource ('tab'), and the outcome ('makes the tab active and brings its window to front'). It distinctly separates this tool from siblings like list_tabs, close_tab, and new_tab.

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

Usage Guidelines4/5

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

Explicitly states when to use ('when you need to interact with a different open tab'). Though it does not explicitly list when not to use, the sibling tool set provides enough context to infer alternatives.

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