Skip to main content
Glama
kazuph

MCP Browser Tabs Server

by kazuph

activate_tab_by_id

Focus a specific Chrome tab by its unique ID, bringing it to the front for active use. Requires the tab ID from get_tabs output, enabling precise tab control in the MCP Browser Tabs Server.

Instructions

🔥 PREFERRED METHOD: Activate (focus) a specific tab in Google Chrome using its unique tab ID. Brings the tab to the front and makes it active. Extract the Tab ID from [Tab ID: 1234567890] in get_tabs output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdYesThe exact Tab ID number from [Tab ID: xxxxx] in get_tabs output - NOT the display number

Implementation Reference

  • Core handler function that executes the activation of a Chrome tab by its unique ID using AppleScript executed via osascript.
    async function activateChromeTabById(tabId: number): Promise<void> {
      const script = `
        tell application "Google Chrome"
          set targetTabID to "${tabId}"
          set tabFound to false
          
          repeat with w in (every window)
            repeat with i from 1 to count of (every tab of w)
              set t to item i of (every tab of w)
              if (id of t) as string = targetTabID then
                set (active tab index of w) to i
                set index of w to 1
                set tabFound to true
                exit repeat
              end if
            end repeat
            if tabFound then exit repeat
          end repeat
          
          if not tabFound then
            error "Tab with ID " & targetTabID & " not found"
          end if
        end tell
      `;
    
      try {
        await execAsync(`osascript -e '${script}'`);
      } catch (error) {
        throw new Error(
          `Failed to activate Chrome tab with ID ${tabId}: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • MCP tool dispatch handler block that parses arguments, calls the core activateChromeTabById function, and returns success response.
    if (name === "activate_tab_by_id") {
      const { tabId } = request.params.arguments as { tabId: number };
      await activateChromeTabById(tabId);
      return {
        content: [
          {
            type: "text", 
            text: `✅ Successfully activated tab with ID ${tabId}`,
          },
        ],
      };
    }
  • Zod schema defining the input parameter 'tabId' for the activate_tab_by_id tool.
      z.object({
        tabId: z.number().int().positive().describe("The exact Tab ID number from [Tab ID: xxxxx] in get_tabs output - NOT the display number"),
      })
    ),
  • src/index.ts:249-257 (registration)
    Tool registration in the list of tools returned by tools/list, including name, description, and schema.
    {
      name: "activate_tab_by_id", 
      description: "🔥 PREFERRED METHOD: Activate (focus) a specific tab in Google Chrome using its unique tab ID. Brings the tab to the front and makes it active. Extract the Tab ID from [Tab ID: 1234567890] in get_tabs output.",
      inputSchema: zodToJsonSchema(
        z.object({
          tabId: z.number().int().positive().describe("The exact Tab ID number from [Tab ID: xxxxx] in get_tabs output - NOT the display number"),
        })
      ),
    },
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the tool performs a UI action ('Brings the tab to the front and makes it active'), which implies mutation/focus change. However, it doesn't mention potential side effects like browser window activation or what happens if the tab ID is invalid. The description adds meaningful context beyond basic functionality.

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?

The description is efficiently structured with three sentences: first states purpose and preference, second explains the behavioral effect, third provides usage guidance. Every sentence adds value, and it's front-loaded with the key action. No wasted words or redundancy.

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?

Given the tool's moderate complexity (single parameter, no output schema, no annotations), the description is mostly complete. It covers purpose, usage, and behavioral context adequately. However, it lacks details on error conditions (e.g., invalid tab ID) and doesn't specify return values, which would be helpful since there's no output schema. It compensates well but has minor gaps.

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

Parameters4/5

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

Schema description coverage is 100%, so the schema already documents the tabId parameter thoroughly. The description adds marginal value by reinforcing the source ('Extract the Tab ID from [Tab ID: 1234567890] in get_tabs output') and clarifying it's 'NOT the display number,' but doesn't provide additional syntax or format details beyond the schema. Baseline 3 is appropriate, but the extra clarification earns a slightly higher score.

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 specific action ('activate/focus'), the resource ('a specific tab in Google Chrome'), and the mechanism ('using its unique tab ID'). It distinguishes from siblings by specifying this is the 'PREFERRED METHOD' for activation by ID, differentiating from close_tab operations and get_tabs.

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

Usage Guidelines5/5

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

Explicit guidance is provided on when to use this tool: 'PREFERRED METHOD: Activate (focus) a specific tab... using its unique tab ID' and 'Extract the Tab ID from [Tab ID: 1234567890] in get_tabs output.' This clearly indicates the prerequisite (get_tabs output) and distinguishes it from alternatives like close_tab operations.

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

Related 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/kazuph/mcp-browser-tabs'

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