Skip to main content
Glama

switch_page

Navigate between browser pages in Playwright automation by specifying a page ID to switch context for testing or scraping tasks.

Instructions

Switch to a different browser page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
page_idYes

Implementation Reference

  • Registration of the 'switch_page' tool in the list_tools handler, including its schema definition.
    types.Tool(
        name="switch_page",
        description="Switch to a different browser page",
        inputSchema={
            "type": "object",
            "properties": {
                "page_id": {"type": "string"},
            },
            "required": ["page_id"],
        },
    ),
  • Handler logic for the 'switch_page' tool: retrieves page_id from arguments, validates existence, updates global current_page_id, and returns confirmation.
    elif name == "switch_page":
        page_id = arguments.get("page_id")
        if not page_id:
            raise ValueError("Page ID is required")
            
        if page_id not in pages:
            raise ValueError(f"Page ID '{page_id}' not found")
            
        current_page_id = page_id
        
        return [types.TextContent(type="text", text=f"Switched to page: {page_id}")]
  • Helper function get_active_page used by switch_page and other tools to retrieve the active Page object based on page_id or current_page_id.
    def get_active_page(page_id: Optional[str] = None) -> Page:
        """Get the active page based on page_id or current default."""
        global current_page_id
        
        if page_id is None:
            page_id = current_page_id
        
        if page_id not in pages:
            raise ValueError(f"Page not found: {page_id}")
        
        return pages[page_id]
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action ('Switch to') but doesn't disclose behavioral traits like whether this changes focus in a browser context, if it requires an open page, what happens on failure, or side effects. This is inadequate 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 with zero waste. It's front-loaded and appropriately sized for the tool's apparent simplicity, earning full marks for 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 tool likely performs a mutation (switching pages), no annotations, no output schema, and 0% schema coverage, the description is incomplete. It lacks details on behavior, parameters, and context needed for an agent to use it correctly, especially among siblings like 'navigate' or 'get_pages'.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It doesn't explain the 'page_id' parameter at all—no mention of what it represents, how to obtain it, or format. The description adds no meaning beyond the bare schema, failing to address the coverage gap.

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

Purpose4/5

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

The description clearly states the verb ('Switch to') and resource ('a different browser page'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'navigate' (which might change URL) or 'get_pages' (which lists pages), so it's not fully specific to sibling context.

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 doesn't mention prerequisites (e.g., needing an existing page), exclusions (e.g., not for creating pages), or compare to siblings like 'new_page' (for creating) or 'navigate' (for URL changes).

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/misanthropic-ai/playwrite-mcp'

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