Skip to main content
Glama

navigate

Directs a browser to a specific webpage for automation tasks, enabling LLM-powered clients to control web navigation.

Instructions

Navigate to a URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
page_idNo

Implementation Reference

  • The handler logic for the 'navigate' tool within the handle_call_tool function. It retrieves the URL from arguments, gets the active page, navigates to the URL using page.goto, and returns a success message.
    if name == "navigate":
        url = arguments.get("url")
        if not url:
            raise ValueError("URL is required")
            
        page = get_active_page(arguments.get("page_id"))
        await page.goto(url)
        return [types.TextContent(type="text", text=f"Navigated to {url}")]
  • Registration of the 'navigate' tool in the list_tools handler, including its name, description, and input schema.
    types.Tool(
        name="navigate",
        description="Navigate to a URL",
        inputSchema={
            "type": "object",
            "properties": {
                "url": {"type": "string"},
                "page_id": {"type": "string"},
            },
            "required": ["url"],
        },
    ),
  • Helper function used by the 'navigate' handler to retrieve the active browser page based on page_id or current default.
    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]

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