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"), }) ), },

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