Skip to main content
Glama
andytango
by andytango

switch_tab

Switch between browser tabs to make a specific tab active for automated interactions like navigation, content extraction, or form filling.

Instructions

Switch to a different tab, making it the active tab for subsequent operations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdYesTab ID to switch to

Implementation Reference

  • Core implementation of switching to the specified tab: retrieves the page from state, sets it as active tab ID, brings the page to front, returns tab info on success or tabNotFound error.
    export async function switchTab(tabId) {
        const page = state.tabs.get(tabId);
        if (!page) {
            return err(tabNotFound(tabId));
        }
        state.activeTabId = tabId;
        try {
            // Bring page to front
            await page.bringToFront();
            return ok({
                id: tabId,
                url: page.url(),
                title: await page.title(),
                isActive: true,
            });
        }
        catch (error) {
            return err(tabNotFound(tabId));
        }
    }
  • Zod schema defining the input for the switch_tab tool: requires a tabId string.
    export const switchTabSchema = z.object({
        tabId: z.string().describe('Tab ID to switch to'),
    });
  • Registers the 'switch_tab' MCP tool on the server, using the switchTabSchema for input validation and an inline async handler that delegates to switchTab and wraps the result with handleResult.
    server.tool('switch_tab', 'Switch to a different tab, making it the active tab for subsequent operations.', switchTabSchema.shape, async ({ tabId }) => {
        const result = await switchTab(tabId);
        return handleResult(result);
    });
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool changes the active tab but does not disclose behavioral traits such as whether it requires specific permissions, if it affects browser state irreversibly, potential errors (e.g., invalid tab ID), or side effects. This is a significant gap for a mutation tool with zero annotation coverage.

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 a single, efficient sentence that is front-loaded with the core action and outcome. Every word earns its place, with no redundant or vague phrasing, making it highly concise and well-structured.

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 tool's complexity (a mutation with no annotations and no output schema), the description is incomplete. It lacks details on behavioral transparency, usage guidelines, and error handling, which are crucial for an agent to invoke it correctly in a browser automation context with many sibling tools.

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 description coverage is 100%, so the schema already documents the 'tabId' parameter. The description does not add any meaning beyond what the schema provides (e.g., format examples, source of tab IDs, or constraints), resulting in the baseline score of 3.

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 ('Switch to a different tab') and the resource ('tab'), distinguishing it from siblings like 'list_tabs' (which lists tabs) and 'new_tab' (which creates tabs). It also specifies the outcome ('making it the active tab for subsequent operations'), which adds clarity beyond just the verb.

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?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites (e.g., needing an existing tab ID from 'list_tabs'), exclusions, or comparisons to similar tools like 'focus' or 'navigate', leaving usage context unclear.

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/andytango/puppeteer-mcp'

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